-
Notifications
You must be signed in to change notification settings - Fork 2
/
data.tf
68 lines (60 loc) · 1.77 KB
/
data.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
#------------------------------------------------
## get asw_default_tags
#------------------------------------------------
data "aws_default_tags" "current" {}
#------------------------------------------------
## get first_public_subnet
#------------------------------------------------
data "aws_subnet" "first_public_subnet" {
depends_on = [aws_subnet.public]
#subnets in this vpc
filter {
name = "vpc-id"
values = [aws_vpc.vpc.id]
}
#subnet with particular expression in their tag:Name
filter {
name = "tag:Name"
values = ["public-${var.public_subnet_config[0].az_name}-${local.name_suffix}"]
}
}
#------------------------------------------------
## get a list of public subnets
#------------------------------------------------
data "aws_subnets" "selected_publics" {
depends_on = [aws_subnet.public]
filter {
name = "vpc-id"
values = [aws_vpc.vpc.id]
}
# Filter subnets by name containing "public"
filter {
name = "tag:Name"
values = ["*public*"]
}
}
#------------------------------------------------
## get a list of private subnets
#------------------------------------------------
data "aws_subnets" "selected_privates" {
depends_on = [aws_subnet.private]
filter {
name = "vpc-id"
values = [aws_vpc.vpc.id]
}
# Filter subnets by name containing "private"
filter {
name = "tag:Name"
values = ["*private*"]
}
}
#------------------------------------------------
## get a list of VPCs
#------------------------------------------------
data "aws_vpcs" "existing_vpcs" {
# Filter existing VPCs based on the specified name
filter {
name = "tag:Name"
values = ["vpc-${local.name_suffix}"]
}
}