forked from ssts-alg/terraform-july
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vpc.tf
45 lines (44 loc) · 1.13 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
resource "aws_vpc" "myvpc" {
cidr_block = "${var.vpc_cidr}"
tags {
Name = "MPTECH"
Env = "Dev"
}
}
#
# resource "aws_subnet" "subnet1" {
# vpc_id = "${aws_vpc.myvpc.id}"
# cidr_block = "${var.subnet_cidr[0]}"
# availability_zone = "us-west-2a"
# tags {
# Name = "MPTECH_SN-1"
# }
# }
# resource "aws_subnet" "subnet2" {
# vpc_id = "${aws_vpc.myvpc.id}"
# cidr_block = "${var.subnet_cidr[1]}"
# availability_zone = "us-west-2b"
# tags {
# Name = "MPTECH_SN-2"
# }
# }
# resource "aws_subnet" "subnet3" {
# vpc_id = "${aws_vpc.myvpc.id}"
# cidr_block = "${var.subnet_cidr[2]}"
# availability_zone = "us-west-2c"
# tags {
# Name = "MPTECH_SN-3"
# }
# }
resource "aws_subnet" "subnet1" {
#count = 3
count = "${length(var.subnet_cidr)}"
#count = "${length(data.aws_availability_zones.available.names)}"
vpc_id = "${aws_vpc.myvpc.id}"
cidr_block = "${element(var.subnet_cidr,count.index)}"
#availability_zone = "${element(var.azs,count.index)}"
availability_zone = "${data.aws_availability_zones.available.names[count.index]}"
tags {
Name = "MPTECH_SN-${count.index + 1}"
}
}