Skip to content

Instantly share code, notes, and snippets.

@johnewart
Created February 19, 2016 20:37
Show Gist options
  • Save johnewart/f2711715f3f2320d83c8 to your computer and use it in GitHub Desktop.
Save johnewart/f2711715f3f2320d83c8 to your computer and use it in GitHub Desktop.
variable region {
default = "us-west-1"
}
provider "aws" {
alias = "east"
region = "us-east-1"
}
resource "aws_s3_bucket" "config" {
provider = "aws.east"
bucket = "egencia_lab"
acl = "private"
}
resource "aws_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
tags {
Name = "test-vpc"
Environment = "test"
Owner = "jewart"
}
}
resource "aws_s3_keys" "infrastructure" {
bucket = "egencia_lab"
provider = "aws.east"
# Read the launch AMI from S3
key {
name = "coreos_ami"
path = "service/${var.region}/app/coreos_ami"
default = "ami-27553a47"
}
key {
name = "vpc_id"
path = "infrastructure/${var.region}/vpc_id"
value = "${aws_vpc.vpc.id}"
}
key {
name = "app_subnet_id"
path = "infrastructure/${var.region}/app_subnet_id"
value = "${aws_subnet.testapp.id}"
}
key {
name = "dmz_subnet_id"
path = "infrastructure/${var.region}/dmz_subnet_id"
value = "${aws_subnet.dmz.id}"
}
}
resource "aws_subnet" "testapp" {
vpc_id = "${aws_vpc.vpc.id}"
cidr_block = "10.0.1.0/24"
availability_zone = "us-west-1a"
tags {
Environment = "test"
}
}
# Start our instance with the dynamic ami value
resource "aws_instance" "app" {
ami = "${aws_s3_keys.app.var.coreos_ami}"
instance_type = "t2.small"
subnet_id = "${aws_s3_keys.infra.var.app_subnet}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment