-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpc.tf
55 lines (47 loc) · 1.06 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
data "aws_vpc" "vpc" {
filter {
name = "tag:Name"
values = [var.vpc-name]
}
}
data "aws_internet_gateway" "igw" {
filter {
name = "tag:Name"
values = [var.igw-name]
}
}
data "aws_subnet" "subnet" {
filter {
name = "tag:Name"
values = [var.subnet-name]
}
}
data "aws_security_group" "sg-default" {
filter {
name = "tag:Name"
values = [var.security-group-name]
}
}
resource "aws_subnet" "public-subnet2" {
vpc_id = data.aws_vpc.vpc.id
cidr_block = "10.0.2.0/24"
availability_zone = "ap-northeast-2b"
map_public_ip_on_launch = true
tags = {
Name = var.subnet-name2
}
}
resource "aws_route_table" "rt2" {
vpc_id = data.aws_vpc.vpc.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = data.aws_internet_gateway.igw.id
}
tags = {
Name = var.rt-name2
}
}
resource "aws_route_table_association" "rt-association2" {
route_table_id = aws_route_table.rt2.id
subnet_id = aws_subnet.public-subnet2.id
}