-
Notifications
You must be signed in to change notification settings - Fork 3
/
aws.tf
78 lines (65 loc) · 1.81 KB
/
aws.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
provider "aws" {
region = "${var.aws_region}"
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
}
// Ubuntu 16.04 official hvm:ebs volumes to their region.
variable "aws_amis" {
default = {
ap-northeast-1 = "ami-be4a24d9"
ap-south-1 = "ami-f9fb8c96"
ap-southeast-1 = "ami-06963965"
eu-central-1 = "ami-fe408091"
eu-west-1 = "ami-6f587e1c"
sa-east-1 = "ami-b6fc64da"
us-east-1 = "ami-e13739f6"
us-west-1 = "ami-d8bdebb8"
}
}
resource "aws_vpc" "terraform" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
tags { Name = "terraform" }
}
resource "aws_internet_gateway" "terraform" {
vpc_id = "${aws_vpc.terraform.id}"
tags { Name = "terraform" }
}
resource "aws_subnet" "terraform" {
vpc_id = "${aws_vpc.terraform.id}"
cidr_block = "10.0.0.0/24"
tags { Name = "terraform" }
availability_zone = "${var.aws_availability_zone}"
map_public_ip_on_launch = true
}
resource "aws_route_table" "terraform" {
vpc_id = "${aws_vpc.terraform.id}"
route {
cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.terraform.id}"
}
tags { Name = "terraform" }
}
// The Route Table Association binds our subnet and route together.
resource "aws_route_table_association" "terraform" {
subnet_id = "${aws_subnet.terraform.id}"
route_table_id = "${aws_route_table.terraform.id}"
}
// The AWS Security Group is akin to a firewall. It specifies the inbound
// only open required ports in a production environment.
resource "aws_security_group" "terraform" {
name = "terraform-web"
vpc_id = "${aws_vpc.terraform.id}"
ingress {
protocol = -1
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
egress {
protocol = -1
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
}