Skip to content

Commit 3608eed

Browse files
author
Srihari Raman
committed
Added ACM SSL cert
1 parent bce133c commit 3608eed

5 files changed

Lines changed: 77 additions & 0 deletions

File tree

terraform/aws/custom_domain.tf

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Custom domain resources for the prod MCP server.
2+
# Only created when var.custom_domain is non-empty (i.e. boston-prod workspace).
3+
# DNS records are managed externally by city IT — no Route53 resources here.
4+
5+
locals {
6+
create_custom_domain = var.custom_domain != "" ? 1 : 0
7+
}
8+
9+
# ── ACM Certificate ──────────────────────────────────────────────────────────
10+
11+
resource "aws_acm_certificate" "mcp_cert" {
12+
count = local.create_custom_domain
13+
domain_name = var.custom_domain
14+
validation_method = "DNS"
15+
16+
tags = {
17+
Name = "${local.lambda_name}-cert"
18+
Environment = var.stage_name
19+
}
20+
21+
lifecycle {
22+
create_before_destroy = true
23+
}
24+
}
25+
26+
# ── API Gateway Custom Domain Name ──────────────────────────────────────────
27+
28+
resource "aws_api_gateway_domain_name" "custom" {
29+
count = local.create_custom_domain
30+
domain_name = var.custom_domain
31+
32+
regional_certificate_arn = aws_acm_certificate.mcp_cert[0].arn
33+
34+
endpoint_configuration {
35+
types = ["REGIONAL"]
36+
}
37+
}
38+
39+
# ── Base Path Mapping ───────────────────────────────────────────────────────
40+
# Empty base path so data-mcp.boston.gov/mcp hits the existing /mcp resource.
41+
42+
resource "aws_api_gateway_base_path_mapping" "custom" {
43+
count = local.create_custom_domain
44+
domain_name = aws_api_gateway_domain_name.custom[0].domain_name
45+
api_id = aws_api_gateway_rest_api.mcp_api.id
46+
stage_name = aws_api_gateway_stage.prod.stage_name
47+
}

terraform/aws/outputs.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,25 @@ output "api_gateway_url" {
2222
description = "API Gateway URL for MCP server (production endpoint with authentication)"
2323
value = "${aws_api_gateway_stage.prod.invoke_url}/mcp"
2424
}
25+
26+
# ── Custom domain outputs (only populated when var.custom_domain is set) ────
27+
28+
output "acm_certificate_arn" {
29+
description = "ARN of the ACM certificate for the custom domain"
30+
value = var.custom_domain != "" ? aws_acm_certificate.mcp_cert[0].arn : null
31+
}
32+
33+
output "acm_validation_cname_name" {
34+
description = "DNS CNAME record name that city IT must create for ACM validation"
35+
value = var.custom_domain != "" ? tolist(aws_acm_certificate.mcp_cert[0].domain_validation_options)[0].resource_record_name : null
36+
}
37+
38+
output "acm_validation_cname_value" {
39+
description = "DNS CNAME record value for ACM validation"
40+
value = var.custom_domain != "" ? tolist(aws_acm_certificate.mcp_cert[0].domain_validation_options)[0].resource_record_value : null
41+
}
42+
43+
output "custom_domain_target" {
44+
description = "API Gateway regional domain name — city IT points the custom domain CNAME here"
45+
value = var.custom_domain != "" ? aws_api_gateway_domain_name.custom[0].regional_domain_name : null
46+
}

terraform/aws/prod.tfvars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ lambda_timeout = 120
77
api_quota_limit = 1000
88
api_rate_limit = 5
99
api_burst_limit = 10
10+
custom_domain = "data-mcp.boston.gov"

terraform/aws/staging.tfvars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ lambda_timeout = 120
77
api_quota_limit = 1000
88
api_rate_limit = 5
99
api_burst_limit = 10
10+
custom_domain = ""

terraform/aws/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,9 @@ variable "stage_name" {
5151
type = string
5252
default = "staging"
5353
}
54+
55+
variable "custom_domain" {
56+
description = "Custom domain name for API Gateway (leave empty to skip custom domain setup)"
57+
type = string
58+
default = ""
59+
}

0 commit comments

Comments
 (0)