-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutputs.tf
More file actions
209 lines (177 loc) · 10.1 KB
/
outputs.tf
File metadata and controls
209 lines (177 loc) · 10.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
# Backend Environment Outputs (conditional based on deployed environments)
output "backend_outputs" {
description = "Outputs for all deployed backend environments"
value = {
for env in var.backend_environments : env => {
lambda_function_name = module.abnmo_svm_backend[env].lambda_function_name
lambda_function_url = module.abnmo_svm_backend[env].lambda_function_url
api_gateway_url = module.abnmo_svm_backend[env].api_gateway_url
custom_domain_name = var.dns_validation_complete ? module.abnmo_svm_backend[env].custom_domain_name : "Phase 1: Add DNS records first, then set dns_validation_complete=true"
custom_domain_target = var.dns_validation_complete ? module.abnmo_svm_backend[env].custom_domain_target : "Phase 1: Add DNS records first, then set dns_validation_complete=true"
}
}
}
# Individual environment outputs for backward compatibility
output "dev_lambda_function_name" {
description = "Name of the development Lambda function"
value = contains(var.backend_environments, "development") ? module.abnmo_svm_backend["development"].lambda_function_name : "Development environment not deployed"
}
output "dev_lambda_function_url" {
description = "URL of the development Lambda function"
value = contains(var.backend_environments, "development") ? module.abnmo_svm_backend["development"].lambda_function_url : "Development environment not deployed"
}
output "dev_api_gateway_url" {
description = "URL of the development API Gateway"
value = contains(var.backend_environments, "development") ? module.abnmo_svm_backend["development"].api_gateway_url : "Development environment not deployed"
}
output "dev_custom_domain_name" {
description = "Custom domain name for the development API"
value = contains(var.backend_environments, "development") ? (var.dns_validation_complete ? module.abnmo_svm_backend["development"].custom_domain_name : "Phase 1: Add DNS records first, then set dns_validation_complete=true") : "Development environment not deployed"
}
output "dev_custom_domain_target" {
description = "Target domain for CNAME record (development)"
value = contains(var.backend_environments, "development") ? (var.dns_validation_complete ? module.abnmo_svm_backend["development"].custom_domain_target : "Phase 1: Add DNS records first, then set dns_validation_complete=true") : "Development environment not deployed"
}
# Homolog Environment Outputs
output "homolog_lambda_function_name" {
description = "Name of the homolog Lambda function"
value = contains(var.backend_environments, "homolog") ? module.abnmo_svm_backend["homolog"].lambda_function_name : "Homolog environment not deployed"
}
output "homolog_lambda_function_url" {
description = "URL of the homolog Lambda function"
value = contains(var.backend_environments, "homolog") ? module.abnmo_svm_backend["homolog"].lambda_function_url : "Homolog environment not deployed"
}
output "homolog_api_gateway_url" {
description = "URL of the homolog API Gateway"
value = contains(var.backend_environments, "homolog") ? module.abnmo_svm_backend["homolog"].api_gateway_url : "Homolog environment not deployed"
}
output "homolog_custom_domain_name" {
description = "Custom domain name for the homolog API"
value = contains(var.backend_environments, "homolog") ? (var.dns_validation_complete ? module.abnmo_svm_backend["homolog"].custom_domain_name : "Phase 1: Add DNS records first, then set dns_validation_complete=true") : "Homolog environment not deployed"
}
output "homolog_custom_domain_target" {
description = "Target domain for CNAME record (homolog)"
value = contains(var.backend_environments, "homolog") ? (var.dns_validation_complete ? module.abnmo_svm_backend["homolog"].custom_domain_target : "Phase 1: Add DNS records first, then set dns_validation_complete=true") : "Homolog environment not deployed"
}
# Production Environment Outputs
output "prod_lambda_function_name" {
description = "Name of the production Lambda function"
value = contains(var.backend_environments, "production") ? module.abnmo_svm_backend["production"].lambda_function_name : "Production environment not deployed"
}
output "prod_lambda_function_url" {
description = "URL of the production Lambda function"
value = contains(var.backend_environments, "production") ? module.abnmo_svm_backend["production"].lambda_function_url : "Production environment not deployed"
}
output "prod_api_gateway_url" {
description = "URL of the production API Gateway"
value = contains(var.backend_environments, "production") ? module.abnmo_svm_backend["production"].api_gateway_url : "Production environment not deployed"
}
output "prod_custom_domain_name" {
description = "Custom domain name for the production API"
value = contains(var.backend_environments, "production") ? (var.dns_validation_complete ? module.abnmo_svm_backend["production"].custom_domain_name : "Phase 1: Add DNS records first, then set dns_validation_complete=true") : "Production environment not deployed"
}
output "prod_custom_domain_target" {
description = "Target domain for CNAME record (production)"
value = contains(var.backend_environments, "production") ? (var.dns_validation_complete ? module.abnmo_svm_backend["production"].custom_domain_target : "Phase 1: Add DNS records first, then set dns_validation_complete=true") : "Production environment not deployed"
}
# Centralized Certificate Outputs
output "wildcard_certificate_arn" {
description = "ARN of the wildcard certificate for all API domains"
value = aws_acm_certificate.wildcard_api.arn
}
output "wildcard_certificate_validation_records" {
description = "DNS validation records for the wildcard certificate"
value = aws_acm_certificate.wildcard_api.domain_validation_options
}
# Formatted DNS validation records for easy copying
output "dns_validation_records_formatted" {
description = "Formatted DNS validation records for manual DNS configuration"
value = {
for record in aws_acm_certificate.wildcard_api.domain_validation_options : record.domain_name => {
name = record.resource_record_name
type = record.resource_record_type
value = record.resource_record_value
domain = record.domain_name
}
}
}
output "app_domain" {
description = "Base APP domain configured"
value = var.app_domain
}
output "db_domain" {
description = "Base database domain configured"
value = var.db_domain
}
# Database domain outputs for manual DNS configuration
output "database_dns_records" {
description = "DNS records you need to configure manually for database domains"
value = {
for env in var.database_environments : "db-${env}.${var.db_domain}" => {
type = "A"
name = "db-${env}"
value = aws_eip.database_eip[env].public_ip
domain = var.db_domain
}
}
}
# Database Outputs (conditional based on deployed environments)
output "database_outputs" {
description = "Outputs for all deployed database environments"
value = {
for env in var.database_environments : env => {
public_ip = aws_eip.database_eip[env].public_ip
instance_id = aws_instance.database[env].id
domain = "db-${env}.${var.db_domain}"
}
}
}
# Individual database outputs for backward compatibility
output "database_dev_ip" {
description = "Public IP of the development database"
value = contains(var.database_environments, "development") ? aws_eip.database_eip["development"].public_ip : "Development database not deployed"
}
output "database_homolog_ip" {
description = "Public IP of the Homolog database"
value = contains(var.database_environments, "homolog") ? aws_eip.database_eip["homolog"].public_ip : "Homolog database not deployed"
}
output "database_dev_instance_id" {
description = "Instance ID of the development database"
value = contains(var.database_environments, "development") ? aws_instance.database["development"].id : "Development database not deployed"
}
output "database_homolog_instance_id" {
description = "Instance ID of the homolog database"
value = contains(var.database_environments, "homolog") ? aws_instance.database["homolog"].id : "Homolog database not deployed"
}
output "vpc_id" {
description = "VPC ID"
value = aws_vpc.abnmo_svm_vpc.id
}
output "public_subnet_ids" {
description = "Public subnet IDs"
value = [aws_subnet.public_subnet_a.id, aws_subnet.public_subnet_b.id]
}
output "github_actions_setup_guide" {
description = "GitHub Actions setup instructions and role ARNs"
value = {
instructions = "Add the following values to your GitHub repository secrets:"
secrets = {
AWS_ROLE_TO_ASSUME_DEV = contains(var.backend_environments, "development") ? module.abnmo_svm_backend["development"].github_oidc_deploy_role_arn : "Development environment not deployed"
AWS_ROLE_TO_ASSUME_HOMOLOG = contains(var.backend_environments, "homolog") ? module.abnmo_svm_backend["homolog"].github_oidc_deploy_role_arn : "Homolog environment not deployed"
AWS_ROLE_TO_ASSUME_PROD = contains(var.backend_environments, "production") ? module.abnmo_svm_backend["production"].github_oidc_deploy_role_arn : "Production environment not deployed"
}
}
}
# Individual GitHub Actions role outputs for easy access
output "aws_role_to_assume_dev" {
description = "GitHub Actions role ARN for development environment deployments"
value = contains(var.backend_environments, "development") ? module.abnmo_svm_backend["development"].github_oidc_deploy_role_arn : "Development environment not deployed"
}
output "aws_role_to_assume_homolog" {
description = "GitHub Actions role ARN for homolog environment deployments"
value = contains(var.backend_environments, "homolog") ? module.abnmo_svm_backend["homolog"].github_oidc_deploy_role_arn : "Homolog environment not deployed"
}
output "aws_role_to_assume_prod" {
description = "GitHub Actions role ARN for production environment deployments"
value = contains(var.backend_environments, "production") ? module.abnmo_svm_backend["production"].github_oidc_deploy_role_arn : "Production environment not deployed"
}