github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/builtin/infra/aws/data/simple/main.tf (about) 1 # Generated by Otto, do not edit manually. 2 3 variable "aws_access_key" { 4 description = "Access key for AWS" 5 } 6 7 variable "aws_secret_key" { 8 description = "Secret key for AWS" 9 } 10 11 variable "aws_region" { 12 description = "Region where we will operate." 13 } 14 15 variable "ssh_public_key" { 16 description = "Contents of an SSH public key to grant access to created instances" 17 } 18 19 provider "aws" { 20 access_key = "${var.aws_access_key}" 21 secret_key = "${var.aws_secret_key}" 22 region = "${var.aws_region}" 23 } 24 25 # Main VPC that will contain everything. 26 resource "aws_vpc" "main" { 27 cidr_block = "10.0.0.0/16" 28 29 enable_dns_support = true 30 enable_dns_hostnames = true 31 32 tags { Name = "otto" } 33 } 34 35 # The public subnet is where resources connected to the internet will go 36 resource "aws_subnet" "public" { 37 vpc_id = "${aws_vpc.main.id}" 38 cidr_block = "10.0.2.0/24" 39 map_public_ip_on_launch = true 40 41 tags { Name = "public" } 42 } 43 44 # Internet accessible route table + gateway for the public subnet 45 resource "aws_internet_gateway" "public" { 46 vpc_id = "${aws_vpc.main.id}" 47 } 48 49 resource "aws_route_table" "public" { 50 vpc_id = "${aws_vpc.main.id}" 51 route { 52 cidr_block = "0.0.0.0/0" 53 gateway_id = "${aws_internet_gateway.public.id}" 54 } 55 tags { Name = "public" } 56 } 57 58 resource "aws_route_table_association" "public" { 59 subnet_id = "${aws_subnet.public.id}" 60 route_table_id = "${aws_route_table.public.id}" 61 } 62 63 # SSH key that app implementations can use to grant SSH access to instances 64 resource "aws_key_pair" "main" { 65 key_name = "otto-${element(split("-", aws_vpc.main.id), 1)}" 66 public_key = "${var.ssh_public_key}" 67 }