@aws/nx-plugin 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/LICENSE-THIRD-PARTY +70 -92
  2. package/migrations.json +6 -1
  3. package/package.json +6 -6
  4. package/src/agentcore-gateway/__snapshots__/generator.spec.ts.snap +1 -1
  5. package/src/infra/app/__snapshots__/generator.spec.ts.snap +3 -3
  6. package/src/migrations/v1.0.5/0001-api-custom-domain-runtime-config/metadata.json +3 -0
  7. package/src/migrations/v1.0.5/0001-api-custom-domain-runtime-config/migration.d.ts +6 -0
  8. package/src/migrations/v1.0.5/0001-api-custom-domain-runtime-config/migration.js +362 -0
  9. package/src/migrations/v1.0.5/0001-api-custom-domain-runtime-config/migration.js.map +1 -0
  10. package/src/preset/__snapshots__/generator.spec.ts.snap +2 -2
  11. package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +6 -6
  12. package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +8 -8
  13. package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +4 -4
  14. package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
  15. package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +54 -6
  16. package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +390 -18
  17. package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
  18. package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +4 -4
  19. package/src/py/rdb/__snapshots__/generator.spec.ts.snap +2 -2
  20. package/src/smithy/project/__snapshots__/generator.spec.ts.snap +5 -5
  21. package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +260 -12
  22. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +444 -24
  23. package/src/ts/agent/__snapshots__/generator.spec.ts.snap +4 -4
  24. package/src/ts/dcr-proxy/__snapshots__/generator.spec.ts.snap +1 -1
  25. package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
  26. package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
  27. package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +2 -2
  28. package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +6 -6
  29. package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +21 -21
  30. package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +2 -2
  31. package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +34 -4
  32. package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +20 -2
  33. package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +63 -1
  34. package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +63 -1
  35. package/src/utils/docker.d.ts +1 -1
  36. package/src/utils/versions.d.ts +56 -56
  37. package/src/utils/versions.js +55 -55
  38. package/src/utils/versions.js.map +1 -1
@@ -155,7 +155,7 @@ exports[`py#mcp-server generator > should match snapshot for Terraform generated
155
155
  required_providers {
156
156
  aws = {
157
157
  source = "hashicorp/aws"
158
- version = "6.66.0"
158
+ version = "6.67.0"
159
159
  }
160
160
  null = {
161
161
  source = "hashicorp/null"
@@ -514,7 +514,7 @@ resource "null_resource" "runtime_ready" {
514
514
 
515
515
  provisioner "local-exec" {
516
516
  command = <<-EOT
517
- uv run --with boto3==1.43.103 python -c "
517
+ uv run --with boto3==1.43.108 python -c "
518
518
  import boto3
519
519
  import json
520
520
  import os
@@ -804,8 +804,8 @@ dependencies = [
804
804
  "aws-lambda-powertools==3.35.0",
805
805
  "mcp==1.28.1",
806
806
  "uvicorn==0.54.0",
807
- "boto3==1.43.103",
808
- "aws-opentelemetry-distro==0.20.0"
807
+ "boto3==1.43.108",
808
+ "aws-opentelemetry-distro==0.21.0"
809
809
  ]
810
810
 
811
811
  [dependency-groups]
@@ -222,7 +222,7 @@ exports[`py#rdb generator > should generate Terraform modules 1`] = `
222
222
  }
223
223
  aws = {
224
224
  source = "hashicorp/aws"
225
- version = "6.66.0"
225
+ version = "6.67.0"
226
226
  }
