Skip to content

Commit 5ea5961

Browse files
author
vijay patel
committed
terraform-variable-example
1 parent fbcd404 commit 5ea5961

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

terraform-variables/provider.tf

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
provider "aws" {
2+
region = "${var.region}"
3+
access_key = "${var.access_key}"
4+
secret_key = "${var.secret_key}"
5+
version = "~> 2.0"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
provider "aws" {
2+
region = "${var.region}"
3+
access_key = "${var.access_key}"
4+
secret_key = "${var.secret_key}"
5+
version = "~> 2.0"
6+
}
7+
8+
resource "aws_instance" "my_web_server" {
9+
ami = "${lookup(var.ami_id, var.region)}"
10+
instance_type = "t2.micro"
11+
}

terraform-variables/variables.tf

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

0 commit comments

Comments
 (0)