Skip to content

Commit

Permalink
terraform-variable-example
Browse files Browse the repository at this point in the history
  • Loading branch information
vijay patel committed Sep 30, 2019
1 parent fbcd404 commit 5ea5961
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions terraform-variables/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
provider "aws" {
region = "${var.region}"
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
version = "~> 2.0"
}
11 changes: 11 additions & 0 deletions terraform-variables/terraform-variable-example.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
provider "aws" {
region = "${var.region}"
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
version = "~> 2.0"
}

resource "aws_instance" "my_web_server" {
ami = "${lookup(var.ami_id, var.region)}"
instance_type = "t2.micro"
}
17 changes: 17 additions & 0 deletions terraform-variables/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
variable "access_key" { }
variable "secret_key" { }
variable "region" {
default="us-east-1"
}
variable "instance_type" {
default="t2.micro"
}

variable "ami_id" {
type = "map"
default = {
us-east-1 = "ami-035b3c7efe6d061d5"
eu-west-2= "ami-132b3c7efe6sdfdsfd"
eu-central-1="ami-9787h5h6nsn"
}
}

0 comments on commit 5ea5961

Please sign in to comment.