227
227
  external = {
228
228
  source = "hashicorp/external"
@@ -1495,7 +1495,7 @@ dependencies = [
1495
1495
  "alembic==1.20.0",
1496
1496
  "greenlet==3.5.6",
1497
1497
  "asyncpg==0.31.0",
1498
- "boto3==1.43.103",
1498
+ "boto3==1.43.108",
1499
1499
  "aws-lambda-powertools==3.35.0"
1500
1500
  ]
1501
1501
 
@@ -45,7 +45,7 @@ exports[`smithyProjectGenerator > shape libraries > should generate a shape libr
45
45
  "shx rm -rf dist/{projectRoot}/build",
46
46
  "shx rm -rf dist/{projectRoot}/smithy",
47
47
  "shx mkdir -p dist/{projectRoot}/build",
48
- "npx -y mise@2026.9.14 exec smithy@1.74.0 -- smithy build -c {projectRoot}/smithy-build.json --output dist/{projectRoot}/smithy",
48
+ "npx -y mise@2026.10.1 exec smithy@1.74.0 -- smithy build -c {projectRoot}/smithy-build.json --output dist/{projectRoot}/smithy",
49
49
  "shx cp dist/{projectRoot}/smithy/source/model/model.json dist/{projectRoot}/build/model.json"
50
50
  ],
51
51
  "parallel": false,
@@ -122,7 +122,7 @@ exports[`smithyProjectGenerator > should generate smithy project with all custom
122
122
  "shx rm -rf dist/{projectRoot}/build",
123
123
  "shx rm -rf dist/{projectRoot}/smithy",
124
124
  "shx mkdir -p dist/{projectRoot}/build",
125
- "npx -y mise@2026.9.14 exec smithy@1.74.0 -- smithy build -c {projectRoot}/smithy-build.json --output dist/{projectRoot}/smithy",
125
+ "npx -y mise@2026.10.1 exec smithy@1.74.0 -- smithy build -c {projectRoot}/smithy-build.json --output dist/{projectRoot}/smithy",
126
126
  "shx mkdir -p dist/{projectRoot}/build/openapi",
127
127
  "shx cp \\"dist/{projectRoot}/smithy/source/openapi/*.openapi.json\\" dist/{projectRoot}/build/openapi/openapi.json"
128
128
  ],
@@ -180,7 +180,7 @@ exports[`smithyProjectGenerator > should generate smithy project with custom dir
180
180
  "shx rm -rf dist/{projectRoot}/build",
181
181
  "shx rm -rf dist/{projectRoot}/smithy",
182
182
  "shx mkdir -p dist/{projectRoot}/build",
183
- "npx -y mise@2026.9.14 exec smithy@1.74.0 -- smithy build -c {projectRoot}/smithy-build.json --output dist/{projectRoot}/smithy",
183
+ "npx -y mise@2026.10.1 exec smithy@1.74.0 -- smithy build -c {projectRoot}/smithy-build.json --output dist/{projectRoot}/smithy",
184
184
  "shx mkdir -p dist/{projectRoot}/build/openapi",
185
185
  "shx cp \\"dist/{projectRoot}/smithy/source/openapi/*.openapi.json\\" dist/{projectRoot}/build/openapi/openapi.json"
186
186
  ],
@@ -330,7 +330,7 @@ exports[`smithyProjectGenerator > should generate smithy project with default op
330
330
  "shx rm -rf dist/{projectRoot}/build",
331
331
  "shx rm -rf dist/{projectRoot}/smithy",
332
332
  "shx mkdir -p dist/{projectRoot}/build",
333
- "npx -y mise@2026.9.14 exec smithy@1.74.0 -- smithy build -c {projectRoot}/smithy-build.json --output dist/{projectRoot}/smithy",
333
+ "npx -y mise@2026.10.1 exec smithy@1.74.0 -- smithy build -c {projectRoot}/smithy-build.json --output dist/{projectRoot}/smithy",
334
334
  "shx mkdir -p dist/{projectRoot}/build/openapi",
335
335
  "shx cp \\"dist/{projectRoot}/smithy/source/openapi/*.openapi.json\\" dist/{projectRoot}/build/openapi/openapi.json"
336
336
  ],
@@ -474,7 +474,7 @@ exports[`smithyProjectGenerator > should generate smithy project with subdirecto
474
474
  "shx rm -rf dist/{projectRoot}/build",
475
475
  "shx rm -rf dist/{projectRoot}/smithy",
476
476
  "shx mkdir -p dist/{projectRoot}/build",
477
- "npx -y mise@2026.9.14 exec smithy@1.74.0 -- smithy build -c {projectRoot}/smithy-build.json --output dist/{projectRoot}/smithy",
477
+ "npx -y mise@2026.10.1 exec smithy@1.74.0 -- smithy build -c {projectRoot}/smithy-build.json --output dist/{projectRoot}/smithy",
478
478
  "shx mkdir -p dist/{projectRoot}/build/openapi",
479
479
  "shx cp \\"dist/{projectRoot}/smithy/source/openapi/*.openapi.json\\" dist/{projectRoot}/build/openapi/openapi.json"
480
480
  ],
@@ -416,7 +416,7 @@ terraform {
416
416
  required_providers {
417
417
  aws = {
418
418
  source = "hashicorp/aws"
419
- version = "6.66.0"
419
+ version = "6.67.0"
420
420
  }
421
421
  random = {
422
422
  source = "hashicorp/random"
@@ -732,7 +732,7 @@ exports[`tsSmithyApiGenerator > should generate smithy ts api with Terraform pro
732
732
  }
733
733
  aws = {
734
734
  source = "hashicorp/aws"
735
- version = "6.66.0"
735
+ version = "6.67.0"
736
736
  }
737
737
  random = {
738
738
  source = "hashicorp/random"
@@ -833,6 +833,19 @@ variable "tags" {
833
833
  default = {}
834
834
  }
835
835
 
836
+ # Custom domain configuration
837
+ variable "custom_domain_name" {
838
+ description = "Custom domain name for the API. Requires acm_certificate_arn."
839
+ type = string
840
+ default = null
841
+ }
842
+
843
+ variable "acm_certificate_arn" {
844
+ description = "ARN of an ACM certificate (in the API's region) for the custom domain name."
845
+ type = string
846
+ default = null
847
+ }
848
+
836
849
  # Get current AWS region and account ID
837
850
  data "aws_region" "current" {}
838
851
  data "aws_caller_identity" "current" {}
@@ -1275,6 +1288,10 @@ locals {
1275
1288
  ]
1276
1289
  }
1277
1290
 
1291
+ locals {
1292
+ api_url = var.custom_domain_name == null ? "\${aws_api_gateway_stage.api_stage.invoke_url}/" : "https://\${var.custom_domain_name}/"
1293
+ }
1294
+
1278
1295
  # CloudWatch Log Group for Lambda
1279
1296
  resource "aws_cloudwatch_log_group" "lambda_logs" {
1280
1297
  #checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
@@ -1658,11 +1675,41 @@ module "add_url_to_runtime_config" {
1658
1675
 
1659
1676
  namespace = "connection"
1660
1677
  key = "apis"
1661
- value = { "TestApi" = "\${aws_api_gateway_stage.api_stage.invoke_url}/" }
1678
+ value = { "TestApi" = local.api_url }
1662
1679
 
1663
1680
  depends_on = [aws_api_gateway_stage.api_stage]
1664
1681
  }
1665
1682
 
1683
+ # Custom domain for the API, served without the stage path prefix
1684
+ resource "aws_api_gateway_domain_name" "custom_domain" {
1685
+ count = var.custom_domain_name == null ? 0 : 1
1686
+
1687
+ domain_name = var.custom_domain_name
1688
+ regional_certificate_arn = var.acm_certificate_arn
1689
+ security_policy = "TLS_1_2"
1690
+
1691
+ endpoint_configuration {
1692
+ types = ["REGIONAL"]
1693
+ }
1694
+
1695
+ tags = var.tags
1696
+
1697
+ lifecycle {
1698
+ precondition {
1699
+ condition = var.acm_certificate_arn != null
1700
+ error_message = "acm_certificate_arn is required when custom_domain_name is set."
1701
+ }
1702
+ }
1703
+ }
1704
+
1705
+ resource "aws_api_gateway_base_path_mapping" "custom_domain" {
1706
+ count = var.custom_domain_name == null ? 0 : 1
1707
+
1708
+ api_id = module.rest_api.api_id
1709
+ stage_name = aws_api_gateway_stage.api_stage.stage_name
1710
+ domain_name = aws_api_gateway_domain_name.custom_domain[0].domain_name
1711
+ }
1712
+
1666
1713
  # Outputs
1667
1714
 
1668
1715
  # API Gateway Outputs (from core module)
@@ -1691,6 +1738,21 @@ output "stage_invoke_url" {
1691
1738
  value = aws_api_gateway_stage.api_stage.invoke_url
1692
1739
  }
1693
1740
 
1741
+ output "api_url" {
1742
+ description = "URL clients should call: the custom domain if configured, otherwise the stage invoke URL"
1743
+ value = local.api_url
1744
+ }
1745
+
1746
+ output "custom_domain_target_domain_name" {
1747
+ description = "Target domain name to point a DNS alias or CNAME record at for the custom domain"
1748
+ value = var.custom_domain_name == null ? null : aws_api_gateway_domain_name.custom_domain[0].regional_domain_name
1749
+ }
1750
+
1751
+ output "custom_domain_hosted_zone_id" {
1752
+ description = "Hosted zone ID to use for a Route 53 alias record for the custom domain"
1753
+ value = var.custom_domain_name == null ? null : aws_api_gateway_domain_name.custom_domain[0].regional_zone_id
1754
+ }
1755
+
1694
1756
  output "stage_arn" {
1695
1757
  description = "ARN of the API Gateway stage"
1696
1758
  value = aws_api_gateway_stage.api_stage.arn
@@ -2113,7 +2175,7 @@ exports[`tsSmithyApiGenerator > should generate smithy ts api with default optio
2113
2175
  "shx rm -rf dist/{projectRoot}/build",
2114
2176
  "shx rm -rf dist/{projectRoot}/smithy",
2115
2177
  "shx mkdir -p dist/{projectRoot}/build",
2116
- "npx -y mise@2026.9.14 exec smithy@1.74.0 -- smithy build -c {projectRoot}/smithy-build.json --output dist/{projectRoot}/smithy",
2178
+ "npx -y mise@2026.10.1 exec smithy@1.74.0 -- smithy build -c {projectRoot}/smithy-build.json --output dist/{projectRoot}/smithy",
2117
2179
  "shx mkdir -p dist/{projectRoot}/build/openapi",
2118
2180
  "shx cp \\"dist/{projectRoot}/smithy/source/openapi/*.openapi.json\\" dist/{projectRoot}/build/openapi/openapi.json"
2119
2181
  ],
@@ -2253,7 +2315,7 @@ terraform {
2253
2315
  required_providers {
2254
2316
  aws = {
2255
2317
  source = "hashicorp/aws"
2256
- version = "6.66.0"
2318
+ version = "6.67.0"
2257
2319
  }
2258
2320
  random = {
2259
2321
  source = "hashicorp/random"
@@ -2566,7 +2628,7 @@ output "waf_web_acl_arn" {
2566
2628
  }
2567
2629
  aws = {
2568
2630
  source = "hashicorp/aws"
2569
- version = "6.66.0"
2631
+ version = "6.67.0"
2570
2632
  }
2571
2633
  random = {
2572
2634
  source = "hashicorp/random"
@@ -2677,6 +2739,19 @@ variable "tags" {
2677
2739
  default = {}
2678
2740
  }
2679
2741
 
2742
+ # Custom domain configuration
2743
+ variable "custom_domain_name" {
2744
+ description = "Custom domain name for the API. Requires acm_certificate_arn."
2745
+ type = string
2746
+ default = null
2747
+ }
2748
+
2749
+ variable "acm_certificate_arn" {
2750
+ description = "ARN of an ACM certificate (in the API's region) for the custom domain name."
2751
+ type = string
2752
+ default = null
2753
+ }
2754
+
2680
2755
  # Get current AWS region and account ID
2681
2756
  data "aws_region" "current" {}
2682
2757
  data "aws_caller_identity" "current" {}
@@ -3119,6 +3194,10 @@ locals {
3119
3194
  ]
3120
3195
  }
3121
3196
 
3197
+ locals {
3198
+ api_url = var.custom_domain_name == null ? "\${aws_api_gateway_stage.api_stage.invoke_url}/" : "https://\${var.custom_domain_name}/"
3199
+ }
3200
+
3122
3201
  # CloudWatch Log Group for Lambda
3123
3202
  resource "aws_cloudwatch_log_group" "lambda_logs" {
3124
3203
  #checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
@@ -3420,11 +3499,41 @@ module "add_url_to_runtime_config" {
3420
3499
 
3421
3500
  namespace = "connection"
3422
3501
  key = "apis"
3423
- value = { "TestApi" = "\${aws_api_gateway_stage.api_stage.invoke_url}/" }
3502
+ value = { "TestApi" = local.api_url }
3424
3503
 
3425
3504
  depends_on = [aws_api_gateway_stage.api_stage]
3426
3505
  }
3427
3506
 
3507
+ # Custom domain for the API, served without the stage path prefix
3508
+ resource "aws_api_gateway_domain_name" "custom_domain" {
3509
+ count = var.custom_domain_name == null ? 0 : 1
3510
+
3511
+ domain_name = var.custom_domain_name
3512
+ regional_certificate_arn = var.acm_certificate_arn
3513
+ security_policy = "TLS_1_2"
3514
+
3515
+ endpoint_configuration {
3516
+ types = ["REGIONAL"]
3517
+ }
3518
+
3519
+ tags = var.tags
3520
+
3521
+ lifecycle {
3522
+ precondition {
3523
+ condition = var.acm_certificate_arn != null
3524
+ error_message = "acm_certificate_arn is required when custom_domain_name is set."
3525
+ }
3526
+ }
3527
+ }
3528
+
3529
+ resource "aws_api_gateway_base_path_mapping" "custom_domain" {
3530
+ count = var.custom_domain_name == null ? 0 : 1
3531
+
3532
+ api_id = module.rest_api.api_id
3533
+ stage_name = aws_api_gateway_stage.api_stage.stage_name
3534
+ domain_name = aws_api_gateway_domain_name.custom_domain[0].domain_name
3535
+ }
3536
+
3428
3537
  # Outputs
3429
3538
 
3430
3539
  # API Gateway Outputs (from core module)
@@ -3453,6 +3562,21 @@ output "stage_invoke_url" {
3453
3562
  value = aws_api_gateway_stage.api_stage.invoke_url
3454
3563
  }
3455
3564
 
3565
+ output "api_url" {
3566
+ description = "URL clients should call: the custom domain if configured, otherwise the stage invoke URL"
3567
+ value = local.api_url
3568
+ }
3569
+
3570
+ output "custom_domain_target_domain_name" {
3571
+ description = "Target domain name to point a DNS alias or CNAME record at for the custom domain"
3572
+ value = var.custom_domain_name == null ? null : aws_api_gateway_domain_name.custom_domain[0].regional_domain_name
3573
+ }
3574
+
3575
+ output "custom_domain_hosted_zone_id" {
3576
+ description = "Hosted zone ID to use for a Route 53 alias record for the custom domain"
3577
+ value = var.custom_domain_name == null ? null : aws_api_gateway_domain_name.custom_domain[0].regional_zone_id
3578
+ }
3579
+
3456
3580
  output "stage_arn" {
3457
3581
  description = "ARN of the API Gateway stage"
3458
3582
  value = aws_api_gateway_stage.api_stage.arn
@@ -3566,7 +3690,7 @@ terraform {
3566
3690
  required_providers {
3567
3691
  aws = {
3568
3692
  source = "hashicorp/aws"
3569
- version = "6.66.0"
3693
+ version = "6.67.0"
3570
3694
  }
3571
3695
  random = {
3572
3696
  source = "hashicorp/random"
@@ -3879,7 +4003,7 @@ output "waf_web_acl_arn" {
3879
4003
  }
3880
4004
  aws = {
3881
4005
  source = "hashicorp/aws"
3882
- version = "6.66.0"
4006
+ version = "6.67.0"
3883
4007
  }
3884
4008
  random = {
3885
4009
  source = "hashicorp/random"
@@ -3980,6 +4104,19 @@ variable "tags" {
3980
4104
  default = {}
3981
4105
  }
3982
4106
 
4107
+ # Custom domain configuration
4108
+ variable "custom_domain_name" {
4109
+ description = "Custom domain name for the API. Requires acm_certificate_arn."
4110
+ type = string
4111
+ default = null
4112
+ }
4113
+
4114
+ variable "acm_certificate_arn" {
4115
+ description = "ARN of an ACM certificate (in the API's region) for the custom domain name."
4116
+ type = string
4117
+ default = null
4118
+ }
4119
+
3983
4120
  # Get current AWS region and account ID
3984
4121
  data "aws_region" "current" {}
3985
4122
  data "aws_caller_identity" "current" {}
@@ -4422,6 +4559,10 @@ locals {
4422
4559
  ]
4423
4560
  }
4424
4561
 
4562
+ locals {
4563
+ api_url = var.custom_domain_name == null ? "\${aws_api_gateway_stage.api_stage.invoke_url}/" : "https://\${var.custom_domain_name}/"
4564
+ }
4565
+
4425
4566
  # CloudWatch Log Group for Lambda
4426
4567
  resource "aws_cloudwatch_log_group" "lambda_logs" {
4427
4568
  #checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
@@ -4722,11 +4863,41 @@ module "add_url_to_runtime_config" {
4722
4863
 
4723
4864
  namespace = "connection"
4724
4865
  key = "apis"
4725
- value = { "TestApi" = "\${aws_api_gateway_stage.api_stage.invoke_url}/" }
4866
+ value = { "TestApi" = local.api_url }
4726
4867
 
4727
4868
  depends_on = [aws_api_gateway_stage.api_stage]
4728
4869
  }
4729
4870
 
4871
+ # Custom domain for the API, served without the stage path prefix
4872
+ resource "aws_api_gateway_domain_name" "custom_domain" {
4873
+ count = var.custom_domain_name == null ? 0 : 1
4874
+
4875
+ domain_name = var.custom_domain_name
4876
+ regional_certificate_arn = var.acm_certificate_arn
4877
+ security_policy = "TLS_1_2"
4878
+
4879
+ endpoint_configuration {
4880
+ types = ["REGIONAL"]
4881
+ }
4882
+
4883
+ tags = var.tags
4884
+
4885
+ lifecycle {
4886
+ precondition {
4887
+ condition = var.acm_certificate_arn != null
4888
+ error_message = "acm_certificate_arn is required when custom_domain_name is set."
4889
+ }
4890
+ }
4891
+ }
4892
+
4893
+ resource "aws_api_gateway_base_path_mapping" "custom_domain" {
4894
+ count = var.custom_domain_name == null ? 0 : 1
4895
+
4896
+ api_id = module.rest_api.api_id
4897
+ stage_name = aws_api_gateway_stage.api_stage.stage_name
4898
+ domain_name = aws_api_gateway_domain_name.custom_domain[0].domain_name
4899
+ }
4900
+
4730
4901
  # Outputs
4731
4902
 
4732
4903
  # API Gateway Outputs (from core module)
@@ -4755,6 +4926,21 @@ output "stage_invoke_url" {
4755
4926
  value = aws_api_gateway_stage.api_stage.invoke_url
4756
4927
  }
4757
4928
 
4929
+ output "api_url" {
4930
+ description = "URL clients should call: the custom domain if configured, otherwise the stage invoke URL"
4931
+ value = local.api_url
4932
+ }
4933
+
4934
+ output "custom_domain_target_domain_name" {
4935
+ description = "Target domain name to point a DNS alias or CNAME record at for the custom domain"
4936
+ value = var.custom_domain_name == null ? null : aws_api_gateway_domain_name.custom_domain[0].regional_domain_name
4937
+ }
4938
+
4939
+ output "custom_domain_hosted_zone_id" {
4940
+ description = "Hosted zone ID to use for a Route 53 alias record for the custom domain"
4941
+ value = var.custom_domain_name == null ? null : aws_api_gateway_domain_name.custom_domain[0].regional_zone_id
4942
+ }
4943
+
4758
4944
  output "stage_arn" {
4759
4945
  description = "ARN of the API Gateway stage"
4760
4946
  value = aws_api_gateway_stage.api_stage.arn
@@ -4868,7 +5054,7 @@ exports[`tsSmithyApiGenerator > terraform iac > should generate terraform with c
4868
5054
  }
4869
5055
  aws = {
4870
5056
  source = "hashicorp/aws"
4871
- version = "6.66.0"
5057
+ version = "6.67.0"
4872
5058
  }
4873
5059
  random = {
4874
5060
  source = "hashicorp/random"
@@ -4969,6 +5155,19 @@ variable "tags" {
4969
5155
  default = {}
4970
5156
  }
4971
5157
 
5158
+ # Custom domain configuration
5159
+ variable "custom_domain_name" {
5160
+ description = "Custom domain name for the API. Requires acm_certificate_arn."
5161
+ type = string
5162
+ default = null
5163
+ }
5164
+
5165
+ variable "acm_certificate_arn" {
5166
+ description = "ARN of an ACM certificate (in the API's region) for the custom domain name."
5167
+ type = string
5168
+ default = null
5169
+ }
5170
+
4972
5171
  # Get current AWS region and account ID
4973
5172
  data "aws_region" "current" {}
4974
5173
  data "aws_caller_identity" "current" {}
@@ -5411,6 +5610,10 @@ locals {
5411
5610
  ]
5412
5611
  }
5413
5612
 
5613
+ locals {
5614
+ api_url = var.custom_domain_name == null ? "\${aws_api_gateway_stage.api_stage.invoke_url}/" : "https://\${var.custom_domain_name}/"
5615
+ }
5616
+
5414
5617
  # CloudWatch Log Group for Lambda
5415
5618
  resource "aws_cloudwatch_log_group" "lambda_logs" {
5416
5619
  #checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
@@ -5794,11 +5997,41 @@ module "add_url_to_runtime_config" {
5794
5997
 
5795
5998
  namespace = "connection"
5796
5999
  key = "apis"
5797
- value = { "CustomApi" = "\${aws_api_gateway_stage.api_stage.invoke_url}/" }
6000
+ value = { "CustomApi" = local.api_url }
5798
6001
 
5799
6002
  depends_on = [aws_api_gateway_stage.api_stage]
5800
6003
  }
5801
6004
 
6005
+ # Custom domain for the API, served without the stage path prefix
6006
+ resource "aws_api_gateway_domain_name" "custom_domain" {
6007
+ count = var.custom_domain_name == null ? 0 : 1
6008
+
6009
+ domain_name = var.custom_domain_name
6010
+ regional_certificate_arn = var.acm_certificate_arn
6011
+ security_policy = "TLS_1_2"
6012
+
6013
+ endpoint_configuration {
6014
+ types = ["REGIONAL"]
6015
+ }
6016
+
6017
+ tags = var.tags
6018
+
6019
+ lifecycle {
6020
+ precondition {
6021
+ condition = var.acm_certificate_arn != null
6022
+ error_message = "acm_certificate_arn is required when custom_domain_name is set."
6023
+ }
6024
+ }
6025
+ }
6026
+
6027
+ resource "aws_api_gateway_base_path_mapping" "custom_domain" {
6028
+ count = var.custom_domain_name == null ? 0 : 1
6029
+
6030
+ api_id = module.rest_api.api_id
6031
+ stage_name = aws_api_gateway_stage.api_stage.stage_name
6032
+ domain_name = aws_api_gateway_domain_name.custom_domain[0].domain_name
6033
+ }
6034
+
5802
6035
  # Outputs
5803
6036
 
5804
6037
  # API Gateway Outputs (from core module)
@@ -5827,6 +6060,21 @@ output "stage_invoke_url" {
5827
6060
  value = aws_api_gateway_stage.api_stage.invoke_url
5828
6061
  }
5829
6062
 
6063
+ output "api_url" {
6064
+ description = "URL clients should call: the custom domain if configured, otherwise the stage invoke URL"
6065
+ value = local.api_url
6066
+ }
6067
+
6068
+ output "custom_domain_target_domain_name" {
6069
+ description = "Target domain name to point a DNS alias or CNAME record at for the custom domain"
6070
+ value = var.custom_domain_name == null ? null : aws_api_gateway_domain_name.custom_domain[0].regional_domain_name
6071
+ }
6072
+
6073
+ output "custom_domain_hosted_zone_id" {
6074
+ description = "Hosted zone ID to use for a Route 53 alias record for the custom domain"
6075
+ value = var.custom_domain_name == null ? null : aws_api_gateway_domain_name.custom_domain[0].regional_zone_id
6076
+ }
6077
+
5830
6078
  output "stage_arn" {
5831
6079
  description = "ARN of the API Gateway stage"
5832
6080
  value = aws_api_gateway_stage.api_stage.arn