forked from terraform-aws-modules/terraform-aws-vpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
outputs.tf
652 lines (520 loc) · 20.9 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
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
locals {
redshift_route_table_ids = aws_route_table.redshift[*].id
public_route_table_ids = aws_route_table.public[*].id
private_route_table_ids = aws_route_table.private[*].id
}
################################################################################
# VPC
################################################################################
output "vpc_id" {
description = "The ID of the VPC"
value = try(aws_vpc.this[0].id, null)
}
output "vpc_arn" {
description = "The ARN of the VPC"
value = try(aws_vpc.this[0].arn, null)
}
output "vpc_cidr_block" {
description = "The CIDR block of the VPC"
value = try(aws_vpc.this[0].cidr_block, null)
}
output "default_security_group_id" {
description = "The ID of the security group created by default on VPC creation"
value = try(aws_vpc.this[0].default_security_group_id, null)
}
output "default_network_acl_id" {
description = "The ID of the default network ACL"
value = try(aws_vpc.this[0].default_network_acl_id, null)
}
output "default_route_table_id" {
description = "The ID of the default route table"
value = try(aws_vpc.this[0].default_route_table_id, null)
}
output "vpc_instance_tenancy" {
description = "Tenancy of instances spin up within VPC"
value = try(aws_vpc.this[0].instance_tenancy, null)
}
output "vpc_enable_dns_support" {
description = "Whether or not the VPC has DNS support"
value = try(aws_vpc.this[0].enable_dns_support, null)
}
output "vpc_enable_dns_hostnames" {
description = "Whether or not the VPC has DNS hostname support"
value = try(aws_vpc.this[0].enable_dns_hostnames, null)
}
output "vpc_main_route_table_id" {
description = "The ID of the main route table associated with this VPC"
value = try(aws_vpc.this[0].main_route_table_id, null)
}
output "vpc_ipv6_association_id" {
description = "The association ID for the IPv6 CIDR block"
value = try(aws_vpc.this[0].ipv6_association_id, null)
}
output "vpc_ipv6_cidr_block" {
description = "The IPv6 CIDR block"
value = try(aws_vpc.this[0].ipv6_cidr_block, null)
}
output "vpc_secondary_cidr_blocks" {
description = "List of secondary CIDR blocks of the VPC"
value = compact(aws_vpc_ipv4_cidr_block_association.this[*].cidr_block)
}
output "vpc_owner_id" {
description = "The ID of the AWS account that owns the VPC"
value = try(aws_vpc.this[0].owner_id, null)
}
################################################################################
# DHCP Options Set
################################################################################
output "dhcp_options_id" {
description = "The ID of the DHCP options"
value = try(aws_vpc_dhcp_options.this[0].id, null)
}
################################################################################
# Internet Gateway
################################################################################
output "igw_id" {
description = "The ID of the Internet Gateway"
value = try(aws_internet_gateway.this[0].id, null)
}
output "igw_arn" {
description = "The ARN of the Internet Gateway"
value = try(aws_internet_gateway.this[0].arn, null)
}
################################################################################
# Publiс Subnets
################################################################################
output "public_subnets" {
description = "List of IDs of public subnets"
value = aws_subnet.public[*].id
}
output "public_subnet_arns" {
description = "List of ARNs of public subnets"
value = aws_subnet.public[*].arn
}
output "public_subnets_cidr_blocks" {
description = "List of cidr_blocks of public subnets"
value = compact(aws_subnet.public[*].cidr_block)
}
output "public_subnets_ipv6_cidr_blocks" {
description = "List of IPv6 cidr_blocks of public subnets in an IPv6 enabled VPC"
value = compact(aws_subnet.public[*].ipv6_cidr_block)
}
output "public_route_table_ids" {
description = "List of IDs of public route tables"
value = local.public_route_table_ids
}
output "public_internet_gateway_route_id" {
description = "ID of the internet gateway route"
value = try(aws_route.public_internet_gateway[0].id, null)
}
output "public_internet_gateway_ipv6_route_id" {
description = "ID of the IPv6 internet gateway route"
value = try(aws_route.public_internet_gateway_ipv6[0].id, null)
}
output "public_route_table_association_ids" {
description = "List of IDs of the public route table association"
value = aws_route_table_association.public[*].id
}
output "public_network_acl_id" {
description = "ID of the public network ACL"
value = try(aws_network_acl.public[0].id, null)
}
output "public_network_acl_arn" {
description = "ARN of the public network ACL"
value = try(aws_network_acl.public[0].arn, null)
}
################################################################################
# Private Subnets
################################################################################
output "private_subnets" {
description = "List of IDs of private subnets"
value = aws_subnet.private[*].id
}
output "private_subnet_arns" {
description = "List of ARNs of private subnets"
value = aws_subnet.private[*].arn
}
output "private_subnets_cidr_blocks" {
description = "List of cidr_blocks of private subnets"
value = compact(aws_subnet.private[*].cidr_block)
}
output "private_subnets_ipv6_cidr_blocks" {
description = "List of IPv6 cidr_blocks of private subnets in an IPv6 enabled VPC"
value = compact(aws_subnet.private[*].ipv6_cidr_block)
}
output "private_route_table_ids" {
description = "List of IDs of private route tables"
value = local.private_route_table_ids
}
output "private_nat_gateway_route_ids" {
description = "List of IDs of the private nat gateway route"
value = aws_route.private_nat_gateway[*].id
}
output "private_ipv6_egress_route_ids" {
description = "List of IDs of the ipv6 egress route"
value = aws_route.private_ipv6_egress[*].id
}
output "private_route_table_association_ids" {
description = "List of IDs of the private route table association"
value = aws_route_table_association.private[*].id
}
output "private_network_acl_id" {
description = "ID of the private network ACL"
value = try(aws_network_acl.private[0].id, null)
}
output "private_network_acl_arn" {
description = "ARN of the private network ACL"
value = try(aws_network_acl.private[0].arn, null)
}
################################################################################
# Outpost Subnets
################################################################################
output "outpost_subnets" {
description = "List of IDs of outpost subnets"
value = aws_subnet.outpost[*].id
}
output "outpost_subnet_arns" {
description = "List of ARNs of outpost subnets"
value = aws_subnet.outpost[*].arn
}
output "outpost_subnets_cidr_blocks" {
description = "List of cidr_blocks of outpost subnets"
value = compact(aws_subnet.outpost[*].cidr_block)
}
output "outpost_subnets_ipv6_cidr_blocks" {
description = "List of IPv6 cidr_blocks of outpost subnets in an IPv6 enabled VPC"
value = compact(aws_subnet.outpost[*].ipv6_cidr_block)
}
output "outpost_network_acl_id" {
description = "ID of the outpost network ACL"
value = try(aws_network_acl.outpost[0].id, null)
}
output "outpost_network_acl_arn" {
description = "ARN of the outpost network ACL"
value = try(aws_network_acl.outpost[0].arn, null)
}
################################################################################
# Database Subnets
################################################################################
output "database_subnets" {
description = "List of IDs of database subnets"
value = aws_subnet.database[*].id
}
output "database_subnet_arns" {
description = "List of ARNs of database subnets"
value = aws_subnet.database[*].arn
}
output "database_subnets_cidr_blocks" {
description = "List of cidr_blocks of database subnets"
value = compact(aws_subnet.database[*].cidr_block)
}
output "database_subnets_ipv6_cidr_blocks" {
description = "List of IPv6 cidr_blocks of database subnets in an IPv6 enabled VPC"
value = compact(aws_subnet.database[*].ipv6_cidr_block)
}
output "database_subnet_group" {
description = "ID of database subnet group"
value = try(aws_db_subnet_group.database[0].id, null)
}
output "database_subnet_group_name" {
description = "Name of database subnet group"
value = try(aws_db_subnet_group.database[0].name, null)
}
output "database_route_table_ids" {
description = "List of IDs of database route tables"
# Refer to https://github.com/terraform-aws-modules/terraform-aws-vpc/pull/926 before changing logic
value = length(aws_route_table.database[*].id) > 0 ? aws_route_table.database[*].id : aws_route_table.private[*].id
}
output "database_internet_gateway_route_id" {
description = "ID of the database internet gateway route"
value = try(aws_route.database_internet_gateway[0].id, null)
}
output "database_nat_gateway_route_ids" {
description = "List of IDs of the database nat gateway route"
value = aws_route.database_nat_gateway[*].id
}
output "database_ipv6_egress_route_id" {
description = "ID of the database IPv6 egress route"
value = try(aws_route.database_ipv6_egress[0].id, null)
}
output "database_route_table_association_ids" {
description = "List of IDs of the database route table association"
value = aws_route_table_association.database[*].id
}
output "database_network_acl_id" {
description = "ID of the database network ACL"
value = try(aws_network_acl.database[0].id, null)
}
output "database_network_acl_arn" {
description = "ARN of the database network ACL"
value = try(aws_network_acl.database[0].arn, null)
}
################################################################################
# Redshift Subnets
################################################################################
output "redshift_subnets" {
description = "List of IDs of redshift subnets"
value = aws_subnet.redshift[*].id
}
output "redshift_subnet_arns" {
description = "List of ARNs of redshift subnets"
value = aws_subnet.redshift[*].arn
}
output "redshift_subnets_cidr_blocks" {
description = "List of cidr_blocks of redshift subnets"
value = compact(aws_subnet.redshift[*].cidr_block)
}
output "redshift_subnets_ipv6_cidr_blocks" {
description = "List of IPv6 cidr_blocks of redshift subnets in an IPv6 enabled VPC"
value = compact(aws_subnet.redshift[*].ipv6_cidr_block)
}
output "redshift_subnet_group" {
description = "ID of redshift subnet group"
value = try(aws_redshift_subnet_group.redshift[0].id, null)
}
output "redshift_route_table_ids" {
description = "List of IDs of redshift route tables"
value = length(local.redshift_route_table_ids) > 0 ? local.redshift_route_table_ids : (var.enable_public_redshift ? local.public_route_table_ids : local.private_route_table_ids)
}
output "redshift_route_table_association_ids" {
description = "List of IDs of the redshift route table association"
value = aws_route_table_association.redshift[*].id
}
output "redshift_public_route_table_association_ids" {
description = "List of IDs of the public redshift route table association"
value = aws_route_table_association.redshift_public[*].id
}
output "redshift_network_acl_id" {
description = "ID of the redshift network ACL"
value = try(aws_network_acl.redshift[0].id, null)
}
output "redshift_network_acl_arn" {
description = "ARN of the redshift network ACL"
value = try(aws_network_acl.redshift[0].arn, null)
}
################################################################################
# Elasticache Subnets
################################################################################
output "elasticache_subnets" {
description = "List of IDs of elasticache subnets"
value = aws_subnet.elasticache[*].id
}
output "elasticache_subnet_arns" {
description = "List of ARNs of elasticache subnets"
value = aws_subnet.elasticache[*].arn
}
output "elasticache_subnets_cidr_blocks" {
description = "List of cidr_blocks of elasticache subnets"
value = compact(aws_subnet.elasticache[*].cidr_block)
}
output "elasticache_subnets_ipv6_cidr_blocks" {
description = "List of IPv6 cidr_blocks of elasticache subnets in an IPv6 enabled VPC"
value = compact(aws_subnet.elasticache[*].ipv6_cidr_block)
}
output "elasticache_subnet_group" {
description = "ID of elasticache subnet group"
value = try(aws_elasticache_subnet_group.elasticache[0].id, null)
}
output "elasticache_subnet_group_name" {
description = "Name of elasticache subnet group"
value = try(aws_elasticache_subnet_group.elasticache[0].name, null)
}
output "elasticache_route_table_ids" {
description = "List of IDs of elasticache route tables"
value = try(coalescelist(aws_route_table.elasticache[*].id, local.private_route_table_ids), [])
}
output "elasticache_route_table_association_ids" {
description = "List of IDs of the elasticache route table association"
value = aws_route_table_association.elasticache[*].id
}
output "elasticache_network_acl_id" {
description = "ID of the elasticache network ACL"
value = try(aws_network_acl.elasticache[0].id, null)
}
output "elasticache_network_acl_arn" {
description = "ARN of the elasticache network ACL"
value = try(aws_network_acl.elasticache[0].arn, null)
}
################################################################################
# Intra Subnets
################################################################################
output "intra_subnets" {
description = "List of IDs of intra subnets"
value = aws_subnet.intra[*].id
}
output "intra_subnet_arns" {
description = "List of ARNs of intra subnets"
value = aws_subnet.intra[*].arn
}
output "intra_subnets_cidr_blocks" {
description = "List of cidr_blocks of intra subnets"
value = compact(aws_subnet.intra[*].cidr_block)
}
output "intra_subnets_ipv6_cidr_blocks" {
description = "List of IPv6 cidr_blocks of intra subnets in an IPv6 enabled VPC"
value = compact(aws_subnet.intra[*].ipv6_cidr_block)
}
output "intra_route_table_ids" {
description = "List of IDs of intra route tables"
value = aws_route_table.intra[*].id
}
output "intra_route_table_association_ids" {
description = "List of IDs of the intra route table association"
value = aws_route_table_association.intra[*].id
}
output "intra_network_acl_id" {
description = "ID of the intra network ACL"
value = try(aws_network_acl.intra[0].id, null)
}
output "intra_network_acl_arn" {
description = "ARN of the intra network ACL"
value = try(aws_network_acl.intra[0].arn, null)
}
################################################################################
# NAT Gateway
################################################################################
output "nat_ids" {
description = "List of allocation ID of Elastic IPs created for AWS NAT Gateway"
value = aws_eip.nat[*].id
}
output "nat_public_ips" {
description = "List of public Elastic IPs created for AWS NAT Gateway"
value = var.reuse_nat_ips ? var.external_nat_ips : aws_eip.nat[*].public_ip
}
output "natgw_ids" {
description = "List of NAT Gateway IDs"
value = aws_nat_gateway.this[*].id
}
################################################################################
# Egress Only Gateway
################################################################################
output "egress_only_internet_gateway_id" {
description = "The ID of the egress only Internet Gateway"
value = try(aws_egress_only_internet_gateway.this[0].id, null)
}
################################################################################
# Customer Gateway
################################################################################
output "cgw_ids" {
description = "List of IDs of Customer Gateway"
value = [for k, v in aws_customer_gateway.this : v.id]
}
output "cgw_arns" {
description = "List of ARNs of Customer Gateway"
value = [for k, v in aws_customer_gateway.this : v.arn]
}
output "this_customer_gateway" {
description = "Map of Customer Gateway attributes"
value = aws_customer_gateway.this
}
################################################################################
# VPN Gateway
################################################################################
output "vgw_id" {
description = "The ID of the VPN Gateway"
value = try(aws_vpn_gateway.this[0].id, aws_vpn_gateway_attachment.this[0].vpn_gateway_id, null)
}
output "vgw_arn" {
description = "The ARN of the VPN Gateway"
value = try(aws_vpn_gateway.this[0].arn, null)
}
################################################################################
# Default VPC
################################################################################
output "default_vpc_id" {
description = "The ID of the Default VPC"
value = try(aws_default_vpc.this[0].id, null)
}
output "default_vpc_arn" {
description = "The ARN of the Default VPC"
value = try(aws_default_vpc.this[0].arn, null)
}
output "default_vpc_cidr_block" {
description = "The CIDR block of the Default VPC"
value = try(aws_default_vpc.this[0].cidr_block, null)
}
output "default_vpc_default_security_group_id" {
description = "The ID of the security group created by default on Default VPC creation"
value = try(aws_default_vpc.this[0].default_security_group_id, null)
}
output "default_vpc_default_network_acl_id" {
description = "The ID of the default network ACL of the Default VPC"
value = try(aws_default_vpc.this[0].default_network_acl_id, null)
}
output "default_vpc_default_route_table_id" {
description = "The ID of the default route table of the Default VPC"
value = try(aws_default_vpc.this[0].default_route_table_id, null)
}
output "default_vpc_instance_tenancy" {
description = "Tenancy of instances spin up within Default VPC"
value = try(aws_default_vpc.this[0].instance_tenancy, null)
}
output "default_vpc_enable_dns_support" {
description = "Whether or not the Default VPC has DNS support"
value = try(aws_default_vpc.this[0].enable_dns_support, null)
}
output "default_vpc_enable_dns_hostnames" {
description = "Whether or not the Default VPC has DNS hostname support"
value = try(aws_default_vpc.this[0].enable_dns_hostnames, null)
}
output "default_vpc_main_route_table_id" {
description = "The ID of the main route table associated with the Default VPC"
value = try(aws_default_vpc.this[0].main_route_table_id, null)
}
################################################################################
# VPC Flow Log
################################################################################
output "vpc_flow_log_id" {
description = "The ID of the Flow Log resource"
value = try(aws_flow_log.this[0].id, null)
}
output "vpc_flow_log_destination_arn" {
description = "The ARN of the destination for VPC Flow Logs"
value = local.flow_log_destination_arn
}
output "vpc_flow_log_destination_type" {
description = "The type of the destination for VPC Flow Logs"
value = var.flow_log_destination_type
}
output "vpc_flow_log_cloudwatch_iam_role_arn" {
description = "The ARN of the IAM role used when pushing logs to Cloudwatch log group"
value = local.flow_log_iam_role_arn
}
################################################################################
# Static values (arguments)
################################################################################
output "azs" {
description = "A list of availability zones specified as argument to this module"
value = var.azs
}
output "name" {
description = "The name of the VPC specified as argument to this module"
value = var.name
}
################################################################################
# Our own outputs
################################################################################
output "private_subnets_az_names" {
description = "List of AZ names of private subnets"
value = aws_subnet.private[*].availability_zone
}
output "private_subnets_az_ids" {
description = "List of AZ IDs of private subnets"
value = aws_subnet.private[*].availability_zone_id
}
output "public_subnets_az_names" {
description = "List of AZ names of public subnets"
value = aws_subnet.public[*].availability_zone
}
output "public_subnets_az_ids" {
description = "List of AZ IDs of public subnets"
value = aws_subnet.public[*].availability_zone_id
}
output "database_subnets_az_names" {
description = "List of AZ names of database subnets"
value = aws_subnet.database[*].availability_zone
}
output "database_subnets_az_ids" {
description = "List of AZ IDs of database subnets"
value = aws_subnet.database[*].availability_zone_id
}