-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutputs.tf
More file actions
150 lines (119 loc) · 5.6 KB
/
Copy pathoutputs.tf
File metadata and controls
150 lines (119 loc) · 5.6 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
####################################################################################################
# VPC Outputs
####################################################################################################
output "vpc_id" {
description = "The ID of the VPC"
value = aws_vpc.main.id
}
output "vpc_cidr" {
description = "The CIDR block of the VPC"
value = aws_vpc.main.cidr_block
}
output "vpc_arn" {
description = "The ARN of the VPC"
value = aws_vpc.main.arn
}
####################################################################################################
# Subnet Outputs
####################################################################################################
output "subnet_ids" {
description = "Map of subnet names to their IDs"
value = { for k, v in aws_subnet.subnets : k => v.id }
}
output "subnet_arns" {
description = "Map of subnet names to their ARNs"
value = { for k, v in aws_subnet.subnets : k => v.arn }
}
output "public_subnet_ids" {
description = "List of public subnet IDs"
value = [for k, v in aws_subnet.subnets : v.id if var.subnets[k].type == "public"]
}
output "private_subnet_ids" {
description = "List of private subnet IDs"
value = [for k, v in aws_subnet.subnets : v.id if var.subnets[k].type == "private"]
}
output "subnet_cidrs" {
description = "Map of subnet names to their CIDR blocks"
value = { for k, v in aws_subnet.subnets : k => v.cidr_block }
}
output "subnet_availability_zones" {
description = "Map of subnet names to their availability zones"
value = { for k, v in aws_subnet.subnets : k => v.availability_zone }
}
####################################################################################################
# Route Table Outputs
####################################################################################################
output "public_route_table_id" {
description = "ID of the public route table (if public subnets exist)"
value = local.has_public_subnets ? aws_route_table.public[0].id : null
}
output "private_route_table_id" {
description = "ID of the private route table"
value = aws_route_table.private.id
}
####################################################################################################
# Internet Gateway Outputs
####################################################################################################
output "internet_gateway_id" {
description = "ID of the Internet Gateway (if public subnets exist)"
value = local.has_public_subnets ? aws_internet_gateway.main[0].id : null
}
####################################################################################################
# NAT Gateway Outputs
####################################################################################################
output "nat_gateway_id" {
description = "ID of the NAT Gateway (if created — not present when using centralized NAT)"
value = local.create_nat_gateway ? aws_nat_gateway.main[0].id : null
}
output "nat_gateway_public_ip" {
description = "Public IP address of the NAT Gateway (if created — not present when using centralized NAT)"
value = local.create_nat_gateway ? aws_eip.nat[0].public_ip : null
}
####################################################################################################
# VPC Endpoint Outputs
####################################################################################################
output "s3_vpc_endpoint_id" {
description = "ID of the S3 VPC Endpoint"
value = aws_vpc_endpoint.s3.id
}
output "s3_vpc_endpoint_prefix_list_id" {
description = "Prefix list ID of the S3 VPC Endpoint (useful for security groups)"
value = aws_vpc_endpoint.s3.prefix_list_id
}
####################################################################################################
# Transit Gateway Outputs
####################################################################################################
output "transit_gateway_id" {
description = "ID of the Transit Gateway (if created)"
value = var.create_transit_gateway ? aws_ec2_transit_gateway.main[0].id : null
}
output "transit_gateway_arn" {
description = "ARN of the Transit Gateway (if created)"
value = var.create_transit_gateway ? aws_ec2_transit_gateway.main[0].arn : null
}
output "transit_gateway_attachment_id" {
description = "ID of the Transit Gateway VPC Attachment (if attached)"
value = local.effective_attach_to_tgw ? aws_ec2_transit_gateway_vpc_attachment.main[0].id : null
}
####################################################################################################
# Metadata Outputs
####################################################################################################
output "has_public_subnets" {
description = "Boolean indicating if the VPC has any public subnets"
value = local.has_public_subnets
}
output "using_centralized_nat" {
description = "Boolean indicating if this VPC uses centralized NAT via Transit Gateway"
value = var.use_centralized_nat
}
####################################################################################################
# Flow Logs Outputs
####################################################################################################
output "flow_log_id" {
description = "ID of the VPC Flow Log (if enabled)"
value = var.enable_flow_logs ? aws_flow_log.main[0].id : null
}
output "flow_logs_log_group_name" {
description = "Name of the CloudWatch log group receiving flow logs (if enabled)"
value = var.enable_flow_logs ? aws_cloudwatch_log_group.flow_logs[0].name : null
}