Skip to content

Instantly share code, notes, and snippets.

@simplytunde
Created June 22, 2017 07:33
Show Gist options
  • Save simplytunde/ec86128e9d17886b242f1294ac19ba0b to your computer and use it in GitHub Desktop.
Save simplytunde/ec86128e9d17886b242f1294ac19ba0b to your computer and use it in GitHub Desktop.
Terraform By Example: Creating Resources
provider "aws" {
alias="uswest2"
region = "us-west-2"
}
provider "aws" {
alias="uswest1"
region = "us-west-1"
}
variable "ami_map" {
type = "map"
default = {
us-west-1 = "ami-563a1736"
us-west-2 = "ami-a07379d9"
}
}
resource "aws_instance" "web1"{
provider = "aws.uswest1"
ami = "${lookup(var.ami_map,"us-west-1")}"
count = "2"
instance_type = "t2.micro"
}
resource "aws_instance" "web2"{
provider = "aws.uswest2"
ami = "${lookup(var.ami_map,"us-west-2")}"
count = "2"
instance_type = "t2.micro"
lifecycle {
create_before_destroy = true
}
timeouts {
create="5m"
delete="10m"
}
depends_on = ["aws_instance.web1"]
}
output "tutorial_output" {
value = "${aws_instance.web2.*.private_ip}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment