-
Notifications
You must be signed in to change notification settings - Fork 8
/
vpc.tf
65 lines (54 loc) · 1.5 KB
/
vpc.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
provider "aws" {
region = "${var.region}"
}
resource "aws_vpc" "main" {
cidr_block = "10.${var.network_number}.0.0/16"
enable_dns_support = true
enable_dns_hostnames = true
tags {
Name = "${var.cluster_name}"
cluster = "${var.cluster_name}"
product = "${var.tag_product}"
purpose = "${var.tag_purpose}"
builder = "terraform"
}
lifecycle {
create_before_destroy = true
}
}
resource "aws_vpc_dhcp_options_association" "dns_resolver" {
vpc_id = "${aws_vpc.main.id}"
dhcp_options_id = "${aws_vpc_dhcp_options.search.id}"
}
resource "aws_vpc_dhcp_options" "search" {
domain_name = "${var.fqdn} ${var.region}.compute.internal"
domain_name_servers = ["AmazonProvidedDNS"]
tags {
Name = "${var.cluster_name}_default_search"
cluster = "${var.cluster_name}"
product = "${var.tag_product}"
purpose = "${var.tag_purpose}"
}
}
resource "aws_internet_gateway" "default" {
vpc_id = "${aws_vpc.main.id}"
tags {
Name = "${var.cluster_name}_ig"
cluster = "${var.cluster_name}"
product = "${var.tag_product}"
purpose = "${var.tag_purpose}"
builder = "terraform"
}
lifecycle {
create_before_destroy = true
}
}
# s3 endpoint
resource "aws_vpc_endpoint" "private-s3" {
vpc_id = "${aws_vpc.main.id}"
service_name = "com.amazonaws.${var.region}.s3"
route_table_ids = ["${aws_route_table.private.*.id}", "${aws_route_table.public.id}"]
lifecycle {
create_before_destroy = true
}
}