Skip to content

Commit c1ce127

Browse files
committed
added terraform variable files and modified main source file
1 parent 2ff214a commit c1ce127

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

Aws-instance-example.tf

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
provider "aws"{
2-
region = "us-east-1"
3-
access_key = "AKIASGHX7SHCBQNPCDUB"
4-
secret_key = "apmH6dOPA1GR7t9/5QQlyhZ6vdI6MFP6FjpEcJ2L"
5-
version = "~> 2.0"
6-
1+
provider "aws" {
2+
region = "${var.region}"
3+
access_key = "${var.access_key}"
4+
secret_key = "${var.secret_key}"
5+
version = "~> 2.0"
76
}
87

9-
resource "aws_instance" "web" {
10-
ami = "ami-0ad82a384c06c911e"
8+
resource "aws_instance" "web1" {
9+
ami = "${lookup(var.ami_id, var.region)}"
1110
instance_type = "t2.micro"
12-
13-
tags = {
14-
Name = "HelloWorld"
15-
}
1611
}

variables.tf

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
variable "access_key" { }
2+
variable "secret_key" { }
3+
variable "region" {
4+
default="us-east-1"
5+
}
6+
7+
variable "ami_id" {
8+
type = "map"
9+
default = {
10+
us-east-1 = "ami-035b3c7efe6d061d5"
11+
eu-west-2= "ami-132b3c7efe6sdfdsfd"
12+
eu-central-1="ami-9787h5h6nsn"
13+
}
14+
}

0 commit comments

Comments
 (0)