Skip to content

Commit 9b0847d

Browse files
authored
[Issue #5379] Hook up MTLS ceritificates to MTLS ALBs (#5652)
## Summary Work for #5379 ## Changes proposed Following the process for CDN domain names and certificate references, hook up the mtls domain and certificate for the soap.<env>.simpler.grants.gov URLs. ## Validation steps Manually deployed branch to Dev using terraform apply and tested successfully.
1 parent 5116304 commit 9b0847d

File tree

8 files changed

+28
-3
lines changed

8 files changed

+28
-3
lines changed

infra/api/app-config/dev.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module "dev_config" {
77
network_name = "dev"
88
domain_name = "api.dev.simpler.grants.gov"
99
s3_cdn_domain_name = "files.dev.simpler.grants.gov"
10+
mtls_domain_name = "soap.dev.simpler.grants.gov"
1011
enable_https = true
1112
has_database = local.has_database
1213
database_enable_http_endpoint = true

infra/api/app-config/env-config/outputs.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ output "service_config" {
2828
service_name = "${local.prefix}${var.app_name}-${var.environment}"
2929
domain_name = var.domain_name
3030
s3_cdn_domain_name = var.s3_cdn_domain_name
31+
mtls_domain_name = var.mtls_domain_name
3132
enable_https = var.enable_https
3233
region = var.default_region
3334
cpu = var.instance_cpu

infra/api/app-config/env-config/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ variable "s3_cdn_domain_name" {
3030
default = null
3131
}
3232

33+
variable "mtls_domain_name" {
34+
type = string
35+
description = "The domain name for the mTLS side-by-side ALB for the API"
36+
default = null
37+
}
3338
variable "enable_command_execution" {
3439
type = bool
3540
description = "Enables the ability to manually execute commands on running service containers using AWS ECS Exec"

infra/api/app-config/prod.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module "prod_config" {
88
domain_name = "api.simpler.grants.gov"
99
enable_https = true
1010
s3_cdn_domain_name = "files.simpler.grants.gov"
11+
mtls_domain_name = "soap.simpler.grants.gov"
1112
has_database = local.has_database
1213
database_enable_http_endpoint = true
1314
has_incident_management_service = local.has_incident_management_service

infra/api/app-config/staging.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module "staging_config" {
77
network_name = "staging"
88
domain_name = "api.staging.simpler.grants.gov"
99
s3_cdn_domain_name = "files.staging.simpler.grants.gov"
10+
mtls_domain_name = "soap.staging.simpler.grants.gov"
1011
enable_https = true
1112
has_database = local.has_database
1213
database_enable_http_endpoint = true

infra/api/service/main.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ data "aws_acm_certificate" "s3_cdn_cert" {
109109
most_recent = true
110110
}
111111

112+
data "aws_acm_certificate" "mtls_cert" {
113+
count = local.service_config.mtls_domain_name != null ? 1 : 0
114+
domain = local.service_config.mtls_domain_name
115+
most_recent = true
116+
}
117+
112118
data "aws_iam_policy" "app_db_access_policy" {
113119
count = module.app_config.has_database ? 1 : 0
114120
name = local.database_config.app_access_policy_name
@@ -156,9 +162,14 @@ module "service" {
156162
domain_name = local.service_config.domain_name
157163
s3_cdn_domain_name = local.service_config.s3_cdn_domain_name
158164
s3_cdn_certificate_arn = local.service_config.s3_cdn_domain_name != null ? data.aws_acm_certificate.s3_cdn_cert[0].arn : null
159-
hosted_zone_id = null
160165

166+
hosted_zone_id = null
167+
168+
# This is used by the API when hosting a side-by-side ALB for mTLS traffic to the API
161169
enable_mtls_load_balancer = true
170+
mtls_domain_name = local.service_config.mtls_domain_name
171+
mtls_certificate_arn = local.service_config.mtls_domain_name != null ? data.aws_acm_certificate.mtls_cert[0].arn : null
172+
162173

163174
cpu = local.service_config.cpu
164175
memory = local.service_config.memory

infra/modules/service/load_balancer.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ resource "aws_lb_listener" "alb_listener_https" {
8787
load_balancer_arn = aws_lb.alb[count.index].arn
8888
port = 443
8989
protocol = "HTTPS"
90-
#TODO: figure out how we get soap. certificate here for false option
91-
certificate_arn = count.index == 0 ? var.certificate_arn : var.certificate_arn
90+
certificate_arn = count.index == 0 ? var.certificate_arn : var.mtls_certificate_arn
9291
mutual_authentication {
9392
mode = count.index == 1 ? "passthrough" : "off"
9493
}

infra/modules/service/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,4 +317,10 @@ variable "mtls_domain_name" {
317317
type = string
318318
description = "The fully qualified domain name for the mTLS-enabled load balancer"
319319
default = null
320+
}
321+
322+
variable "mtls_certificate_arn" {
323+
description = "The ARN of the certificate to use for the mTLS LB for the API"
324+
type = string
325+
default = null
320326
}

0 commit comments

Comments
 (0)