-
Notifications
You must be signed in to change notification settings - Fork 6
/
data.tf
108 lines (88 loc) · 2.23 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
data "aws_vpc" "this" {
provider = aws.satellite
count = local.create ? 1 : 0
filter {
name = "tag:Name"
values = [var.vpc_name_to_attach]
}
}
data "aws_subnets" "this" {
provider = aws.satellite
count = local.create ? 1 : 0
filter {
name = "vpc-id"
values = [data.aws_vpc.this[0].id]
}
dynamic "filter" {
for_each = var.attachment_subnet_filters
content {
name = filter.value["name"]
values = filter.value["values"]
}
}
}
data "aws_subnets" "private" {
provider = aws.satellite
count = local.create ? 1 : 0
filter {
name = "vpc-id"
values = [data.aws_vpc.this[0].id]
}
dynamic "filter" {
for_each = var.private_subnet_filters
content {
name = filter.value["name"]
values = filter.value["values"]
}
}
}
data "aws_route_tables" "all" {
provider = aws.satellite
count = local.create ? 1 : 0
vpc_id = data.aws_vpc.this[0].id
}
data "aws_route_table" "all" {
provider = aws.satellite
for_each = toset(data.aws_route_tables.all[0].ids)
vpc_id = data.aws_vpc.this[0].id
filter {
name = "route-table-id"
values = [each.value]
}
}
data "aws_route_table" "this" {
provider = aws.satellite
count = local.create ? length(local.private_subnets_with_rt) : 0
subnet_id = sort(local.private_subnets_with_rt)[count.index]
}
data "aws_ec2_transit_gateway" "this" {
provider = aws.hub
count = local.create && var.transit_gateway_hub_name != "" ? 1 : 0
filter {
name = "state"
values = ["available"]
}
filter {
name = "owner-id"
values = [var.aws_account_id_hub]
}
filter {
name = "transit-gateway-id"
values = [data.aws_ram_resource_share.this[0].tags.transit-gateway-id]
}
}
data "aws_ec2_transit_gateway_route_table" "this" {
provider = aws.hub
count = local.create && var.transit_gateway_hub_name != "" ? 1 : 0
filter {
name = "transit-gateway-id"
values = [data.aws_ec2_transit_gateway.this[0].id]
}
}
data "aws_ram_resource_share" "this" {
provider = aws.hub
count = local.create && var.transit_gateway_hub_name != "" ? 1 : 0
name = var.transit_gateway_hub_name
resource_owner = "SELF"
resource_share_status = "ACTIVE"
}