-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathoutputs.tf
178 lines (151 loc) · 5.82 KB
/
outputs.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
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
##############################################################################
# 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
}
##############################################################################
# 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 VPC. Only set if enable_hub is false and enable_hub_vpc_id are true."
value = length(ibm_is_vpc_dns_resolution_binding.vpc_dns_resolution_binding_id) == 1 ? ibm_is_vpc_dns_resolution_binding.vpc_dns_resolution_binding_id[0] : null
}
output "dns_endpoint_gateways_by_crn" {
description = "The list of VPEs that are made available for DNS resolution in the created VPC. Only set if enable_hub is false and enable_hub_vpc_id are true."
value = length(ibm_is_vpc_dns_resolution_binding.vpc_dns_resolution_binding_crn) == 1 ? ibm_is_vpc_dns_resolution_binding.vpc_dns_resolution_binding_crn[0] : 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[*].instance_id) : null
}