-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutputs.tf
More file actions
268 lines (227 loc) · 9.1 KB
/
outputs.tf
File metadata and controls
268 lines (227 loc) · 9.1 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
##############################################################################
# VPC GUID
##############################################################################
output "vpc_name" {
description = "Name of VPC created"
value = local.vpc_name
}
output "vpc_id" {
description = "ID of VPC created"
value = local.vpc_id
}
output "vpc_crn" {
description = "CRN of VPC created"
value = local.vpc_crn
}
##############################################################################
##############################################################################
# Public Gateways
##############################################################################
output "public_gateways" {
description = "Map of public gateways by zone"
value = {
for zone in [1, 2, 3] :
"zone-${zone}" => (
var.use_public_gateways["zone-${zone}"] == false
? null
: ibm_is_public_gateway.gateway["zone-${zone}"].id
)
}
}
##############################################################################
##############################################################################
# Subnet Outputs
##############################################################################
output "subnet_ids" {
description = "The IDs of the subnets"
value = [
for subnet in local.subnets :
subnet.id
]
}
output "subnet_detail_list" {
description = "A list of subnets containing names, CIDR blocks, and zones."
value = {
for zone_name in distinct([
for subnet in local.subnets :
subnet.zone
]) :
zone_name => {
for subnet in local.subnets :
subnet.name => {
id = subnet.id
cidr = subnet.ipv4_cidr_block
crn = subnet.crn
} if subnet.zone == zone_name
}
}
}
output "subnet_zone_list" {
description = "A list containing subnet IDs and subnet zones"
value = [
for subnet in local.subnets : {
name = subnet.name
id = subnet.id
zone = subnet.zone
cidr = subnet.ipv4_cidr_block
crn = subnet.crn
}
]
}
output "subnet_detail_map" {
description = "A map of subnets containing IDs, CIDR blocks, and zones"
value = {
for zone_name in distinct([
for subnet in local.subnets :
subnet.zone
]) :
"zone-${substr(zone_name, -1, length(zone_name))}" => [
for subnet in local.subnets :
{
id = subnet.id
zone = subnet.zone
cidr_block = subnet.ipv4_cidr_block
crn = subnet.crn
} if subnet.zone == zone_name
]
}
}
##############################################################################
##############################################################################
# Network ACLs
##############################################################################
output "network_acls" {
description = "List of shortnames and IDs of network ACLs"
value = [
for network_acl in local.acl_object :
{
shortname = network_acl.name
id = ibm_is_network_acl.network_acl[network_acl.name].id
} if var.create_subnets
]
}
##############################################################################
##############################################################################
# VPC flow logs
##############################################################################
output "vpc_flow_logs" {
description = "Details of VPC flow logs collector"
value = var.enable_vpc_flow_logs != true ? [] : [
for flow_log_collector in ibm_is_flow_log.flow_logs :
{
name = flow_log_collector.name
id = flow_log_collector.id
crn = flow_log_collector.crn
href = flow_log_collector.href
state = flow_log_collector.lifecycle_state
}
]
}
##############################################################################
output "cidr_blocks" {
description = "List of CIDR blocks present in VPC stack"
value = [for address in data.ibm_is_vpc_address_prefixes.get_address_prefixes.address_prefixes : address.cidr]
}
output "vpc_data" {
description = "Data of the VPC used in this module, created or existing."
value = data.ibm_is_vpc.vpc
}
##############################################################################
# Routing Tables
##############################################################################
output "default_routing_table" {
description = "The default routing table ID and name that is created along with the VPC."
value = {
routing_table_id = data.ibm_is_vpc.vpc.default_routing_table
routing_table_name = data.ibm_is_vpc.vpc.default_routing_table_name
}
}
output "routing_table_ids" {
description = "List of routing table IDs created by this module."
value = [
for table in ibm_is_vpc_routing_table.route_table :
{
name = table.name
routing_table_id = table.routing_table
}
]
}
output "routing_table_routes" {
description = "List of routing table routes created by this module."
value = [
for route in ibm_is_vpc_routing_table_route.routing_table_routes :
{
name = route.name
routing_table_id = route.routing_table
destination = route.destination
action = route.action
next_hop = route.next_hop
zone = route.zone
}
]
}
##############################################################################
##############################################################################
# Hub and Spoke specific configuration
##############################################################################
output "custom_resolver_hub" {
description = "The custom resolver created for the hub vpc. Only set if enable_hub is set and skip_custom_resolver_hub_creation is false."
value = length(ibm_dns_custom_resolver.custom_resolver_hub) == 1 ? ibm_dns_custom_resolver.custom_resolver_hub[0] : null
}
output "dns_endpoint_gateways_by_id" {
description = "The list of VPEs that are made available for DNS resolution in the created Spoke VPC. Only set if enable_hub is false and enable_hub_vpc_id OR enable_hub_vpc_crn are true."
value = try(length(data.ibm_is_vpc_dns_resolution_bindings.dns_bindings) == 1 ? data.ibm_is_vpc_dns_resolution_bindings.dns_bindings[0].dns_resolution_bindings[0].vpc[0].id : null, null)
}
output "dns_endpoint_gateways_by_crn" {
description = "The list of VPEs that are made available for DNS resolution in the created Spoke VPC. Only set if enable_hub is false and enable_hub_vpc_id OR enable_hub_vpc_crn are true."
value = try(length(data.ibm_is_vpc_dns_resolution_bindings.dns_bindings) == 1 ? data.ibm_is_vpc_dns_resolution_bindings.dns_bindings[0].dns_resolution_bindings[0].vpc[0].crn : null, null)
}
output "dns_instance_id" {
description = "The ID of the DNS instance."
value = (var.enable_hub && !var.skip_custom_resolver_hub_creation) ? (var.use_existing_dns_instance ? var.existing_dns_instance_id : ibm_resource_instance.dns_instance_hub[0].guid) : null
}
output "dns_custom_resolver_id" {
description = "The ID of the DNS Custom Resolver."
value = (var.enable_hub && !var.skip_custom_resolver_hub_creation) ? one(ibm_dns_custom_resolver.custom_resolver_hub[*].custom_resolver_id) : null
}
## DNS Zone and Records
output "dns_zone_state" {
description = "The state of the DNS zone."
value = length(ibm_dns_zone.dns_zone) > 0 ? [for zone in var.dns_zones : { (zone.name) = ibm_dns_zone.dns_zone[zone.name].state }] : null
}
output "dns_zone_id" {
description = "The ID of the DNS zone."
value = length(ibm_dns_zone.dns_zone) > 0 ? [for zone in var.dns_zones : { (zone.name) = ibm_dns_zone.dns_zone[zone.name].zone_id }] : null
}
output "dns_zone" {
description = "A map representing DNS zone information."
value = length(ibm_dns_zone.dns_zone) > 0 ? [for zone in ibm_dns_zone.dns_zone : zone] : null
}
output "dns_record_ids" {
description = "List of all the domain resource records."
value = length(ibm_dns_resource_record.dns_record) > 0 ? local.record_ids : null
}
##############################################################################
# VPN Gateways
##############################################################################
output "vpn_gateways_name" {
description = "[DEPRECATED] List of names of VPN gateways. For more information please refer the [migration guide](https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc/blob/main/docs/migration_guide.md)."
value = [
for gateway in ibm_is_vpn_gateway.vpn_gateway :
gateway.name
]
}
output "vpn_gateways_data" {
description = "[DEPRECATED] Details of VPN gateways data. For more information please refer the [migration guide](https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc/blob/main/docs/migration_guide.md)."
value = [
for gateway in ibm_is_vpn_gateway.vpn_gateway :
gateway
]
}
##############################################################################
# Security Group Details
##############################################################################
output "security_group_details" {
description = "Details of security group."
value = ibm_is_security_group_rule.default_vpc_rule
}