@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.
- package/LICENSE-THIRD-PARTY +70 -92
- package/migrations.json +6 -1
- package/package.json +6 -6
- package/src/agentcore-gateway/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/migrations/v1.0.5/0001-api-custom-domain-runtime-config/metadata.json +3 -0
- package/src/migrations/v1.0.5/0001-api-custom-domain-runtime-config/migration.d.ts +6 -0
- package/src/migrations/v1.0.5/0001-api-custom-domain-runtime-config/migration.js +362 -0
- package/src/migrations/v1.0.5/0001-api-custom-domain-runtime-config/migration.js.map +1 -0
- package/src/preset/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +6 -6
- package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +8 -8
- package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +4 -4
- package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +54 -6
- package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +390 -18
- package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/py/rdb/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/smithy/project/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +260 -12
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +444 -24
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/ts/dcr-proxy/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +21 -21
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +2 -2
- package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +34 -4
- package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +20 -2
- package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +63 -1
- package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +63 -1
- package/src/utils/docker.d.ts +1 -1
- package/src/utils/versions.d.ts +56 -56
- package/src/utils/versions.js +55 -55
- package/src/utils/versions.js.map +1 -1
|
@@ -11,7 +11,7 @@ terraform {
|
|
|
11
11
|
required_providers {
|
|
12
12
|
aws = {
|
|
13
13
|
source = "hashicorp/aws"
|
|
14
|
-
version = "6.
|
|
14
|
+
version = "6.67.0"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -262,7 +262,7 @@ output "api_log_group_arn" {
|
|
|
262
262
|
}
|
|
263
263
|
aws = {
|
|
264
264
|
source = "hashicorp/aws"
|
|
265
|
-
version = "6.
|
|
265
|
+
version = "6.67.0"
|
|
266
266
|
}
|
|
267
267
|
random = {
|
|
268
268
|
source = "hashicorp/random"
|
|
@@ -377,6 +377,19 @@ variable "tags" {
|
|
|
377
377
|
default = {}
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
+
# Custom domain configuration
|
|
381
|
+
variable "custom_domain_name" {
|
|
382
|
+
description = "Custom domain name for the API. Requires acm_certificate_arn."
|
|
383
|
+
type = string
|
|
384
|
+
default = null
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
variable "acm_certificate_arn" {
|
|
388
|
+
description = "ARN of an ACM certificate (in the API's region) for the custom domain name."
|
|
389
|
+
type = string
|
|
390
|
+
default = null
|
|
391
|
+
}
|
|
392
|
+
|
|
380
393
|
# Get current AWS region and account ID
|
|
381
394
|
data "aws_region" "current" {}
|
|
382
395
|
data "aws_caller_identity" "current" {}
|
|
@@ -628,6 +641,10 @@ locals {
|
|
|
628
641
|
]
|
|
629
642
|
}
|
|
630
643
|
|
|
644
|
+
locals {
|
|
645
|
+
api_url = var.custom_domain_name == null ? module.http_api.stage_invoke_url : "https://\${var.custom_domain_name}/"
|
|
646
|
+
}
|
|
647
|
+
|
|
631
648
|
# CloudWatch Log Group for Lambda
|
|
632
649
|
resource "aws_cloudwatch_log_group" "lambda_logs" {
|
|
633
650
|
#checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
|
|
@@ -697,11 +714,41 @@ module "add_url_to_runtime_config" {
|
|
|
697
714
|
|
|
698
715
|
namespace = "connection"
|
|
699
716
|
key = "apis"
|
|
700
|
-
value = { "TestApi" =
|
|
717
|
+
value = { "TestApi" = local.api_url }
|
|
701
718
|
|
|
702
719
|
depends_on = [module.http_api]
|
|
703
720
|
}
|
|
704
721
|
|
|
722
|
+
# Custom domain for the API
|
|
723
|
+
resource "aws_apigatewayv2_domain_name" "custom_domain" {
|
|
724
|
+
count = var.custom_domain_name == null ? 0 : 1
|
|
725
|
+
|
|
726
|
+
domain_name = var.custom_domain_name
|
|
727
|
+
|
|
728
|
+
domain_name_configuration {
|
|
729
|
+
certificate_arn = var.acm_certificate_arn
|
|
730
|
+
endpoint_type = "REGIONAL"
|
|
731
|
+
security_policy = "TLS_1_2"
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
tags = var.tags
|
|
735
|
+
|
|
736
|
+
lifecycle {
|
|
737
|
+
precondition {
|
|
738
|
+
condition = var.acm_certificate_arn != null
|
|
739
|
+
error_message = "acm_certificate_arn is required when custom_domain_name is set."
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
resource "aws_apigatewayv2_api_mapping" "custom_domain" {
|
|
745
|
+
count = var.custom_domain_name == null ? 0 : 1
|
|
746
|
+
|
|
747
|
+
api_id = module.http_api.api_id
|
|
748
|
+
stage = module.http_api.stage_id
|
|
749
|
+
domain_name = aws_apigatewayv2_domain_name.custom_domain[0].domain_name
|
|
750
|
+
}
|
|
751
|
+
|
|
705
752
|
# Lambda permission for API Gateway to invoke the function via alias
|
|
706
753
|
resource "aws_lambda_permission" "api_gateway_invoke" {
|
|
707
754
|
for_each = local.operations
|
|
@@ -744,6 +791,21 @@ output "stage_invoke_url" {
|
|
|
744
791
|
value = module.http_api.stage_invoke_url
|
|
745
792
|
}
|
|
746
793
|
|
|
794
|
+
output "api_url" {
|
|
795
|
+
description = "URL clients should call: the custom domain if configured, otherwise the stage invoke URL"
|
|
796
|
+
value = local.api_url
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
output "custom_domain_target_domain_name" {
|
|
800
|
+
description = "Target domain name to point a DNS alias or CNAME record at for the custom domain"
|
|
801
|
+
value = var.custom_domain_name == null ? null : aws_apigatewayv2_domain_name.custom_domain[0].domain_name_configuration[0].target_domain_name
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
output "custom_domain_hosted_zone_id" {
|
|
805
|
+
description = "Hosted zone ID to use for a Route 53 alias record for the custom domain"
|
|
806
|
+
value = var.custom_domain_name == null ? null : aws_apigatewayv2_domain_name.custom_domain[0].domain_name_configuration[0].hosted_zone_id
|
|
807
|
+
}
|
|
808
|
+
|
|
747
809
|
output "stage_arn" {
|
|
748
810
|
description = "ARN of the API Gateway stage"
|
|
749
811
|
value = module.http_api.stage_arn
|
|
@@ -846,7 +908,7 @@ terraform {
|
|
|
846
908
|
required_providers {
|
|
847
909
|
aws = {
|
|
848
910
|
source = "hashicorp/aws"
|
|
849
|
-
version = "6.
|
|
911
|
+
version = "6.67.0"
|
|
850
912
|
}
|
|
851
913
|
}
|
|
852
914
|
}
|
|
@@ -1097,7 +1159,7 @@ output "api_log_group_arn" {
|
|
|
1097
1159
|
}
|
|
1098
1160
|
aws = {
|
|
1099
1161
|
source = "hashicorp/aws"
|
|
1100
|
-
version = "6.
|
|
1162
|
+
version = "6.67.0"
|
|
1101
1163
|
}
|
|
1102
1164
|
random = {
|
|
1103
1165
|
source = "hashicorp/random"
|
|
@@ -1202,6 +1264,19 @@ variable "tags" {
|
|
|
1202
1264
|
default = {}
|
|
1203
1265
|
}
|
|
1204
1266
|
|
|
1267
|
+
# Custom domain configuration
|
|
1268
|
+
variable "custom_domain_name" {
|
|
1269
|
+
description = "Custom domain name for the API. Requires acm_certificate_arn."
|
|
1270
|
+
type = string
|
|
1271
|
+
default = null
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
variable "acm_certificate_arn" {
|
|
1275
|
+
description = "ARN of an ACM certificate (in the API's region) for the custom domain name."
|
|
1276
|
+
type = string
|
|
1277
|
+
default = null
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1205
1280
|
# Get current AWS region and account ID
|
|
1206
1281
|
data "aws_region" "current" {}
|
|
1207
1282
|
data "aws_caller_identity" "current" {}
|
|
@@ -1453,6 +1528,10 @@ locals {
|
|
|
1453
1528
|
]
|
|
1454
1529
|
}
|
|
1455
1530
|
|
|
1531
|
+
locals {
|
|
1532
|
+
api_url = var.custom_domain_name == null ? module.http_api.stage_invoke_url : "https://\${var.custom_domain_name}/"
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1456
1535
|
# CloudWatch Log Group for Lambda
|
|
1457
1536
|
resource "aws_cloudwatch_log_group" "lambda_logs" {
|
|
1458
1537
|
#checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
|
|
@@ -1605,11 +1684,41 @@ module "add_url_to_runtime_config" {
|
|
|
1605
1684
|
|
|
1606
1685
|
namespace = "connection"
|
|
1607
1686
|
key = "apis"
|
|
1608
|
-
value = { "TestApi" =
|
|
1687
|
+
value = { "TestApi" = local.api_url }
|
|
1609
1688
|
|
|
1610
1689
|
depends_on = [module.http_api]
|
|
1611
1690
|
}
|
|
1612
1691
|
|
|
1692
|
+
# Custom domain for the API
|
|
1693
|
+
resource "aws_apigatewayv2_domain_name" "custom_domain" {
|
|
1694
|
+
count = var.custom_domain_name == null ? 0 : 1
|
|
1695
|
+
|
|
1696
|
+
domain_name = var.custom_domain_name
|
|
1697
|
+
|
|
1698
|
+
domain_name_configuration {
|
|
1699
|
+
certificate_arn = var.acm_certificate_arn
|
|
1700
|
+
endpoint_type = "REGIONAL"
|
|
1701
|
+
security_policy = "TLS_1_2"
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
tags = var.tags
|
|
1705
|
+
|
|
1706
|
+
lifecycle {
|
|
1707
|
+
precondition {
|
|
1708
|
+
condition = var.acm_certificate_arn != null
|
|
1709
|
+
error_message = "acm_certificate_arn is required when custom_domain_name is set."
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
resource "aws_apigatewayv2_api_mapping" "custom_domain" {
|
|
1715
|
+
count = var.custom_domain_name == null ? 0 : 1
|
|
1716
|
+
|
|
1717
|
+
api_id = module.http_api.api_id
|
|
1718
|
+
stage = module.http_api.stage_id
|
|
1719
|
+
domain_name = aws_apigatewayv2_domain_name.custom_domain[0].domain_name
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1613
1722
|
# Lambda permission for API Gateway to invoke the function via alias
|
|
1614
1723
|
resource "aws_lambda_permission" "api_gateway_invoke" {
|
|
1615
1724
|
for_each = local.operations
|
|
@@ -1652,6 +1761,21 @@ output "stage_invoke_url" {
|
|
|
1652
1761
|
value = module.http_api.stage_invoke_url
|
|
1653
1762
|
}
|
|
1654
1763
|
|
|
1764
|
+
output "api_url" {
|
|
1765
|
+
description = "URL clients should call: the custom domain if configured, otherwise the stage invoke URL"
|
|
1766
|
+
value = local.api_url
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
output "custom_domain_target_domain_name" {
|
|
1770
|
+
description = "Target domain name to point a DNS alias or CNAME record at for the custom domain"
|
|
1771
|
+
value = var.custom_domain_name == null ? null : aws_apigatewayv2_domain_name.custom_domain[0].domain_name_configuration[0].target_domain_name
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
output "custom_domain_hosted_zone_id" {
|
|
1775
|
+
description = "Hosted zone ID to use for a Route 53 alias record for the custom domain"
|
|
1776
|
+
value = var.custom_domain_name == null ? null : aws_apigatewayv2_domain_name.custom_domain[0].domain_name_configuration[0].hosted_zone_id
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1655
1779
|
output "stage_arn" {
|
|
1656
1780
|
description = "ARN of the API Gateway stage"
|
|
1657
1781
|
value = module.http_api.stage_arn
|
|
@@ -1754,7 +1878,7 @@ terraform {
|
|
|
1754
1878
|
required_providers {
|
|
1755
1879
|
aws = {
|
|
1756
1880
|
source = "hashicorp/aws"
|
|
1757
|
-
version = "6.
|
|
1881
|
+
version = "6.67.0"
|
|
1758
1882
|
}
|
|
1759
1883
|
}
|
|
1760
1884
|
}
|
|
@@ -2005,7 +2129,7 @@ output "api_log_group_arn" {
|
|
|
2005
2129
|
}
|
|
2006
2130
|
aws = {
|
|
2007
2131
|
source = "hashicorp/aws"
|
|
2008
|
-
version = "6.
|
|
2132
|
+
version = "6.67.0"
|
|
2009
2133
|
}
|
|
2010
2134
|
random = {
|
|
2011
2135
|
source = "hashicorp/random"
|
|
@@ -2110,6 +2234,19 @@ variable "tags" {
|
|
|
2110
2234
|
default = {}
|
|
2111
2235
|
}
|
|
2112
2236
|
|
|
2237
|
+
# Custom domain configuration
|
|
2238
|
+
variable "custom_domain_name" {
|
|
2239
|
+
description = "Custom domain name for the API. Requires acm_certificate_arn."
|
|
2240
|
+
type = string
|
|
2241
|
+
default = null
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
variable "acm_certificate_arn" {
|
|
2245
|
+
description = "ARN of an ACM certificate (in the API's region) for the custom domain name."
|
|
2246
|
+
type = string
|
|
2247
|
+
default = null
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2113
2250
|
# Get current AWS region and account ID
|
|
2114
2251
|
data "aws_region" "current" {}
|
|
2115
2252
|
data "aws_caller_identity" "current" {}
|
|
@@ -2361,6 +2498,10 @@ locals {
|
|
|
2361
2498
|
]
|
|
2362
2499
|
}
|
|
2363
2500
|
|
|
2501
|
+
locals {
|
|
2502
|
+
api_url = var.custom_domain_name == null ? module.http_api.stage_invoke_url : "https://\${var.custom_domain_name}/"
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2364
2505
|
# CloudWatch Log Group for Lambda
|
|
2365
2506
|
resource "aws_cloudwatch_log_group" "lambda_logs" {
|
|
2366
2507
|
#checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
|
|
@@ -2417,11 +2558,41 @@ module "add_url_to_runtime_config" {
|
|
|
2417
2558
|
|
|
2418
2559
|
namespace = "connection"
|
|
2419
2560
|
key = "apis"
|
|
2420
|
-
value = { "TestApi" =
|
|
2561
|
+
value = { "TestApi" = local.api_url }
|
|
2421
2562
|
|
|
2422
2563
|
depends_on = [module.http_api]
|
|
2423
2564
|
}
|
|
2424
2565
|
|
|
2566
|
+
# Custom domain for the API
|
|
2567
|
+
resource "aws_apigatewayv2_domain_name" "custom_domain" {
|
|
2568
|
+
count = var.custom_domain_name == null ? 0 : 1
|
|
2569
|
+
|
|
2570
|
+
domain_name = var.custom_domain_name
|
|
2571
|
+
|
|
2572
|
+
domain_name_configuration {
|
|
2573
|
+
certificate_arn = var.acm_certificate_arn
|
|
2574
|
+
endpoint_type = "REGIONAL"
|
|
2575
|
+
security_policy = "TLS_1_2"
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
tags = var.tags
|
|
2579
|
+
|
|
2580
|
+
lifecycle {
|
|
2581
|
+
precondition {
|
|
2582
|
+
condition = var.acm_certificate_arn != null
|
|
2583
|
+
error_message = "acm_certificate_arn is required when custom_domain_name is set."
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
resource "aws_apigatewayv2_api_mapping" "custom_domain" {
|
|
2589
|
+
count = var.custom_domain_name == null ? 0 : 1
|
|
2590
|
+
|
|
2591
|
+
api_id = module.http_api.api_id
|
|
2592
|
+
stage = module.http_api.stage_id
|
|
2593
|
+
domain_name = aws_apigatewayv2_domain_name.custom_domain[0].domain_name
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2425
2596
|
# Lambda permission for API Gateway to invoke the function via alias
|
|
2426
2597
|
resource "aws_lambda_permission" "api_gateway_invoke" {
|
|
2427
2598
|
for_each = local.operations
|
|
@@ -2464,6 +2635,21 @@ output "stage_invoke_url" {
|
|
|
2464
2635
|
value = module.http_api.stage_invoke_url
|
|
2465
2636
|
}
|
|
2466
2637
|
|
|
2638
|
+
output "api_url" {
|
|
2639
|
+
description = "URL clients should call: the custom domain if configured, otherwise the stage invoke URL"
|
|
2640
|
+
value = local.api_url
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
output "custom_domain_target_domain_name" {
|
|
2644
|
+
description = "Target domain name to point a DNS alias or CNAME record at for the custom domain"
|
|
2645
|
+
value = var.custom_domain_name == null ? null : aws_apigatewayv2_domain_name.custom_domain[0].domain_name_configuration[0].target_domain_name
|
|
2646
|
+
}
|
|
2647
|
+
|
|
2648
|
+
output "custom_domain_hosted_zone_id" {
|
|
2649
|
+
description = "Hosted zone ID to use for a Route 53 alias record for the custom domain"
|
|
2650
|
+
value = var.custom_domain_name == null ? null : aws_apigatewayv2_domain_name.custom_domain[0].domain_name_configuration[0].hosted_zone_id
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2467
2653
|
output "stage_arn" {
|
|
2468
2654
|
description = "ARN of the API Gateway stage"
|
|
2469
2655
|
value = module.http_api.stage_arn
|
|
@@ -2566,7 +2752,7 @@ terraform {
|
|
|
2566
2752
|
required_providers {
|
|
2567
2753
|
aws = {
|
|
2568
2754
|
source = "hashicorp/aws"
|
|
2569
|
-
version = "6.
|
|
2755
|
+
version = "6.67.0"
|
|
2570
2756
|
}
|
|
2571
2757
|
random = {
|
|
2572
2758
|
source = "hashicorp/random"
|
|
@@ -2879,7 +3065,7 @@ output "waf_web_acl_arn" {
|
|
|
2879
3065
|
}
|
|
2880
3066
|
aws = {
|
|
2881
3067
|
source = "hashicorp/aws"
|
|
2882
|
-
version = "6.
|
|
3068
|
+
version = "6.67.0"
|
|
2883
3069
|
}
|
|
2884
3070
|
random = {
|
|
2885
3071
|
source = "hashicorp/random"
|
|
@@ -2990,6 +3176,19 @@ variable "tags" {
|
|
|
2990
3176
|
default = {}
|
|
2991
3177
|
}
|
|
2992
3178
|
|
|
3179
|
+
# Custom domain configuration
|
|
3180
|
+
variable "custom_domain_name" {
|
|
3181
|
+
description = "Custom domain name for the API. Requires acm_certificate_arn."
|
|
3182
|
+
type = string
|
|
3183
|
+
default = null
|
|
3184
|
+
}
|
|
3185
|
+
|
|
3186
|
+
variable "acm_certificate_arn" {
|
|
3187
|
+
description = "ARN of an ACM certificate (in the API's region) for the custom domain name."
|
|
3188
|
+
type = string
|
|
3189
|
+
default = null
|
|
3190
|
+
}
|
|
3191
|
+
|
|
2993
3192
|
# Get current AWS region and account ID
|
|
2994
3193
|
data "aws_region" "current" {}
|
|
2995
3194
|
data "aws_caller_identity" "current" {}
|
|
@@ -3441,6 +3640,10 @@ locals {
|
|
|
3441
3640
|
]
|
|
3442
3641
|
}
|
|
3443
3642
|
|
|
3643
|
+
locals {
|
|
3644
|
+
api_url = var.custom_domain_name == null ? "\${aws_api_gateway_stage.api_stage.invoke_url}/" : "https://\${var.custom_domain_name}/"
|
|
3645
|
+
}
|
|
3646
|
+
|
|
3444
3647
|
# CloudWatch Log Group for Lambda
|
|
3445
3648
|
resource "aws_cloudwatch_log_group" "lambda_logs" {
|
|
3446
3649
|
#checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
|
|
@@ -3768,11 +3971,41 @@ module "add_url_to_runtime_config" {
|
|
|
3768
3971
|
|
|
3769
3972
|
namespace = "connection"
|
|
3770
3973
|
key = "apis"
|
|
3771
|
-
value = { "TestApi" =
|
|
3974
|
+
value = { "TestApi" = local.api_url }
|
|
3772
3975
|
|
|
3773
3976
|
depends_on = [aws_api_gateway_stage.api_stage]
|
|
3774
3977
|
}
|
|
3775
3978
|
|
|
3979
|
+
# Custom domain for the API, served without the stage path prefix
|
|
3980
|
+
resource "aws_api_gateway_domain_name" "custom_domain" {
|
|
3981
|
+
count = var.custom_domain_name == null ? 0 : 1
|
|
3982
|
+
|
|
3983
|
+
domain_name = var.custom_domain_name
|
|
3984
|
+
regional_certificate_arn = var.acm_certificate_arn
|
|
3985
|
+
security_policy = "TLS_1_2"
|
|
3986
|
+
|
|
3987
|
+
endpoint_configuration {
|
|
3988
|
+
types = ["REGIONAL"]
|
|
3989
|
+
}
|
|
3990
|
+
|
|
3991
|
+
tags = var.tags
|
|
3992
|
+
|
|
3993
|
+
lifecycle {
|
|
3994
|
+
precondition {
|
|
3995
|
+
condition = var.acm_certificate_arn != null
|
|
3996
|
+
error_message = "acm_certificate_arn is required when custom_domain_name is set."
|
|
3997
|
+
}
|
|
3998
|
+
}
|
|
3999
|
+
}
|
|
4000
|
+
|
|
4001
|
+
resource "aws_api_gateway_base_path_mapping" "custom_domain" {
|
|
4002
|
+
count = var.custom_domain_name == null ? 0 : 1
|
|
4003
|
+
|
|
4004
|
+
api_id = module.rest_api.api_id
|
|
4005
|
+
stage_name = aws_api_gateway_stage.api_stage.stage_name
|
|
4006
|
+
domain_name = aws_api_gateway_domain_name.custom_domain[0].domain_name
|
|
4007
|
+
}
|
|
4008
|
+
|
|
3776
4009
|
# Outputs
|
|
3777
4010
|
|
|
3778
4011
|
# API Gateway Outputs (from core module)
|
|
@@ -3801,6 +4034,21 @@ output "stage_invoke_url" {
|
|
|
3801
4034
|
value = aws_api_gateway_stage.api_stage.invoke_url
|
|
3802
4035
|
}
|
|
3803
4036
|
|
|
4037
|
+
output "api_url" {
|
|
4038
|
+
description = "URL clients should call: the custom domain if configured, otherwise the stage invoke URL"
|
|
4039
|
+
value = local.api_url
|
|
4040
|
+
}
|
|
4041
|
+
|
|
4042
|
+
output "custom_domain_target_domain_name" {
|
|
4043
|
+
description = "Target domain name to point a DNS alias or CNAME record at for the custom domain"
|
|
4044
|
+
value = var.custom_domain_name == null ? null : aws_api_gateway_domain_name.custom_domain[0].regional_domain_name
|
|
4045
|
+
}
|
|
4046
|
+
|
|
4047
|
+
output "custom_domain_hosted_zone_id" {
|
|
4048
|
+
description = "Hosted zone ID to use for a Route 53 alias record for the custom domain"
|
|
4049
|
+
value = var.custom_domain_name == null ? null : aws_api_gateway_domain_name.custom_domain[0].regional_zone_id
|
|
4050
|
+
}
|
|
4051
|
+
|
|
3804
4052
|
output "stage_arn" {
|
|
3805
4053
|
description = "ARN of the API Gateway stage"
|
|
3806
4054
|
value = aws_api_gateway_stage.api_stage.arn
|
|
@@ -3914,7 +4162,7 @@ terraform {
|
|
|
3914
4162
|
required_providers {
|
|
3915
4163
|
aws = {
|
|
3916
4164
|
source = "hashicorp/aws"
|
|
3917
|
-
version = "6.
|
|
4165
|
+
version = "6.67.0"
|
|
3918
4166
|
}
|
|
3919
4167
|
random = {
|
|
3920
4168
|
source = "hashicorp/random"
|
|
@@ -4227,7 +4475,7 @@ output "waf_web_acl_arn" {
|
|
|
4227
4475
|
}
|
|
4228
4476
|
aws = {
|
|
4229
4477
|
source = "hashicorp/aws"
|
|
4230
|
-
version = "6.
|
|
4478
|
+
version = "6.67.0"
|
|
4231
4479
|
}
|
|
4232
4480
|
random = {
|
|
4233
4481
|
source = "hashicorp/random"
|
|
@@ -4328,6 +4576,19 @@ variable "tags" {
|
|
|
4328
4576
|
default = {}
|
|
4329
4577
|
}
|
|
4330
4578
|
|
|
4579
|
+
# Custom domain configuration
|
|
4580
|
+
variable "custom_domain_name" {
|
|
4581
|
+
description = "Custom domain name for the API. Requires acm_certificate_arn."
|
|
4582
|
+
type = string
|
|
4583
|
+
default = null
|
|
4584
|
+
}
|
|
4585
|
+
|
|
4586
|
+
variable "acm_certificate_arn" {
|
|
4587
|
+
description = "ARN of an ACM certificate (in the API's region) for the custom domain name."
|
|
4588
|
+
type = string
|
|
4589
|
+
default = null
|
|
4590
|
+
}
|
|
4591
|
+
|
|
4331
4592
|
# Get current AWS region and account ID
|
|
4332
4593
|
data "aws_region" "current" {}
|
|
4333
4594
|
data "aws_caller_identity" "current" {}
|
|
@@ -4779,6 +5040,10 @@ locals {
|
|
|
4779
5040
|
]
|
|
4780
5041
|
}
|
|
4781
5042
|
|
|
5043
|
+
locals {
|
|
5044
|
+
api_url = var.custom_domain_name == null ? "\${aws_api_gateway_stage.api_stage.invoke_url}/" : "https://\${var.custom_domain_name}/"
|
|
5045
|
+
}
|
|
5046
|
+
|
|
4782
5047
|
# CloudWatch Log Group for Lambda
|
|
4783
5048
|
resource "aws_cloudwatch_log_group" "lambda_logs" {
|
|
4784
5049
|
#checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
|
|
@@ -5105,11 +5370,41 @@ module "add_url_to_runtime_config" {
|
|
|
5105
5370
|
|
|
5106
5371
|
namespace = "connection"
|
|
5107
5372
|
key = "apis"
|
|
5108
|
-
value = { "TestApi" =
|
|
5373
|
+
value = { "TestApi" = local.api_url }
|
|
5109
5374
|
|
|
5110
5375
|
depends_on = [aws_api_gateway_stage.api_stage]
|
|
5111
5376
|
}
|
|
5112
5377
|
|
|
5378
|
+
# Custom domain for the API, served without the stage path prefix
|
|
5379
|
+
resource "aws_api_gateway_domain_name" "custom_domain" {
|
|
5380
|
+
count = var.custom_domain_name == null ? 0 : 1
|
|
5381
|
+
|
|
5382
|
+
domain_name = var.custom_domain_name
|
|
5383
|
+
regional_certificate_arn = var.acm_certificate_arn
|
|
5384
|
+
security_policy = "TLS_1_2"
|
|
5385
|
+
|
|
5386
|
+
endpoint_configuration {
|
|
5387
|
+
types = ["REGIONAL"]
|
|
5388
|
+
}
|
|
5389
|
+
|
|
5390
|
+
tags = var.tags
|
|
5391
|
+
|
|
5392
|
+
lifecycle {
|
|
5393
|
+
precondition {
|
|
5394
|
+
condition = var.acm_certificate_arn != null
|
|
5395
|
+
error_message = "acm_certificate_arn is required when custom_domain_name is set."
|
|
5396
|
+
}
|
|
5397
|
+
}
|
|
5398
|
+
}
|
|
5399
|
+
|
|
5400
|
+
resource "aws_api_gateway_base_path_mapping" "custom_domain" {
|
|
5401
|
+
count = var.custom_domain_name == null ? 0 : 1
|
|
5402
|
+
|
|
5403
|
+
api_id = module.rest_api.api_id
|
|
5404
|
+
stage_name = aws_api_gateway_stage.api_stage.stage_name
|
|
5405
|
+
domain_name = aws_api_gateway_domain_name.custom_domain[0].domain_name
|
|
5406
|
+
}
|
|
5407
|
+
|
|
5113
5408
|
# Outputs
|
|
5114
5409
|
|
|
5115
5410
|
# API Gateway Outputs (from core module)
|
|
@@ -5138,6 +5433,21 @@ output "stage_invoke_url" {
|
|
|
5138
5433
|
value = aws_api_gateway_stage.api_stage.invoke_url
|
|
5139
5434
|
}
|
|
5140
5435
|
|
|
5436
|
+
output "api_url" {
|
|
5437
|
+
description = "URL clients should call: the custom domain if configured, otherwise the stage invoke URL"
|
|
5438
|
+
value = local.api_url
|
|
5439
|
+
}
|
|
5440
|
+
|
|
5441
|
+
output "custom_domain_target_domain_name" {
|
|
5442
|
+
description = "Target domain name to point a DNS alias or CNAME record at for the custom domain"
|
|
5443
|
+
value = var.custom_domain_name == null ? null : aws_api_gateway_domain_name.custom_domain[0].regional_domain_name
|
|
5444
|
+
}
|
|
5445
|
+
|
|
5446
|
+
output "custom_domain_hosted_zone_id" {
|
|
5447
|
+
description = "Hosted zone ID to use for a Route 53 alias record for the custom domain"
|
|
5448
|
+
value = var.custom_domain_name == null ? null : aws_api_gateway_domain_name.custom_domain[0].regional_zone_id
|
|
5449
|
+
}
|
|
5450
|
+
|
|
5141
5451
|
output "stage_arn" {
|
|
5142
5452
|
description = "ARN of the API Gateway stage"
|
|
5143
5453
|
value = aws_api_gateway_stage.api_stage.arn
|
|
@@ -5251,7 +5561,7 @@ terraform {
|
|
|
5251
5561
|
required_providers {
|
|
5252
5562
|
aws = {
|
|
5253
5563
|
source = "hashicorp/aws"
|
|
5254
|
-
version = "6.
|
|
5564
|
+
version = "6.67.0"
|
|
5255
5565
|
}
|
|
5256
5566
|
random = {
|
|
5257
5567
|
source = "hashicorp/random"
|
|
@@ -5564,7 +5874,7 @@ output "waf_web_acl_arn" {
|
|
|
5564
5874
|
}
|
|
5565
5875
|
aws = {
|
|
5566
5876
|
source = "hashicorp/aws"
|
|
5567
|
-
version = "6.
|
|
5877
|
+
version = "6.67.0"
|
|
5568
5878
|
}
|
|
5569
5879
|
random = {
|
|
5570
5880
|
source = "hashicorp/random"
|
|
@@ -5665,6 +5975,19 @@ variable "tags" {
|
|
|
5665
5975
|
default = {}
|
|
5666
5976
|
}
|
|
5667
5977
|
|
|
5978
|
+
# Custom domain configuration
|
|
5979
|
+
variable "custom_domain_name" {
|
|
5980
|
+
description = "Custom domain name for the API. Requires acm_certificate_arn."
|
|
5981
|
+
type = string
|
|
5982
|
+
default = null
|
|
5983
|
+
}
|
|
5984
|
+
|
|
5985
|
+
variable "acm_certificate_arn" {
|
|
5986
|
+
description = "ARN of an ACM certificate (in the API's region) for the custom domain name."
|
|
5987
|
+
type = string
|
|
5988
|
+
default = null
|
|
5989
|
+
}
|
|
5990
|
+
|
|
5668
5991
|
# Get current AWS region and account ID
|
|
5669
5992
|
data "aws_region" "current" {}
|
|
5670
5993
|
data "aws_caller_identity" "current" {}
|
|
@@ -6116,6 +6439,10 @@ locals {
|
|
|
6116
6439
|
]
|
|
6117
6440
|
}
|
|
6118
6441
|
|
|
6442
|
+
locals {
|
|
6443
|
+
api_url = var.custom_domain_name == null ? "\${aws_api_gateway_stage.api_stage.invoke_url}/" : "https://\${var.custom_domain_name}/"
|
|
6444
|
+
}
|
|
6445
|
+
|
|
6119
6446
|
# CloudWatch Log Group for Lambda
|
|
6120
6447
|
resource "aws_cloudwatch_log_group" "lambda_logs" {
|
|
6121
6448
|
#checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
|
|
@@ -6525,11 +6852,41 @@ module "add_url_to_runtime_config" {
|
|
|
6525
6852
|
|
|
6526
6853
|
namespace = "connection"
|
|
6527
6854
|
key = "apis"
|
|
6528
|
-
value = { "TestApi" =
|
|
6855
|
+
value = { "TestApi" = local.api_url }
|
|
6529
6856
|
|
|
6530
6857
|
depends_on = [aws_api_gateway_stage.api_stage]
|
|
6531
6858
|
}
|
|
6532
6859
|
|
|
6860
|
+
# Custom domain for the API, served without the stage path prefix
|
|
6861
|
+
resource "aws_api_gateway_domain_name" "custom_domain" {
|
|
6862
|
+
count = var.custom_domain_name == null ? 0 : 1
|
|
6863
|
+
|
|
6864
|
+
domain_name = var.custom_domain_name
|
|
6865
|
+
regional_certificate_arn = var.acm_certificate_arn
|
|
6866
|
+
security_policy = "TLS_1_2"
|
|
6867
|
+
|
|
6868
|
+
endpoint_configuration {
|
|
6869
|
+
types = ["REGIONAL"]
|
|
6870
|
+
}
|
|
6871
|
+
|
|
6872
|
+
tags = var.tags
|
|
6873
|
+
|
|
6874
|
+
lifecycle {
|
|
6875
|
+
precondition {
|
|
6876
|
+
condition = var.acm_certificate_arn != null
|
|
6877
|
+
error_message = "acm_certificate_arn is required when custom_domain_name is set."
|
|
6878
|
+
}
|
|
6879
|
+
}
|
|
6880
|
+
}
|
|
6881
|
+
|
|
6882
|
+
resource "aws_api_gateway_base_path_mapping" "custom_domain" {
|
|
6883
|
+
count = var.custom_domain_name == null ? 0 : 1
|
|
6884
|
+
|
|
6885
|
+
api_id = module.rest_api.api_id
|
|
6886
|
+
stage_name = aws_api_gateway_stage.api_stage.stage_name
|
|
6887
|
+
domain_name = aws_api_gateway_domain_name.custom_domain[0].domain_name
|
|
6888
|
+
}
|
|
6889
|
+
|
|
6533
6890
|
# Outputs
|
|
6534
6891
|
|
|
6535
6892
|
# API Gateway Outputs (from core module)
|
|
@@ -6558,6 +6915,21 @@ output "stage_invoke_url" {
|
|
|
6558
6915
|
value = aws_api_gateway_stage.api_stage.invoke_url
|
|
6559
6916
|
}
|
|
6560
6917
|
|
|
6918
|
+
output "api_url" {
|
|
6919
|
+
description = "URL clients should call: the custom domain if configured, otherwise the stage invoke URL"
|
|
6920
|
+
value = local.api_url
|
|
6921
|
+
}
|
|
6922
|
+
|
|
6923
|
+
output "custom_domain_target_domain_name" {
|
|
6924
|
+
description = "Target domain name to point a DNS alias or CNAME record at for the custom domain"
|
|
6925
|
+
value = var.custom_domain_name == null ? null : aws_api_gateway_domain_name.custom_domain[0].regional_domain_name
|
|
6926
|
+
}
|
|
6927
|
+
|
|
6928
|
+
output "custom_domain_hosted_zone_id" {
|
|
6929
|
+
description = "Hosted zone ID to use for a Route 53 alias record for the custom domain"
|
|
6930
|
+
value = var.custom_domain_name == null ? null : aws_api_gateway_domain_name.custom_domain[0].regional_zone_id
|
|
6931
|
+
}
|
|
6932
|
+
|
|
6561
6933
|
output "stage_arn" {
|
|
6562
6934
|
description = "ARN of the API Gateway stage"
|
|
6563
6935
|
value = aws_api_gateway_stage.api_stage.arn
|
|
@@ -71,7 +71,7 @@ exports[`lambda-handler project generator > terraform iac > should generate terr
|
|
|
71
71
|
required_providers {
|
|
72
72
|
aws = {
|
|
73
73
|
source = "hashicorp/aws"
|
|
74
|
-
version = "6.
|
|
74
|
+
version = "6.67.0"
|
|
75
75
|
}
|
|
76
76
|
archive = {
|
|
77
77
|
source = "hashicorp/archive"
|
|
@@ -256,7 +256,7 @@ exports[`lambda-handler project generator > terraform iac > should match snapsho
|
|
|
256
256
|
required_providers {
|
|
257
257
|
aws = {
|
|
258
258
|
source = "hashicorp/aws"
|
|
259
|
-
version = "6.
|
|
259
|
+
version = "6.67.0"
|
|
260
260
|
}
|
|
261
261
|
archive = {
|
|
262
262
|
source = "hashicorp/archive"
|