diff --git a/samtranslator/__init__.py b/samtranslator/__init__.py index 6df86cae3..eb9596372 100644 --- a/samtranslator/__init__.py +++ b/samtranslator/__init__.py @@ -1 +1 @@ -__version__ = "1.21.0" +__version__ = "1.22.0" diff --git a/samtranslator/model/api/http_api_generator.py b/samtranslator/model/api/http_api_generator.py index 15c843ce5..1943663ff 100644 --- a/samtranslator/model/api/http_api_generator.py +++ b/samtranslator/model/api/http_api_generator.py @@ -204,10 +204,9 @@ def _construct_api_domain(self, http_api): endpoint = "REGIONAL" # to make sure that default is always REGIONAL self.domain["EndpointConfiguration"] = "REGIONAL" - elif endpoint not in ["EDGE", "REGIONAL"]: + elif endpoint not in ["REGIONAL"]: raise InvalidResourceException( - self.logical_id, - "EndpointConfiguration for Custom Domains must be one of {}.".format(["EDGE", "REGIONAL"]), + self.logical_id, "EndpointConfiguration for Custom Domains must be one of {}.".format(["REGIONAL"]), ) domain_config["EndpointType"] = endpoint domain_config["CertificateArn"] = self.domain.get("CertificateArn") @@ -312,10 +311,9 @@ def _construct_alias_target(self, domain): alias_target["HostedZoneId"] = fnGetAtt(self.domain.get("ApiDomainName"), "RegionalHostedZoneId") alias_target["DNSName"] = fnGetAtt(self.domain.get("ApiDomainName"), "RegionalDomainName") else: - if route53.get("DistributionDomainName") is None: - route53["DistributionDomainName"] = fnGetAtt(self.domain.get("ApiDomainName"), "DistributionDomainName") - alias_target["HostedZoneId"] = "Z2FDTNDATAQYW2" - alias_target["DNSName"] = route53.get("DistributionDomainName") + raise InvalidResourceException( + self.logical_id, "Only REGIONAL endpoint is supported on HTTP APIs.", + ) return alias_target def _add_auth(self): diff --git a/tests/model/api/test_http_api_generator.py b/tests/model/api/test_http_api_generator.py index e1d01070a..c9656d050 100644 --- a/tests/model/api/test_http_api_generator.py +++ b/tests/model/api/test_http_api_generator.py @@ -120,7 +120,7 @@ def test_no_domain_name(self): http_api = HttpApiGenerator(**self.kwargs)._construct_http_api() with pytest.raises(InvalidResourceException) as e: HttpApiGenerator(**self.kwargs)._construct_api_domain(http_api) - self.assertEquals( + self.assertEqual( e.value.message, "Resource with id [HttpApiId] is invalid. " + "Custom Domains only works if both DomainName and CertificateArn are provided.", @@ -131,7 +131,7 @@ def test_no_cert_arn(self): http_api = HttpApiGenerator(**self.kwargs)._construct_http_api() with pytest.raises(InvalidResourceException) as e: HttpApiGenerator(**self.kwargs)._construct_api_domain(http_api) - self.assertEquals( + self.assertEqual( e.value.message, "Resource with id [HttpApiId] is invalid. " + "Custom Domains only works if both DomainName and CertificateArn are provided.", @@ -145,7 +145,7 @@ def test_basic_domain_default_endpoint(self): self.assertIsNotNone(basepath, None) self.assertEqual(len(basepath), 1) self.assertIsNone(route, None) - self.assertEquals(domain.DomainNameConfigurations[0].get("EndpointType"), "REGIONAL") + self.assertEqual(domain.DomainNameConfigurations[0].get("EndpointType"), "REGIONAL") def test_basic_domain_regional_endpoint(self): self.kwargs["domain"] = { @@ -159,7 +159,7 @@ def test_basic_domain_regional_endpoint(self): self.assertIsNotNone(basepath, None) self.assertEqual(len(basepath), 1) self.assertIsNone(route, None) - self.assertEquals(domain.DomainNameConfigurations[0].get("EndpointType"), "REGIONAL") + self.assertEqual(domain.DomainNameConfigurations[0].get("EndpointType"), "REGIONAL") def test_basic_domain_edge_endpoint(self): self.kwargs["domain"] = { @@ -168,12 +168,12 @@ def test_basic_domain_edge_endpoint(self): "EndpointConfiguration": "EDGE", } http_api = HttpApiGenerator(**self.kwargs)._construct_http_api() - domain, basepath, route = HttpApiGenerator(**self.kwargs)._construct_api_domain(http_api) - self.assertIsNotNone(domain, None) - self.assertIsNotNone(basepath, None) - self.assertEqual(len(basepath), 1) - self.assertIsNone(route, None) - self.assertEquals(domain.DomainNameConfigurations[0].get("EndpointType"), "EDGE") + with pytest.raises(InvalidResourceException) as e: + HttpApiGenerator(**self.kwargs)._construct_api_domain(http_api) + self.assertEqual( + e.value.message, + "Resource with id [HttpApiId] is invalid. EndpointConfiguration for Custom Domains must be one of ['REGIONAL'].", + ) def test_bad_endpoint(self): self.kwargs["domain"] = { @@ -184,10 +184,10 @@ def test_bad_endpoint(self): http_api = HttpApiGenerator(**self.kwargs)._construct_http_api() with pytest.raises(InvalidResourceException) as e: HttpApiGenerator(**self.kwargs)._construct_api_domain(http_api) - self.assertEquals( + self.assertEqual( e.value.message, "Resource with id [HttpApiId] is invalid. " - + "EndpointConfiguration for Custom Domains must be one of ['EDGE', 'REGIONAL'].", + + "EndpointConfiguration for Custom Domains must be one of ['REGIONAL'].", ) def test_basic_route53(self): @@ -202,7 +202,7 @@ def test_basic_route53(self): self.assertIsNotNone(basepath, None) self.assertEqual(len(basepath), 1) self.assertIsNotNone(route, None) - self.assertEquals(domain.DomainNameConfigurations[0].get("EndpointType"), "REGIONAL") + self.assertEqual(domain.DomainNameConfigurations[0].get("EndpointType"), "REGIONAL") def test_basepaths(self): self.kwargs["domain"] = { @@ -217,7 +217,7 @@ def test_basepaths(self): self.assertIsNotNone(basepath, None) self.assertEqual(len(basepath), 3) self.assertIsNotNone(route, None) - self.assertEquals(domain.DomainNameConfigurations[0].get("EndpointType"), "REGIONAL") + self.assertEqual(domain.DomainNameConfigurations[0].get("EndpointType"), "REGIONAL") def test_invalid_basepaths(self): self.kwargs["domain"] = { @@ -229,7 +229,7 @@ def test_invalid_basepaths(self): http_api = HttpApiGenerator(**self.kwargs)._construct_http_api() with pytest.raises(InvalidResourceException) as e: HttpApiGenerator(**self.kwargs)._construct_api_domain(http_api) - self.assertEquals( + self.assertEqual( e.value.message, "Resource with id [HttpApiId] is invalid. " + "Invalid Basepath name provided." ) @@ -246,6 +246,6 @@ def test_basepaths(self): self.assertIsNotNone(basepath, None) self.assertEqual(len(basepath), 3) self.assertIsNotNone(route, None) - self.assertEquals(route.HostedZoneName, None) - self.assertEquals(route.HostedZoneId, "xyz") - self.assertEquals(len(route.RecordSets), 2) + self.assertEqual(route.HostedZoneName, None) + self.assertEqual(route.HostedZoneId, "xyz") + self.assertEqual(len(route.RecordSets), 2) diff --git a/tests/translator/input/api_with_basic_custom_domain_http.yaml b/tests/translator/input/api_with_basic_custom_domain_http.yaml index 009190a19..e9a0c5f8a 100644 --- a/tests/translator/input/api_with_basic_custom_domain_http.yaml +++ b/tests/translator/input/api_with_basic_custom_domain_http.yaml @@ -1,11 +1,11 @@ Parameters: MyDomainName: Type: String - Default: sam-v2-regional-test.com + Default: sam-example.com MyDomainCert: Type: String - Default: arn:aws:acm:us-east-1:551213647843:certificate/6c911401-620d-4d41-b89e-366c238bb2f3 + Default: arn:aws:acm:us-east-1:123455353535:certificate/6c911401-620d-4d41-b89e-366c238bb2f3 Globals: HttpApi: @@ -15,7 +15,7 @@ Globals: EndpointConfiguration: REGIONAL BasePath: ["/basic", "/begin-here"] Route53: - HostedZoneName: sam-v2-regional-test.com. + HostedZoneName: sam-example.com. Resources: diff --git a/tests/translator/input/api_with_custom_domain_route53_hosted_zone_name_http.yaml b/tests/translator/input/api_with_custom_domain_route53_hosted_zone_name_http.yaml index f7de53992..9fbc632a8 100644 --- a/tests/translator/input/api_with_custom_domain_route53_hosted_zone_name_http.yaml +++ b/tests/translator/input/api_with_custom_domain_route53_hosted_zone_name_http.yaml @@ -10,7 +10,6 @@ Globals: Domain: DomainName: !Ref DomainName CertificateArn: !Ref ACMCertificateArn - EndpointConfiguration: EDGE BasePath: - /one Route53: diff --git a/tests/translator/input/api_with_custom_domain_route53_http.yaml b/tests/translator/input/api_with_custom_domain_route53_http.yaml index 87c84c543..f3e91b05d 100644 --- a/tests/translator/input/api_with_custom_domain_route53_http.yaml +++ b/tests/translator/input/api_with_custom_domain_route53_http.yaml @@ -34,7 +34,6 @@ Resources: Domain: DomainName: !Ref DomainName CertificateArn: !Ref ACMCertificateArn - EndpointConfiguration: EDGE BasePath: - /one Route53: diff --git a/tests/translator/output/api_with_basic_custom_domain_http.json b/tests/translator/output/api_with_basic_custom_domain_http.json index 7bf4fefba..94d8020a6 100644 --- a/tests/translator/output/api_with_basic_custom_domain_http.json +++ b/tests/translator/output/api_with_basic_custom_domain_http.json @@ -1,11 +1,11 @@ { "Parameters": { "MyDomainName": { - "Default": "sam-v2-regional-test.com", + "Default": "sam-example.com", "Type": "String" }, "MyDomainCert": { - "Default": "arn:aws:acm:us-east-1:551213647843:certificate/6c911401-620d-4d41-b89e-366c238bb2f3", + "Default": "arn:aws:acm:us-east-1:123455353535:certificate/6c911401-620d-4d41-b89e-366c238bb2f3", "Type": "String" } }, @@ -17,7 +17,7 @@ "Ref": "MyApi" }, "DomainName": { - "Ref": "ApiGatewayDomainNameV2ab8e63947d" + "Ref": "ApiGatewayDomainNameV22dbf35af54" }, "ApiMappingKey": "basic", "Stage": { @@ -25,6 +25,21 @@ } } }, + "ApiGatewayDomainNameV22dbf35af54": { + "Type": "AWS::ApiGatewayV2::DomainName", + "Properties": { + "DomainName": "sam-example.com", + "DomainNameConfigurations": [ + { + "CertificateArn": "arn:aws:acm:us-east-1:123455353535:certificate/6c911401-620d-4d41-b89e-366c238bb2f3", + "EndpointType": "REGIONAL" + } + ], + "Tags": { + "httpapi:createdBy": "SAM" + } + } + }, "MyApiProdStage": { "Type": "AWS::ApiGatewayV2::Stage", "Properties": { @@ -88,7 +103,7 @@ "Ref": "MyApi" }, "DomainName": { - "Ref": "ApiGatewayDomainNameV2ab8e63947d" + "Ref": "ApiGatewayDomainNameV22dbf35af54" }, "ApiMappingKey": "begin-here", "Stage": { @@ -96,32 +111,6 @@ } } }, - "RecordSetGroup9616db1511": { - "Type": "AWS::Route53::RecordSetGroup", - "Properties": { - "HostedZoneName": "sam-v2-regional-test.com.", - "RecordSets": [ - { - "AliasTarget": { - "HostedZoneId": { - "Fn::GetAtt": [ - "ApiGatewayDomainNameV2ab8e63947d", - "RegionalHostedZoneId" - ] - }, - "DNSName": { - "Fn::GetAtt": [ - "ApiGatewayDomainNameV2ab8e63947d", - "RegionalDomainName" - ] - } - }, - "Type": "A", - "Name": "sam-v2-regional-test.com" - } - ] - } - }, "HttpApiFunctionRole": { "Type": "AWS::IAM::Role", "Properties": { @@ -152,19 +141,30 @@ ] } }, - "ApiGatewayDomainNameV2ab8e63947d": { - "Type": "AWS::ApiGatewayV2::DomainName", + "RecordSetGroup1f4f569a7e": { + "Type": "AWS::Route53::RecordSetGroup", "Properties": { - "DomainNameConfigurations": [ + "HostedZoneName": "sam-example.com.", + "RecordSets": [ { - "CertificateArn": "arn:aws:acm:us-east-1:551213647843:certificate/6c911401-620d-4d41-b89e-366c238bb2f3", - "EndpointType": "REGIONAL" + "AliasTarget": { + "HostedZoneId": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameV22dbf35af54", + "RegionalHostedZoneId" + ] + }, + "DNSName": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameV22dbf35af54", + "RegionalDomainName" + ] + } + }, + "Type": "A", + "Name": "sam-example.com" } - ], - "DomainName": "sam-v2-regional-test.com", - "Tags": { - "httpapi:createdBy": "SAM" - } + ] } }, "MyApi": { diff --git a/tests/translator/output/api_with_custom_domain_route53_hosted_zone_name_http.json b/tests/translator/output/api_with_custom_domain_route53_hosted_zone_name_http.json index d3351418d..29e0c651e 100644 --- a/tests/translator/output/api_with_custom_domain_route53_hosted_zone_name_http.json +++ b/tests/translator/output/api_with_custom_domain_route53_hosted_zone_name_http.json @@ -67,7 +67,7 @@ "DomainNameConfigurations": [ { "CertificateArn": "cert-arn-in-us-east-1", - "EndpointType": "EDGE" + "EndpointType": "REGIONAL" } ], "Tags": { @@ -82,11 +82,16 @@ "RecordSets": [ { "AliasTarget": { - "HostedZoneId": "Z2FDTNDATAQYW2", + "HostedZoneId": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameV20caaf24ab1", + "RegionalHostedZoneId" + ] + }, "DNSName": { "Fn::GetAtt": [ "ApiGatewayDomainNameV20caaf24ab1", - "DistributionDomainName" + "RegionalDomainName" ] } }, diff --git a/tests/translator/output/api_with_custom_domain_route53_http.json b/tests/translator/output/api_with_custom_domain_route53_http.json index 92bb463f5..f2b054715 100644 --- a/tests/translator/output/api_with_custom_domain_route53_http.json +++ b/tests/translator/output/api_with_custom_domain_route53_http.json @@ -54,11 +54,16 @@ "RecordSets": [ { "AliasTarget": { - "HostedZoneId": "Z2FDTNDATAQYW2", + "HostedZoneId": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameV20caaf24ab1", + "RegionalHostedZoneId" + ] + }, "DNSName": { "Fn::GetAtt": [ "ApiGatewayDomainNameV20caaf24ab1", - "DistributionDomainName" + "RegionalDomainName" ] } }, @@ -67,11 +72,16 @@ }, { "AliasTarget": { - "HostedZoneId": "Z2FDTNDATAQYW2", + "HostedZoneId": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameV20caaf24ab1", + "RegionalHostedZoneId" + ] + }, "DNSName": { "Fn::GetAtt": [ "ApiGatewayDomainNameV20caaf24ab1", - "DistributionDomainName" + "RegionalDomainName" ] } }, @@ -88,7 +98,7 @@ "DomainNameConfigurations": [ { "CertificateArn": "cert-arn-in-us-east-1", - "EndpointType": "EDGE" + "EndpointType": "REGIONAL" } ], "Tags": { diff --git a/tests/translator/output/aws-cn/api_with_basic_custom_domain_http.json b/tests/translator/output/aws-cn/api_with_basic_custom_domain_http.json index 64561b3b6..6309cf1ef 100644 --- a/tests/translator/output/aws-cn/api_with_basic_custom_domain_http.json +++ b/tests/translator/output/aws-cn/api_with_basic_custom_domain_http.json @@ -1,11 +1,11 @@ { "Parameters": { "MyDomainName": { - "Default": "sam-v2-regional-test.com", + "Default": "sam-example.com", "Type": "String" }, "MyDomainCert": { - "Default": "arn:aws:acm:us-east-1:551213647843:certificate/6c911401-620d-4d41-b89e-366c238bb2f3", + "Default": "arn:aws:acm:us-east-1:123455353535:certificate/6c911401-620d-4d41-b89e-366c238bb2f3", "Type": "String" } }, @@ -17,7 +17,7 @@ "Ref": "MyApi" }, "DomainName": { - "Ref": "ApiGatewayDomainNameV2ab8e63947d" + "Ref": "ApiGatewayDomainNameV22dbf35af54" }, "ApiMappingKey": "basic", "Stage": { @@ -25,6 +25,21 @@ } } }, + "ApiGatewayDomainNameV22dbf35af54": { + "Type": "AWS::ApiGatewayV2::DomainName", + "Properties": { + "DomainName": "sam-example.com", + "DomainNameConfigurations": [ + { + "CertificateArn": "arn:aws:acm:us-east-1:123455353535:certificate/6c911401-620d-4d41-b89e-366c238bb2f3", + "EndpointType": "REGIONAL" + } + ], + "Tags": { + "httpapi:createdBy": "SAM" + } + } + }, "MyApiProdStage": { "Type": "AWS::ApiGatewayV2::Stage", "Properties": { @@ -88,7 +103,7 @@ "Ref": "MyApi" }, "DomainName": { - "Ref": "ApiGatewayDomainNameV2ab8e63947d" + "Ref": "ApiGatewayDomainNameV22dbf35af54" }, "ApiMappingKey": "begin-here", "Stage": { @@ -96,32 +111,6 @@ } } }, - "RecordSetGroup9616db1511": { - "Type": "AWS::Route53::RecordSetGroup", - "Properties": { - "HostedZoneName": "sam-v2-regional-test.com.", - "RecordSets": [ - { - "AliasTarget": { - "HostedZoneId": { - "Fn::GetAtt": [ - "ApiGatewayDomainNameV2ab8e63947d", - "RegionalHostedZoneId" - ] - }, - "DNSName": { - "Fn::GetAtt": [ - "ApiGatewayDomainNameV2ab8e63947d", - "RegionalDomainName" - ] - } - }, - "Type": "A", - "Name": "sam-v2-regional-test.com" - } - ] - } - }, "HttpApiFunctionRole": { "Type": "AWS::IAM::Role", "Properties": { @@ -152,19 +141,30 @@ ] } }, - "ApiGatewayDomainNameV2ab8e63947d": { - "Type": "AWS::ApiGatewayV2::DomainName", + "RecordSetGroup1f4f569a7e": { + "Type": "AWS::Route53::RecordSetGroup", "Properties": { - "DomainName": "sam-v2-regional-test.com", - "DomainNameConfigurations": [ + "HostedZoneName": "sam-example.com.", + "RecordSets": [ { - "CertificateArn": "arn:aws:acm:us-east-1:551213647843:certificate/6c911401-620d-4d41-b89e-366c238bb2f3", - "EndpointType": "REGIONAL" + "AliasTarget": { + "HostedZoneId": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameV22dbf35af54", + "RegionalHostedZoneId" + ] + }, + "DNSName": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameV22dbf35af54", + "RegionalDomainName" + ] + } + }, + "Type": "A", + "Name": "sam-example.com" } - ], - "Tags": { - "httpapi:createdBy": "SAM" - } + ] } }, "MyApi": { diff --git a/tests/translator/output/aws-cn/api_with_custom_domain_route53_hosted_zone_name_http.json b/tests/translator/output/aws-cn/api_with_custom_domain_route53_hosted_zone_name_http.json index f614884a8..1fb95eaf7 100644 --- a/tests/translator/output/aws-cn/api_with_custom_domain_route53_hosted_zone_name_http.json +++ b/tests/translator/output/aws-cn/api_with_custom_domain_route53_hosted_zone_name_http.json @@ -63,13 +63,13 @@ "ApiGatewayDomainNameV20caaf24ab1": { "Type": "AWS::ApiGatewayV2::DomainName", "Properties": { + "DomainName": "example.com", "DomainNameConfigurations": [ { "CertificateArn": "cert-arn-in-us-east-1", - "EndpointType": "EDGE" + "EndpointType": "REGIONAL" } ], - "DomainName": "example.com", "Tags": { "httpapi:createdBy": "SAM" } @@ -82,11 +82,16 @@ "RecordSets": [ { "AliasTarget": { - "HostedZoneId": "Z2FDTNDATAQYW2", + "HostedZoneId": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameV20caaf24ab1", + "RegionalHostedZoneId" + ] + }, "DNSName": { "Fn::GetAtt": [ "ApiGatewayDomainNameV20caaf24ab1", - "DistributionDomainName" + "RegionalDomainName" ] } }, diff --git a/tests/translator/output/aws-cn/api_with_custom_domain_route53_http.json b/tests/translator/output/aws-cn/api_with_custom_domain_route53_http.json index f4067c80b..31c6a71d5 100644 --- a/tests/translator/output/aws-cn/api_with_custom_domain_route53_http.json +++ b/tests/translator/output/aws-cn/api_with_custom_domain_route53_http.json @@ -54,11 +54,16 @@ "RecordSets": [ { "AliasTarget": { - "HostedZoneId": "Z2FDTNDATAQYW2", + "HostedZoneId": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameV20caaf24ab1", + "RegionalHostedZoneId" + ] + }, "DNSName": { "Fn::GetAtt": [ "ApiGatewayDomainNameV20caaf24ab1", - "DistributionDomainName" + "RegionalDomainName" ] } }, @@ -67,11 +72,16 @@ }, { "AliasTarget": { - "HostedZoneId": "Z2FDTNDATAQYW2", + "HostedZoneId": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameV20caaf24ab1", + "RegionalHostedZoneId" + ] + }, "DNSName": { "Fn::GetAtt": [ "ApiGatewayDomainNameV20caaf24ab1", - "DistributionDomainName" + "RegionalDomainName" ] } }, @@ -88,7 +98,7 @@ "DomainNameConfigurations": [ { "CertificateArn": "cert-arn-in-us-east-1", - "EndpointType": "EDGE" + "EndpointType": "REGIONAL" } ], "Tags": { diff --git a/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_http.json b/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_http.json index 691caa2fa..4712f95fb 100644 --- a/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_http.json +++ b/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_http.json @@ -1,11 +1,11 @@ { "Parameters": { "MyDomainName": { - "Default": "sam-v2-regional-test.com", + "Default": "sam-example.com", "Type": "String" }, "MyDomainCert": { - "Default": "arn:aws:acm:us-east-1:551213647843:certificate/6c911401-620d-4d41-b89e-366c238bb2f3", + "Default": "arn:aws:acm:us-east-1:123455353535:certificate/6c911401-620d-4d41-b89e-366c238bb2f3", "Type": "String" } }, @@ -17,7 +17,7 @@ "Ref": "MyApi" }, "DomainName": { - "Ref": "ApiGatewayDomainNameV2ab8e63947d" + "Ref": "ApiGatewayDomainNameV22dbf35af54" }, "ApiMappingKey": "basic", "Stage": { @@ -25,6 +25,21 @@ } } }, + "ApiGatewayDomainNameV22dbf35af54": { + "Type": "AWS::ApiGatewayV2::DomainName", + "Properties": { + "DomainName": "sam-example.com", + "DomainNameConfigurations": [ + { + "CertificateArn": "arn:aws:acm:us-east-1:123455353535:certificate/6c911401-620d-4d41-b89e-366c238bb2f3", + "EndpointType": "REGIONAL" + } + ], + "Tags": { + "httpapi:createdBy": "SAM" + } + } + }, "MyApiProdStage": { "Type": "AWS::ApiGatewayV2::Stage", "Properties": { @@ -88,7 +103,7 @@ "Ref": "MyApi" }, "DomainName": { - "Ref": "ApiGatewayDomainNameV2ab8e63947d" + "Ref": "ApiGatewayDomainNameV22dbf35af54" }, "ApiMappingKey": "begin-here", "Stage": { @@ -96,32 +111,6 @@ } } }, - "RecordSetGroup9616db1511": { - "Type": "AWS::Route53::RecordSetGroup", - "Properties": { - "HostedZoneName": "sam-v2-regional-test.com.", - "RecordSets": [ - { - "AliasTarget": { - "HostedZoneId": { - "Fn::GetAtt": [ - "ApiGatewayDomainNameV2ab8e63947d", - "RegionalHostedZoneId" - ] - }, - "DNSName": { - "Fn::GetAtt": [ - "ApiGatewayDomainNameV2ab8e63947d", - "RegionalDomainName" - ] - } - }, - "Type": "A", - "Name": "sam-v2-regional-test.com" - } - ] - } - }, "HttpApiFunctionRole": { "Type": "AWS::IAM::Role", "Properties": { @@ -152,19 +141,30 @@ ] } }, - "ApiGatewayDomainNameV2ab8e63947d": { - "Type": "AWS::ApiGatewayV2::DomainName", + "RecordSetGroup1f4f569a7e": { + "Type": "AWS::Route53::RecordSetGroup", "Properties": { - "DomainNameConfigurations": [ + "HostedZoneName": "sam-example.com.", + "RecordSets": [ { - "CertificateArn": "arn:aws:acm:us-east-1:551213647843:certificate/6c911401-620d-4d41-b89e-366c238bb2f3", - "EndpointType": "REGIONAL" + "AliasTarget": { + "HostedZoneId": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameV22dbf35af54", + "RegionalHostedZoneId" + ] + }, + "DNSName": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameV22dbf35af54", + "RegionalDomainName" + ] + } + }, + "Type": "A", + "Name": "sam-example.com" } - ], - "DomainName": "sam-v2-regional-test.com", - "Tags": { - "httpapi:createdBy": "SAM" - } + ] } }, "MyApi": { diff --git a/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_hosted_zone_name_http.json b/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_hosted_zone_name_http.json index d46cce973..8ee48ef33 100644 --- a/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_hosted_zone_name_http.json +++ b/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_hosted_zone_name_http.json @@ -67,7 +67,7 @@ "DomainNameConfigurations": [ { "CertificateArn": "cert-arn-in-us-east-1", - "EndpointType": "EDGE" + "EndpointType": "REGIONAL" } ], "Tags": { @@ -82,11 +82,16 @@ "RecordSets": [ { "AliasTarget": { - "HostedZoneId": "Z2FDTNDATAQYW2", + "HostedZoneId": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameV20caaf24ab1", + "RegionalHostedZoneId" + ] + }, "DNSName": { "Fn::GetAtt": [ "ApiGatewayDomainNameV20caaf24ab1", - "DistributionDomainName" + "RegionalDomainName" ] } }, diff --git a/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_http.json b/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_http.json index 15b634605..9d42f4e5e 100644 --- a/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_http.json +++ b/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_http.json @@ -54,11 +54,16 @@ "RecordSets": [ { "AliasTarget": { - "HostedZoneId": "Z2FDTNDATAQYW2", + "HostedZoneId": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameV20caaf24ab1", + "RegionalHostedZoneId" + ] + }, "DNSName": { "Fn::GetAtt": [ "ApiGatewayDomainNameV20caaf24ab1", - "DistributionDomainName" + "RegionalDomainName" ] } }, @@ -67,11 +72,16 @@ }, { "AliasTarget": { - "HostedZoneId": "Z2FDTNDATAQYW2", + "HostedZoneId": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameV20caaf24ab1", + "RegionalHostedZoneId" + ] + }, "DNSName": { "Fn::GetAtt": [ "ApiGatewayDomainNameV20caaf24ab1", - "DistributionDomainName" + "RegionalDomainName" ] } }, @@ -88,7 +98,7 @@ "DomainNameConfigurations": [ { "CertificateArn": "cert-arn-in-us-east-1", - "EndpointType": "EDGE" + "EndpointType": "REGIONAL" } ], "Tags": {