From 1d0039b09b5b2d0fe3706036902cd6f1f3f0bf76 Mon Sep 17 00:00:00 2001 From: praneetap Date: Fri, 27 Sep 2019 15:10:28 -0700 Subject: [PATCH 1/4] feat: custom domain route 53 support --- samtranslator/model/api/api_generator.py | 63 +++- samtranslator/model/route53.py | 10 + samtranslator/model/sam_resources.py | 7 +- .../input/api_with_custom_domain_route53.yaml | 66 ++++ ...i_with_custom_domains_route53_invalid.yaml | 40 +++ .../output/api_with_basic_custom_domain.json | 300 ++++++++-------- ...i_with_basic_custom_domain_intrinsics.json | 116 +++---- .../api_with_custom_domain_route53.json | 307 +++++++++++++++++ .../aws-cn/api_with_basic_custom_domain.json | 320 ++++++++--------- ...i_with_basic_custom_domain_intrinsics.json | 24 +- .../api_with_custom_domain_route53.json | 323 +++++++++++++++++ .../api_with_basic_custom_domain.json | 324 +++++++++--------- ...i_with_basic_custom_domain_intrinsics.json | 32 +- .../api_with_custom_domain_route53.json | 323 +++++++++++++++++ ...i_with_custom_domains_route53_invalid.json | 8 + tests/translator/test_translator.py | 4 +- 16 files changed, 1717 insertions(+), 550 deletions(-) create mode 100644 samtranslator/model/route53.py create mode 100644 tests/translator/input/api_with_custom_domain_route53.yaml create mode 100644 tests/translator/input/error_api_with_custom_domains_route53_invalid.yaml create mode 100644 tests/translator/output/api_with_custom_domain_route53.json create mode 100644 tests/translator/output/aws-cn/api_with_custom_domain_route53.json create mode 100644 tests/translator/output/aws-us-gov/api_with_custom_domain_route53.json create mode 100644 tests/translator/output/error_api_with_custom_domains_route53_invalid.json diff --git a/samtranslator/model/api/api_generator.py b/samtranslator/model/api/api_generator.py index 4320a752f4..de4fac323d 100644 --- a/samtranslator/model/api/api_generator.py +++ b/samtranslator/model/api/api_generator.py @@ -1,10 +1,11 @@ from collections import namedtuple from six import string_types -from samtranslator.model.intrinsics import ref +from samtranslator.model.intrinsics import ref, fnGetAtt from samtranslator.model.apigateway import (ApiGatewayDeployment, ApiGatewayRestApi, ApiGatewayStage, ApiGatewayAuthorizer, ApiGatewayResponse, ApiGatewayDomainName, ApiGatewayBasePathMapping) +from samtranslator.model.route53 import Route53RecordSetGroup from samtranslator.model.exceptions import InvalidResourceException from samtranslator.model.s3_utils.uri_parser import parse_s3_uri from samtranslator.region_configuration import RegionConfiguration @@ -218,7 +219,7 @@ def _construct_api_domain(self, rest_api): Constructs and returns the ApiGateway Domain and BasepathMapping """ if self.domain is None: - return None, None + return None, None, None if self.domain.get('DomainName') is None or \ self.domain.get('CertificateArn') is None: @@ -226,15 +227,17 @@ def _construct_api_domain(self, rest_api): "Custom Domains only works if both DomainName and CertificateArn" " are provided") - logical_id = logical_id_generator.LogicalIdGenerator("", self.domain).gen() + self.domain['ApiDomainName'] = "{}{}".format('ApiGatewayDomainName', + logical_id_generator.LogicalIdGenerator("", self.domain).gen()) - domain = ApiGatewayDomainName('ApiGatewayDomainName' + logical_id, + domain = ApiGatewayDomainName(self.domain.get('ApiDomainName'), attributes=self.passthrough_resource_attributes) domain.DomainName = self.domain.get('DomainName') endpoint = self.domain.get('EndpointConfiguration') if endpoint is None: endpoint = 'REGIONAL' + self.domain['EndpointConfiguration'] = 'REGIONAL' elif endpoint not in ['EDGE', 'REGIONAL']: raise InvalidResourceException(self.logical_id, "EndpointConfiguration for Custom Domains must be" @@ -276,7 +279,53 @@ def _construct_api_domain(self, rest_api): basepath_mapping.BasePath = path basepath_resource_list.extend([basepath_mapping]) - return domain, basepath_resource_list + # Create the Route53 RecordSetGroup resource + record_set_group = None + if self.domain.get('Route53') is not None: + route53 = self.domain.get('Route53') + if route53.get('HostedZoneId') is None: + raise InvalidResourceException(self.logical_id, + "HostedZoneId is required to enable Route53 support on Custom Domains.") + logical_id = logical_id_generator.LogicalIdGenerator("", self.domain).gen() + record_set_group = Route53RecordSetGroup('RecordSetGroup' + logical_id, + attributes=self.passthrough_resource_attributes) + record_set_group.HostedZoneId = route53.get('HostedZoneId') + record_set_group.RecordSets = self._construct_record_sets_for_domain(self.domain) + + return domain, basepath_resource_list, record_set_group + + def _construct_record_sets_for_domain(self, domain): + record_set_list = [] + recordset = {} + route53 = domain.get('Route53') + + recordset['Name'] = domain.get('DomainName') + recordset['Type'] = 'A' + recordset['AliasTarget'] = self._construct_alias_target(self.domain) + record_set_list.extend([recordset]) + + if route53.get('IpV6') is not None and route53.get('IpV6') is True: + recordset['Name'] = domain.get('DomainName') + recordset['Type'] = 'AAAA' + recordset['AliasTarget'] = self._construct_alias_target(self.domain) + record_set_list.extend([recordset]) + + return record_set_list + + def _construct_alias_target(self, domain): + alias_target = {} + route53 = domain.get('Route53') + target_health = route53.get('EvaluateTargetHealth') + + if target_health is not None: + alias_target['EvaluateTargetHealth'] = target_health + if domain.get('EndpointConfiguration') == 'REGIONAL': + alias_target['HostedZoneId'] = fnGetAtt(self.domain.get('ApiDomainName'), 'RegionalHostedZoneId') + alias_target['DNSName'] = fnGetAtt(self.domain.get('ApiDomainName'), 'RegionalDomainName') + else: + alias_target['HostedZoneId'] = 'Z2FDTNDATAQYW2' + alias_target['DNSName'] = domain.get('DomainName') + return alias_target def to_cloudformation(self): """Generates CloudFormation resources from a SAM API resource @@ -285,7 +334,7 @@ def to_cloudformation(self): :rtype: tuple """ rest_api = self._construct_rest_api() - domain, basepath_mapping = self._construct_api_domain(rest_api) + domain, basepath_mapping, route53 = self._construct_api_domain(rest_api) deployment = self._construct_deployment(rest_api) swagger = None @@ -297,7 +346,7 @@ def to_cloudformation(self): stage = self._construct_stage(deployment, swagger) permissions = self._construct_authorizer_lambda_permission() - return rest_api, deployment, stage, permissions, domain, basepath_mapping + return rest_api, deployment, stage, permissions, domain, basepath_mapping, route53 def _add_cors(self): """ diff --git a/samtranslator/model/route53.py b/samtranslator/model/route53.py new file mode 100644 index 0000000000..25fd264df4 --- /dev/null +++ b/samtranslator/model/route53.py @@ -0,0 +1,10 @@ +from samtranslator.model import PropertyType, Resource +from samtranslator.model.types import is_type, is_str + + +class Route53RecordSetGroup(Resource): + resource_type = 'AWS::Route53::RecordSetGroup' + property_types = { + 'HostedZoneId': PropertyType(False, is_str()), + 'RecordSets': PropertyType(False, is_type(list)), + } diff --git a/samtranslator/model/sam_resources.py b/samtranslator/model/sam_resources.py index aa583efb88..79423b5396 100644 --- a/samtranslator/model/sam_resources.py +++ b/samtranslator/model/sam_resources.py @@ -10,7 +10,7 @@ from .tags.resource_tagging import get_tag_list from samtranslator.model import (PropertyType, SamResourceMacro, ResourceTypeResolver) -from samtranslator.model.apigateway import ApiGatewayDeployment, ApiGatewayStage +from samtranslator.model.apigateway import ApiGatewayDeployment, ApiGatewayStage, ApiGatewayDomainName from samtranslator.model.cloudformation import NestedStack from samtranslator.model.dynamodb import DynamoDBTable from samtranslator.model.exceptions import (InvalidEventException, @@ -489,6 +489,7 @@ class SamApi(SamResourceMacro): referable_properties = { "Stage": ApiGatewayStage.resource_type, "Deployment": ApiGatewayDeployment.resource_type, + "DomainName": ApiGatewayDomainName.resource_type } def to_cloudformation(self, **kwargs): @@ -531,7 +532,7 @@ def to_cloudformation(self, **kwargs): models=self.Models, domain=self.Domain) - rest_api, deployment, stage, permissions, domain, basepath_mapping = api_generator.to_cloudformation() + rest_api, deployment, stage, permissions, domain, basepath_mapping, route53 = api_generator.to_cloudformation() resources.extend([rest_api, deployment, stage]) resources.extend(permissions) @@ -539,6 +540,8 @@ def to_cloudformation(self, **kwargs): resources.extend([domain]) if basepath_mapping: resources.extend(basepath_mapping) + if route53: + resources.extend([route53]) return resources diff --git a/tests/translator/input/api_with_custom_domain_route53.yaml b/tests/translator/input/api_with_custom_domain_route53.yaml new file mode 100644 index 0000000000..dd60eee1cc --- /dev/null +++ b/tests/translator/input/api_with_custom_domain_route53.yaml @@ -0,0 +1,66 @@ +Parameters: + MyDomainName: + Type: String + Default: api-edge.com + + MyDomainCert: + Type: String + Default: my-edge-api-arn + + MyHostedZone: + Type: String + Default: myregionalhostedzoneid + +Globals: + Api: + Domain: + DomainName: !Ref MyDomainName + CertificateArn: !Ref MyDomainCert + Route53: + EvaluateTargetHealth: true + HostedZoneId: !Ref MyHostedZone + + +Resources: + MyFunction: + Type: AWS::Serverless::Function + Properties: + InlineCode: | + exports.handler = async (event) => { + const response = { + statusCode: 200, + body: JSON.stringify('Hello from Lambda!'), + }; + return response; + }; + Handler: index.handler + Runtime: nodejs8.10 + Events: + Fetch: + Type: Api + Properties: + RestApiId: !Ref MyApi + Method: Post + Path: /fetch/another + ImplicitGet: + Type: Api + Properties: + Method: Post + Path: /implicit + + MyApi: + Type: AWS::Serverless::Api + Properties: + OpenApiVersion: 3.0.1 + StageName: Prod + Domain: + DomainName: 'api-regional.com' + CertificateArn: 'my-regional-cert-arn' + EndpointConfiguration: EDGE + BasePath: + - /fetch + Route53: + HostedZoneId: my-edge-hosted-zone + IpV6: true + + diff --git a/tests/translator/input/error_api_with_custom_domains_route53_invalid.yaml b/tests/translator/input/error_api_with_custom_domains_route53_invalid.yaml new file mode 100644 index 0000000000..647576aa3a --- /dev/null +++ b/tests/translator/input/error_api_with_custom_domains_route53_invalid.yaml @@ -0,0 +1,40 @@ +Resources: + MyFunction: + Type: AWS::Serverless::Function + Properties: + InlineCode: | + exports.handler = async (event) => { + const response = { + statusCode: 200, + body: JSON.stringify('Hello from Lambda!'), + }; + return response; + }; + Handler: index.handler + Runtime: nodejs8.10 + Events: + Api: + Type: Api + Properties: + RestApiId: !Ref MyApi + Method: Put + Path: /get + Fetch: + Type: Api + Properties: + RestApiId: !Ref MyApi + Method: Post + Path: /fetch + + MyApi: + Type: AWS::Serverless::Api + Properties: + OpenApiVersion: 3.0.1 + StageName: Prod + Domain: + DomainName: 'api-example.com' + CertificateArn: 'my-api-cert-arn' + EndpointConfiguration: 'EDGE' + BasePath: [ "/get", "/fetch" ] + Route53: + EvaluateTargetHealth: false diff --git a/tests/translator/output/api_with_basic_custom_domain.json b/tests/translator/output/api_with_basic_custom_domain.json index aaea82eea6..c496d19661 100644 --- a/tests/translator/output/api_with_basic_custom_domain.json +++ b/tests/translator/output/api_with_basic_custom_domain.json @@ -10,29 +10,7 @@ } }, "Resources": { - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Handler": "index.handler", - "Code": { - "ZipFile": "exports.handler = async (event) => {\n const response = {\n statusCode: 200,\n body: JSON.stringify('Hello from Lambda!'),\n };\n return response;\n};\n" - }, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs8.10", - "Tags": [ - { - "Value": "SAM", - "Key": "lambda:createdBy" - } - ] - } - }, - "MyFunctionAnotherGetPermissionProd": { + "MyFunctionImplicitGetPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:invokeFunction", @@ -42,31 +20,18 @@ }, "SourceArn": { "Fn::Sub": [ - "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/another/get", + "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", { "__Stage__": "*", "__ApiId__": { - "Ref": "MyAnotherApi" + "Ref": "ServerlessRestApi" } } ] } } }, - "MyApifetchBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", - "Properties": { - "BasePath": "fetch", - "DomainName": "api-example.com", - "RestApiId": { - "Ref": "MyApi" - }, - "Stage": { - "Ref": "MyApiProdStage" - } - } - }, - "MyFunctionImplicitGetPermissionProd": { + "MyFunctionAnotherGetPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:invokeFunction", @@ -76,60 +41,61 @@ }, "SourceArn": { "Fn::Sub": [ - "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", + "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/another/get", { "__Stage__": "*", "__ApiId__": { - "Ref": "ServerlessRestApi" + "Ref": "MyAnotherApi" } } ] } } }, - "MyAnotherApiProdStage": { + "MyAnotherApiBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", + "Properties": { + "DomainName": "another-example.com", + "RestApiId": { + "Ref": "MyAnotherApi" + }, + "Stage": { + "Ref": "MyAnotherApiProdStage" + } + } + }, + "ServerlessRestApiProdStage": { "Type": "AWS::ApiGateway::Stage", "Properties": { "DeploymentId": { - "Ref": "MyAnotherApiDeployment298b716713" + "Ref": "ServerlessRestApiDeploymentbfc913cadd" }, "RestApiId": { - "Ref": "MyAnotherApi" + "Ref": "ServerlessRestApi" }, "StageName": "Prod" } }, - "MyAnotherApiDeployment298b716713": { + "ServerlessRestApiDeploymentbfc913cadd": { "Type": "AWS::ApiGateway::Deployment", "Properties": { "RestApiId": { - "Ref": "MyAnotherApi" + "Ref": "ServerlessRestApi" }, - "Description": "RestApi deployment id: 298b71671363fe1258648c4e2231d5efb81ee2cb" + "Description": "RestApi deployment id: bfc913caddb202a47127e0e76466ec861a0d643a", + "StageName": "Stage" } }, - "MyFunctionFetchPermissionProd": { - "Type": "AWS::Lambda::Permission", + "MyAnotherApiDeploymentdb326cbbeb": { + "Type": "AWS::ApiGateway::Deployment", "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "MyFunction" + "RestApiId": { + "Ref": "MyAnotherApi" }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch", - { - "__Stage__": "*", - "__ApiId__": { - "Ref": "MyApi" - } - } - ] - } + "Description": "RestApi deployment id: db326cbbeb414a456a1fc90ed87c3ca3eb7e096f" } }, - "MyAnotherApi": { + "MyApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { @@ -140,7 +106,19 @@ } }, "paths": { - "/another/get": { + "/get": { + "put": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" + } + }, + "responses": {} + } + }, + "/fetch": { "post": { "x-amazon-apigateway-integration": { "httpMethod": "POST", @@ -169,54 +147,107 @@ "DomainName": "api-example.com" } }, - "ServerlessRestApiDeployment6f245e96ee": { + "MyApiDeploymente8b6567c21": { "Type": "AWS::ApiGateway::Deployment", "Properties": { "RestApiId": { - "Ref": "ServerlessRestApi" + "Ref": "MyApi" }, - "Description": "RestApi deployment id: 6f245e96ee393dcf04d340172a2d8f590cff7bff", - "StageName": "Stage" + "Description": "RestApi deployment id: e8b6567c2175a539627c1d0e9c94a7737679c7de" } }, - "MyFunctionRole": { - "Type": "AWS::IAM::Role", + "ApiGatewayDomainNamed12ce5c759": { + "Type": "AWS::ApiGateway::DomainName", "Properties": { - "ManagedPolicyArns": [ - "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], - "AssumeRolePolicyDocument": { - "Version": "2012-10-17", - "Statement": [ + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": "another-api-arn", + "DomainName": "another-example.com" + } + }, + "ApiGatewayDomainName7a5525b8a3": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": "another-api-arn", + "DomainName": "another-example.com" + } + }, + "MyFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Handler": "index.handler", + "Code": { + "ZipFile": "exports.handler = async (event) => {\n const response = {\n statusCode: 200,\n body: JSON.stringify('Hello from Lambda!'),\n };\n return response;\n};\n" + }, + "Role": { + "Fn::GetAtt": [ + "MyFunctionRole", + "Arn" + ] + }, + "Runtime": "nodejs8.10", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] + } + }, + "MyFunctionFetchPermissionProd": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "apigateway.amazonaws.com", + "FunctionName": { + "Ref": "MyFunction" + }, + "SourceArn": { + "Fn::Sub": [ + "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch", { - "Action": [ - "sts:AssumeRole" - ], - "Effect": "Allow", - "Principal": { - "Service": [ - "lambda.amazonaws.com" - ] + "__Stage__": "*", + "__ApiId__": { + "Ref": "MyApi" } } ] } } }, - "MyApigetBasePathMapping": { + "ServerlessRestApiBasePathMapping": { "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { - "BasePath": "get", - "DomainName": "api-example.com", + "DomainName": "another-example.com", "RestApiId": { - "Ref": "MyApi" + "Ref": "ServerlessRestApi" }, "Stage": { - "Ref": "MyApiProdStage" + "Ref": "ServerlessRestApiProdStage" } } }, - "MyApi": { + "MyAnotherApiProdStage": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "MyAnotherApiDeploymentdb326cbbeb" + }, + "RestApiId": { + "Ref": "MyAnotherApi" + }, + "StageName": "Prod" + } + }, + "MyAnotherApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { @@ -227,19 +258,7 @@ } }, "paths": { - "/get": { - "put": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" - } - }, - "responses": {} - } - }, - "/fetch": { + "/another/get": { "post": { "x-amazon-apigateway-integration": { "httpMethod": "POST", @@ -256,48 +275,53 @@ } } }, - "MyAnotherApiBasePathMapping": { + "MyApifetchBasePathMapping": { "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { - "DomainName": "another-example.com", + "BasePath": "fetch", + "DomainName": "api-example.com", "RestApiId": { - "Ref": "MyAnotherApi" + "Ref": "MyApi" }, "Stage": { - "Ref": "MyAnotherApiProdStage" + "Ref": "MyApiProdStage" } } }, - "MyApiDeployment345fbac8f2": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "MyApi" - }, - "Description": "RestApi deployment id: 345fbac8f2a7592c5592018ad06db6de00590d35" - } - }, - "ServerlessRestApiProdStage": { - "Type": "AWS::ApiGateway::Stage", + "MyFunctionRole": { + "Type": "AWS::IAM::Role", "Properties": { - "DeploymentId": { - "Ref": "ServerlessRestApiDeployment6f245e96ee" - }, - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "StageName": "Prod" + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + } } }, - "ServerlessRestApiBasePathMapping": { + "MyApigetBasePathMapping": { "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { - "DomainName": "another-example.com", + "BasePath": "get", + "DomainName": "api-example.com", "RestApiId": { - "Ref": "ServerlessRestApi" + "Ref": "MyApi" }, "Stage": { - "Ref": "ServerlessRestApiProdStage" + "Ref": "MyApiProdStage" } } }, @@ -305,7 +329,7 @@ "Type": "AWS::ApiGateway::Stage", "Properties": { "DeploymentId": { - "Ref": "MyApiDeployment345fbac8f2" + "Ref": "MyApiDeploymente8b6567c21" }, "RestApiId": { "Ref": "MyApi" @@ -341,18 +365,6 @@ } } }, - "ApiGatewayDomainName7a5525b8a3": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "RegionalCertificateArn": "another-api-arn", - "DomainName": "another-example.com" - } - }, "MyFunctionApiPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { diff --git a/tests/translator/output/api_with_basic_custom_domain_intrinsics.json b/tests/translator/output/api_with_basic_custom_domain_intrinsics.json index a41bfa93c5..8c626f4399 100644 --- a/tests/translator/output/api_with_basic_custom_domain_intrinsics.json +++ b/tests/translator/output/api_with_basic_custom_domain_intrinsics.json @@ -63,22 +63,6 @@ }, "Condition": "C1" }, - "MyApigetBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", - "Properties": { - "BasePath": "get", - "DomainName": { - "Fn::Sub": "example-ap-southeast-1.com" - }, - "RestApiId": { - "Ref": "MyApi" - }, - "Stage": { - "Ref": "MyApiProdStage" - } - }, - "Condition": "C1" - }, "ServerlessRestApiProdStage": { "Type": "AWS::ApiGateway::Stage", "Properties": { @@ -133,22 +117,23 @@ }, "Condition": "C1" }, - "ApiGatewayDomainName2bd847e760": { - "Type": "AWS::ApiGateway::DomainName", + "MyApigetBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "RegionalCertificateArn": "another-api-arn", + "BasePath": "get", "DomainName": { "Fn::Sub": "example-ap-southeast-1.com" + }, + "RestApiId": { + "Ref": "MyApi" + }, + "Stage": { + "Ref": "MyApiProdStage" } }, "Condition": "C1" }, - "MyApi": { + "ServerlessRestApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { @@ -159,11 +144,11 @@ } }, "paths": { - "/get": { + "/implicit": { "Fn::If": [ "C1", { - "put": { + "post": { "Fn::If": [ "C1", { @@ -196,46 +181,22 @@ ] } }, - "openapi": "3.0.1" + "swagger": "2.0" } }, "Condition": "C1" }, - "ServerlessRestApiDeployment43c34b4e46": { + "MyApiDeployment9c28d20064": { "Type": "AWS::ApiGateway::Deployment", "Properties": { - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "Description": "RestApi deployment id: 43c34b4e46d381101dd94b95856a2cea244411b4", - "StageName": "Stage" - }, - "Condition": "C1" - }, - "MyApiDeploymentb73cd6313c": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "MyApi" - }, - "Description": "RestApi deployment id: b73cd6313c957bca233f1137e39ffbe99e448848" - }, - "Condition": "C1" - }, - "MyApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "MyApiDeploymentb73cd6313c" - }, "RestApiId": { "Ref": "MyApi" }, - "StageName": "Prod" + "Description": "RestApi deployment id: 9c28d20064b889d33964c909f03a6eb8da6b7c59" }, "Condition": "C1" }, - "ServerlessRestApi": { + "MyApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { @@ -246,11 +207,11 @@ } }, "paths": { - "/implicit": { + "/get": { "Fn::If": [ "C1", { - "post": { + "put": { "Fn::If": [ "C1", { @@ -283,11 +244,50 @@ ] } }, - "swagger": "2.0" + "openapi": "3.0.1" } }, "Condition": "C1" }, + "ApiGatewayDomainName2bd847e760": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": "another-api-arn", + "DomainName": { + "Fn::Sub": "example-ap-southeast-1.com" + } + }, + "Condition": "C1" + }, + "MyApiProdStage": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "MyApiDeployment9c28d20064" + }, + "RestApiId": { + "Ref": "MyApi" + }, + "StageName": "Prod" + }, + "Condition": "C1" + }, + "ServerlessRestApiDeployment43c34b4e46": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "Description": "RestApi deployment id: 43c34b4e46d381101dd94b95856a2cea244411b4", + "StageName": "Stage" + }, + "Condition": "C1" + }, "MyFunctionApiPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { diff --git a/tests/translator/output/api_with_custom_domain_route53.json b/tests/translator/output/api_with_custom_domain_route53.json new file mode 100644 index 0000000000..f6328fea0f --- /dev/null +++ b/tests/translator/output/api_with_custom_domain_route53.json @@ -0,0 +1,307 @@ +{ + "Parameters": { + "MyHostedZone": { + "Default": "myregionalhostedzoneid", + "Type": "String" + }, + "MyDomainName": { + "Default": "api-edge.com", + "Type": "String" + }, + "MyDomainCert": { + "Default": "my-edge-api-arn", + "Type": "String" + } + }, + "Resources": { + "MyFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Handler": "index.handler", + "Code": { + "ZipFile": "exports.handler = async (event) => {\n const response = {\n statusCode: 200,\n body: JSON.stringify('Hello from Lambda!'),\n };\n return response;\n};\n" + }, + "Role": { + "Fn::GetAtt": [ + "MyFunctionRole", + "Arn" + ] + }, + "Runtime": "nodejs8.10", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] + } + }, + "MyFunctionImplicitGetPermissionProd": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "apigateway.amazonaws.com", + "FunctionName": { + "Ref": "MyFunction" + }, + "SourceArn": { + "Fn::Sub": [ + "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", + { + "__Stage__": "*", + "__ApiId__": { + "Ref": "ServerlessRestApi" + } + } + ] + } + } + }, + "RecordSetGroup2102f285a7": { + "Type": "AWS::Route53::RecordSetGroup", + "Properties": { + "HostedZoneId": "myregionalhostedzoneid", + "RecordSets": [ + { + "AliasTarget": { + "EvaluateTargetHealth": true, + "HostedZoneId": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameb4325e3ba6", + "RegionalHostedZoneId" + ] + }, + "DNSName": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameb4325e3ba6", + "RegionalDomainName" + ] + } + }, + "Type": "A", + "Name": "api-edge.com" + } + ] + } + }, + "ServerlessRestApiBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", + "Properties": { + "DomainName": "api-edge.com", + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "Stage": { + "Ref": "ServerlessRestApiProdStage" + } + } + }, + "MyFunctionFetchPermissionProd": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "apigateway.amazonaws.com", + "FunctionName": { + "Ref": "MyFunction" + }, + "SourceArn": { + "Fn::Sub": [ + "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch/another", + { + "__Stage__": "*", + "__ApiId__": { + "Ref": "MyApi" + } + } + ] + } + } + }, + "ServerlessRestApiProdStage": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "ServerlessRestApiDeployment5332408c06" + }, + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "StageName": "Prod" + } + }, + "MyApiDeploymentb23755fe76": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "MyApi" + }, + "Description": "RestApi deployment id: b23755fe76eda84d559e1656bb6251c157662141" + } + }, + "MyApifetchBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", + "Properties": { + "BasePath": "fetch", + "DomainName": "api-regional.com", + "RestApiId": { + "Ref": "MyApi" + }, + "Stage": { + "Ref": "MyApiProdStage" + } + } + }, + "MyFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + } + } + }, + "RecordSetGroup3505b49f8a": { + "Type": "AWS::Route53::RecordSetGroup", + "Properties": { + "HostedZoneId": "my-edge-hosted-zone", + "RecordSets": [ + { + "AliasTarget": { + "EvaluateTargetHealth": true, + "HostedZoneId": "Z2FDTNDATAQYW2", + "DNSName": "api-regional.com" + }, + "Type": "AAAA", + "Name": "api-regional.com" + }, + { + "AliasTarget": { + "EvaluateTargetHealth": true, + "HostedZoneId": "Z2FDTNDATAQYW2", + "DNSName": "api-regional.com" + }, + "Type": "AAAA", + "Name": "api-regional.com" + } + ] + } + }, + "ServerlessRestApiDeployment5332408c06": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "Description": "RestApi deployment id: 5332408c060674292fe4785c8cfe8b3a70858887", + "StageName": "Stage" + } + }, + "MyApi": { + "Type": "AWS::ApiGateway::RestApi", + "Properties": { + "Body": { + "info": { + "version": "1.0", + "title": { + "Ref": "AWS::StackName" + } + }, + "paths": { + "/fetch/another": { + "post": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" + } + }, + "responses": {} + } + } + }, + "openapi": "3.0.1" + } + } + }, + "ApiGatewayDomainNameb4325e3ba6": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": "my-edge-api-arn", + "DomainName": "api-edge.com" + } + }, + "ApiGatewayDomainName80a04c0ec3": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "CertificateArn": "my-regional-cert-arn", + "EndpointConfiguration": { + "Types": [ + "EDGE" + ] + }, + "DomainName": "api-regional.com" + } + }, + "MyApiProdStage": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "MyApiDeploymentb23755fe76" + }, + "RestApiId": { + "Ref": "MyApi" + }, + "StageName": "Prod" + } + }, + "ServerlessRestApi": { + "Type": "AWS::ApiGateway::RestApi", + "Properties": { + "Body": { + "info": { + "version": "1.0", + "title": { + "Ref": "AWS::StackName" + } + }, + "paths": { + "/implicit": { + "post": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" + } + }, + "responses": {} + } + } + }, + "swagger": "2.0" + } + } + } + } +} \ No newline at end of file diff --git a/tests/translator/output/aws-cn/api_with_basic_custom_domain.json b/tests/translator/output/aws-cn/api_with_basic_custom_domain.json index 97a2aae5d8..3c670d96fa 100644 --- a/tests/translator/output/aws-cn/api_with_basic_custom_domain.json +++ b/tests/translator/output/aws-cn/api_with_basic_custom_domain.json @@ -10,29 +10,7 @@ } }, "Resources": { - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Handler": "index.handler", - "Code": { - "ZipFile": "exports.handler = async (event) => {\n const response = {\n statusCode: 200,\n body: JSON.stringify('Hello from Lambda!'),\n };\n return response;\n};\n" - }, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs8.10", - "Tags": [ - { - "Value": "SAM", - "Key": "lambda:createdBy" - } - ] - } - }, - "MyFunctionAnotherGetPermissionProd": { + "MyFunctionImplicitGetPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:invokeFunction", @@ -42,18 +20,18 @@ }, "SourceArn": { "Fn::Sub": [ - "arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/another/get", + "arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", { "__Stage__": "*", "__ApiId__": { - "Ref": "MyAnotherApi" + "Ref": "ServerlessRestApi" } } ] } } }, - "MyFunctionImplicitGetPermissionProd": { + "MyFunctionAnotherGetPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:invokeFunction", @@ -63,51 +41,42 @@ }, "SourceArn": { "Fn::Sub": [ - "arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", + "arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/another/get", { "__Stage__": "*", "__ApiId__": { - "Ref": "ServerlessRestApi" + "Ref": "MyAnotherApi" } } ] } } }, - "MyAnotherApiProdStage": { - "Type": "AWS::ApiGateway::Stage", + "MyAnotherApiBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { - "DeploymentId": { - "Ref": "MyAnotherApiDeploymentc61fb61d5c" - }, + "DomainName": "another-example.com", "RestApiId": { "Ref": "MyAnotherApi" }, - "StageName": "Prod" + "Stage": { + "Ref": "MyAnotherApiProdStage" + } } }, - "MyFunctionFetchPermissionProd": { - "Type": "AWS::Lambda::Permission", + "ServerlessRestApiProdStage": { + "Type": "AWS::ApiGateway::Stage", "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "MyFunction" + "DeploymentId": { + "Ref": "ServerlessRestApiDeploymentab9e1a0920" }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch", - { - "__Stage__": "*", - "__ApiId__": { - "Ref": "MyApi" - } - } - ] - } + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "StageName": "Prod" } }, - "MyAnotherApi": { + "MyApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { @@ -118,7 +87,19 @@ } }, "paths": { - "/another/get": { + "/get": { + "put": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" + } + }, + "responses": {} + } + }, + "/fetch": { "post": { "x-amazon-apigateway-integration": { "httpMethod": "POST", @@ -155,57 +136,126 @@ "DomainName": "api-example.com" } }, - "MyApifetchBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", + "MyAnotherApiDeployment97cd66ec36": { + "Type": "AWS::ApiGateway::Deployment", "Properties": { - "BasePath": "fetch", - "DomainName": "api-example.com", "RestApiId": { - "Ref": "MyApi" + "Ref": "MyAnotherApi" }, - "Stage": { - "Ref": "MyApiProdStage" - } + "Description": "RestApi deployment id: 97cd66ec36e6bcd41a2cb4568a77d6fd88c99db9" } }, - "MyFunctionRole": { - "Type": "AWS::IAM::Role", + "ApiGatewayDomainNamed12ce5c759": { + "Type": "AWS::ApiGateway::DomainName", "Properties": { - "ManagedPolicyArns": [ - "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], - "AssumeRolePolicyDocument": { - "Version": "2012-10-17", - "Statement": [ + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": "another-api-arn", + "DomainName": "another-example.com" + } + }, + "ServerlessRestApiDeploymentab9e1a0920": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "Description": "RestApi deployment id: ab9e1a092083a857077258033574270d894a8551", + "StageName": "Stage" + } + }, + "ApiGatewayDomainName7a5525b8a3": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": "another-api-arn", + "DomainName": "another-example.com" + } + }, + "MyFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Handler": "index.handler", + "Code": { + "ZipFile": "exports.handler = async (event) => {\n const response = {\n statusCode: 200,\n body: JSON.stringify('Hello from Lambda!'),\n };\n return response;\n};\n" + }, + "Role": { + "Fn::GetAtt": [ + "MyFunctionRole", + "Arn" + ] + }, + "Runtime": "nodejs8.10", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] + } + }, + "MyFunctionFetchPermissionProd": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "apigateway.amazonaws.com", + "FunctionName": { + "Ref": "MyFunction" + }, + "SourceArn": { + "Fn::Sub": [ + "arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch", { - "Action": [ - "sts:AssumeRole" - ], - "Effect": "Allow", - "Principal": { - "Service": [ - "lambda.amazonaws.com" - ] + "__Stage__": "*", + "__ApiId__": { + "Ref": "MyApi" } } ] } } }, - "MyApigetBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", + "MyApiDeploymentf9af62f948": { + "Type": "AWS::ApiGateway::Deployment", "Properties": { - "BasePath": "get", - "DomainName": "api-example.com", "RestApiId": { "Ref": "MyApi" }, + "Description": "RestApi deployment id: f9af62f9487c3b8737c3b40e1edaf7a1549eb5f6" + } + }, + "ServerlessRestApiBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", + "Properties": { + "DomainName": "another-example.com", + "RestApiId": { + "Ref": "ServerlessRestApi" + }, "Stage": { - "Ref": "MyApiProdStage" + "Ref": "ServerlessRestApiProdStage" } } }, - "MyApi": { + "MyAnotherApiProdStage": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "MyAnotherApiDeployment97cd66ec36" + }, + "RestApiId": { + "Ref": "MyAnotherApi" + }, + "StageName": "Prod" + } + }, + "MyAnotherApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { @@ -216,19 +266,7 @@ } }, "paths": { - "/get": { - "put": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" - } - }, - "responses": {} - } - }, - "/fetch": { + "/another/get": { "post": { "x-amazon-apigateway-integration": { "httpMethod": "POST", @@ -253,67 +291,53 @@ } } }, - "MyAnotherApiBasePathMapping": { + "MyApifetchBasePathMapping": { "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { - "DomainName": "another-example.com", + "BasePath": "fetch", + "DomainName": "api-example.com", "RestApiId": { - "Ref": "MyAnotherApi" + "Ref": "MyApi" }, "Stage": { - "Ref": "MyAnotherApiProdStage" + "Ref": "MyApiProdStage" } } }, - "MyApiDeploymentaf6c57ee88": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "MyApi" - }, - "Description": "RestApi deployment id: af6c57ee88bdbf0d8ace828d5ac9cc02dba55922" - } - }, - "ServerlessRestApiDeploymentd099245fb5": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "Description": "RestApi deployment id: d099245fb560a6117ebb37d418da8821c19f1eac", - "StageName": "Stage" - } - }, - "ServerlessRestApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "ServerlessRestApiDeploymentd099245fb5" - }, - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "StageName": "Prod" - } - }, - "MyAnotherApiDeploymentc61fb61d5c": { - "Type": "AWS::ApiGateway::Deployment", + "MyFunctionRole": { + "Type": "AWS::IAM::Role", "Properties": { - "RestApiId": { - "Ref": "MyAnotherApi" - }, - "Description": "RestApi deployment id: c61fb61d5cfc17e7e2f188dc18c5b11745bb6bc8" + "ManagedPolicyArns": [ + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + } } }, - "ServerlessRestApiBasePathMapping": { + "MyApigetBasePathMapping": { "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { - "DomainName": "another-example.com", + "BasePath": "get", + "DomainName": "api-example.com", "RestApiId": { - "Ref": "ServerlessRestApi" + "Ref": "MyApi" }, "Stage": { - "Ref": "ServerlessRestApiProdStage" + "Ref": "MyApiProdStage" } } }, @@ -321,7 +345,7 @@ "Type": "AWS::ApiGateway::Stage", "Properties": { "DeploymentId": { - "Ref": "MyApiDeploymentaf6c57ee88" + "Ref": "MyApiDeploymentf9af62f948" }, "RestApiId": { "Ref": "MyApi" @@ -365,18 +389,6 @@ } } }, - "ApiGatewayDomainName7a5525b8a3": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "RegionalCertificateArn": "another-api-arn", - "DomainName": "another-example.com" - } - }, "MyFunctionApiPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { diff --git a/tests/translator/output/aws-cn/api_with_basic_custom_domain_intrinsics.json b/tests/translator/output/aws-cn/api_with_basic_custom_domain_intrinsics.json index c4a2c9abc6..0e5bcb8798 100644 --- a/tests/translator/output/aws-cn/api_with_basic_custom_domain_intrinsics.json +++ b/tests/translator/output/aws-cn/api_with_basic_custom_domain_intrinsics.json @@ -144,6 +144,16 @@ }, "Condition": "C1" }, + "MyApiDeployment616cc3af2f": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "MyApi" + }, + "Description": "RestApi deployment id: 616cc3af2fced60efa5a5e30524f22ab69d68dd3" + }, + "Condition": "C1" + }, "MyApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { @@ -205,16 +215,6 @@ }, "Condition": "C1" }, - "MyApiDeployment6cfbc38395": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "MyApi" - }, - "Description": "RestApi deployment id: 6cfbc383958724f1d2d4d05d6e76f8670e66831f" - }, - "Condition": "C1" - }, "ApiGatewayDomainName4bfafc5803": { "Type": "AWS::ApiGateway::DomainName", "Properties": { @@ -234,7 +234,7 @@ "Type": "AWS::ApiGateway::Stage", "Properties": { "DeploymentId": { - "Ref": "MyApiDeployment6cfbc38395" + "Ref": "MyApiDeployment616cc3af2f" }, "RestApiId": { "Ref": "MyApi" @@ -327,4 +327,4 @@ "Condition": "C1" } } -} +} \ No newline at end of file diff --git a/tests/translator/output/aws-cn/api_with_custom_domain_route53.json b/tests/translator/output/aws-cn/api_with_custom_domain_route53.json new file mode 100644 index 0000000000..6bc36b0083 --- /dev/null +++ b/tests/translator/output/aws-cn/api_with_custom_domain_route53.json @@ -0,0 +1,323 @@ +{ + "Parameters": { + "MyHostedZone": { + "Default": "myregionalhostedzoneid", + "Type": "String" + }, + "MyDomainName": { + "Default": "api-edge.com", + "Type": "String" + }, + "MyDomainCert": { + "Default": "my-edge-api-arn", + "Type": "String" + } + }, + "Resources": { + "MyFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Handler": "index.handler", + "Code": { + "ZipFile": "exports.handler = async (event) => {\n const response = {\n statusCode: 200,\n body: JSON.stringify('Hello from Lambda!'),\n };\n return response;\n};\n" + }, + "Role": { + "Fn::GetAtt": [ + "MyFunctionRole", + "Arn" + ] + }, + "Runtime": "nodejs8.10", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] + } + }, + "MyFunctionImplicitGetPermissionProd": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "apigateway.amazonaws.com", + "FunctionName": { + "Ref": "MyFunction" + }, + "SourceArn": { + "Fn::Sub": [ + "arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", + { + "__Stage__": "*", + "__ApiId__": { + "Ref": "ServerlessRestApi" + } + } + ] + } + } + }, + "RecordSetGroup2102f285a7": { + "Type": "AWS::Route53::RecordSetGroup", + "Properties": { + "HostedZoneId": "myregionalhostedzoneid", + "RecordSets": [ + { + "AliasTarget": { + "EvaluateTargetHealth": true, + "HostedZoneId": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameb4325e3ba6", + "RegionalHostedZoneId" + ] + }, + "DNSName": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameb4325e3ba6", + "RegionalDomainName" + ] + } + }, + "Type": "A", + "Name": "api-edge.com" + } + ] + } + }, + "ServerlessRestApiBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", + "Properties": { + "DomainName": "api-edge.com", + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "Stage": { + "Ref": "ServerlessRestApiProdStage" + } + } + }, + "MyFunctionFetchPermissionProd": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "apigateway.amazonaws.com", + "FunctionName": { + "Ref": "MyFunction" + }, + "SourceArn": { + "Fn::Sub": [ + "arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch/another", + { + "__Stage__": "*", + "__ApiId__": { + "Ref": "MyApi" + } + } + ] + } + } + }, + "ServerlessRestApiProdStage": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "ServerlessRestApiDeployment538d879eb6" + }, + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "StageName": "Prod" + } + }, + "MyApifetchBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", + "Properties": { + "BasePath": "fetch", + "DomainName": "api-regional.com", + "RestApiId": { + "Ref": "MyApi" + }, + "Stage": { + "Ref": "MyApiProdStage" + } + } + }, + "MyFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "ManagedPolicyArns": [ + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + } + } + }, + "RecordSetGroup3505b49f8a": { + "Type": "AWS::Route53::RecordSetGroup", + "Properties": { + "HostedZoneId": "my-edge-hosted-zone", + "RecordSets": [ + { + "AliasTarget": { + "EvaluateTargetHealth": true, + "HostedZoneId": "Z2FDTNDATAQYW2", + "DNSName": "api-regional.com" + }, + "Type": "AAAA", + "Name": "api-regional.com" + }, + { + "AliasTarget": { + "EvaluateTargetHealth": true, + "HostedZoneId": "Z2FDTNDATAQYW2", + "DNSName": "api-regional.com" + }, + "Type": "AAAA", + "Name": "api-regional.com" + } + ] + } + }, + "MyApiDeploymentfa6919f89c": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "MyApi" + }, + "Description": "RestApi deployment id: fa6919f89c4b45e3f562e33a0a5b06b3f7dc93ae" + } + }, + "MyApi": { + "Type": "AWS::ApiGateway::RestApi", + "Properties": { + "Body": { + "info": { + "version": "1.0", + "title": { + "Ref": "AWS::StackName" + } + }, + "paths": { + "/fetch/another": { + "post": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" + } + }, + "responses": {} + } + } + }, + "openapi": "3.0.1" + }, + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "Parameters": { + "endpointConfigurationTypes": "REGIONAL" + } + } + }, + "ServerlessRestApiDeployment538d879eb6": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "Description": "RestApi deployment id: 538d879eb60b7bb6dff2551103783a7b29c4851d", + "StageName": "Stage" + } + }, + "ApiGatewayDomainNameb4325e3ba6": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": "my-edge-api-arn", + "DomainName": "api-edge.com" + } + }, + "ApiGatewayDomainName80a04c0ec3": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "CertificateArn": "my-regional-cert-arn", + "EndpointConfiguration": { + "Types": [ + "EDGE" + ] + }, + "DomainName": "api-regional.com" + } + }, + "MyApiProdStage": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "MyApiDeploymentfa6919f89c" + }, + "RestApiId": { + "Ref": "MyApi" + }, + "StageName": "Prod" + } + }, + "ServerlessRestApi": { + "Type": "AWS::ApiGateway::RestApi", + "Properties": { + "Body": { + "info": { + "version": "1.0", + "title": { + "Ref": "AWS::StackName" + } + }, + "paths": { + "/implicit": { + "post": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" + } + }, + "responses": {} + } + } + }, + "swagger": "2.0" + }, + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "Parameters": { + "endpointConfigurationTypes": "REGIONAL" + } + } + } + } +} \ No newline at end of file diff --git a/tests/translator/output/aws-us-gov/api_with_basic_custom_domain.json b/tests/translator/output/aws-us-gov/api_with_basic_custom_domain.json index 23d1f3ff40..53a0f661a5 100644 --- a/tests/translator/output/aws-us-gov/api_with_basic_custom_domain.json +++ b/tests/translator/output/aws-us-gov/api_with_basic_custom_domain.json @@ -10,29 +10,7 @@ } }, "Resources": { - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Handler": "index.handler", - "Code": { - "ZipFile": "exports.handler = async (event) => {\n const response = {\n statusCode: 200,\n body: JSON.stringify('Hello from Lambda!'),\n };\n return response;\n};\n" - }, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs8.10", - "Tags": [ - { - "Value": "SAM", - "Key": "lambda:createdBy" - } - ] - } - }, - "MyFunctionAnotherGetPermissionProd": { + "MyFunctionImplicitGetPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:invokeFunction", @@ -42,18 +20,18 @@ }, "SourceArn": { "Fn::Sub": [ - "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/another/get", + "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", { "__Stage__": "*", "__ApiId__": { - "Ref": "MyAnotherApi" + "Ref": "ServerlessRestApi" } } ] } } }, - "MyFunctionImplicitGetPermissionProd": { + "MyFunctionAnotherGetPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:invokeFunction", @@ -63,51 +41,85 @@ }, "SourceArn": { "Fn::Sub": [ - "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", + "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/another/get", { "__Stage__": "*", "__ApiId__": { - "Ref": "ServerlessRestApi" + "Ref": "MyAnotherApi" } } ] } } }, - "MyAnotherApiProdStage": { + "MyAnotherApiBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", + "Properties": { + "DomainName": "another-example.com", + "RestApiId": { + "Ref": "MyAnotherApi" + }, + "Stage": { + "Ref": "MyAnotherApiProdStage" + } + } + }, + "ServerlessRestApiProdStage": { "Type": "AWS::ApiGateway::Stage", "Properties": { "DeploymentId": { - "Ref": "MyAnotherApiDeployment619d82c169" + "Ref": "ServerlessRestApiDeploymentdb4e2ac130" }, "RestApiId": { - "Ref": "MyAnotherApi" + "Ref": "ServerlessRestApi" }, "StageName": "Prod" } }, - "MyFunctionFetchPermissionProd": { - "Type": "AWS::Lambda::Permission", + "ServerlessRestApiDeploymentdb4e2ac130": { + "Type": "AWS::ApiGateway::Deployment", "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "MyFunction" + "RestApiId": { + "Ref": "ServerlessRestApi" }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch", - { - "__Stage__": "*", - "__ApiId__": { - "Ref": "MyApi" - } - } + "Description": "RestApi deployment id: db4e2ac130d60a5397755c9e502cd2df4deca9a0", + "StageName": "Stage" + } + }, + "MyAnotherApiDeployment0dc7a651a5": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "MyAnotherApi" + }, + "Description": "RestApi deployment id: 0dc7a651a5be25f8dcd62b4fca4ae881e8151bd0" + } + }, + "ApiGatewayDomainName461285836f": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "CertificateArn": "my-api-cert-arn", + "EndpointConfiguration": { + "Types": [ + "EDGE" ] - } + }, + "DomainName": "api-example.com" } }, - "MyAnotherApi": { + "ApiGatewayDomainNamed12ce5c759": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": "another-api-arn", + "DomainName": "another-example.com" + } + }, + "MyApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { @@ -118,7 +130,19 @@ } }, "paths": { - "/another/get": { + "/get": { + "put": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:aws-us-gov:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" + } + }, + "responses": {} + } + }, + "/fetch": { "post": { "x-amazon-apigateway-integration": { "httpMethod": "POST", @@ -143,69 +167,95 @@ } } }, - "ApiGatewayDomainName461285836f": { + "ApiGatewayDomainName7a5525b8a3": { "Type": "AWS::ApiGateway::DomainName", "Properties": { - "CertificateArn": "my-api-cert-arn", "EndpointConfiguration": { "Types": [ - "EDGE" + "REGIONAL" ] }, - "DomainName": "api-example.com" + "RegionalCertificateArn": "another-api-arn", + "DomainName": "another-example.com" } }, - "MyApifetchBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", + "MyApiDeployment6d0cb977c8": { + "Type": "AWS::ApiGateway::Deployment", "Properties": { - "BasePath": "fetch", - "DomainName": "api-example.com", "RestApiId": { "Ref": "MyApi" }, - "Stage": { - "Ref": "MyApiProdStage" - } + "Description": "RestApi deployment id: 6d0cb977c8290881fb8b3f75bae7116d04a23782" } }, - "MyFunctionRole": { - "Type": "AWS::IAM::Role", + "MyFunction": { + "Type": "AWS::Lambda::Function", "Properties": { - "ManagedPolicyArns": [ - "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], - "AssumeRolePolicyDocument": { - "Version": "2012-10-17", - "Statement": [ + "Handler": "index.handler", + "Code": { + "ZipFile": "exports.handler = async (event) => {\n const response = {\n statusCode: 200,\n body: JSON.stringify('Hello from Lambda!'),\n };\n return response;\n};\n" + }, + "Role": { + "Fn::GetAtt": [ + "MyFunctionRole", + "Arn" + ] + }, + "Runtime": "nodejs8.10", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] + } + }, + "MyFunctionFetchPermissionProd": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "apigateway.amazonaws.com", + "FunctionName": { + "Ref": "MyFunction" + }, + "SourceArn": { + "Fn::Sub": [ + "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch", { - "Action": [ - "sts:AssumeRole" - ], - "Effect": "Allow", - "Principal": { - "Service": [ - "lambda.amazonaws.com" - ] + "__Stage__": "*", + "__ApiId__": { + "Ref": "MyApi" } } ] } } }, - "MyApigetBasePathMapping": { + "ServerlessRestApiBasePathMapping": { "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { - "BasePath": "get", - "DomainName": "api-example.com", + "DomainName": "another-example.com", "RestApiId": { - "Ref": "MyApi" + "Ref": "ServerlessRestApi" }, "Stage": { - "Ref": "MyApiProdStage" + "Ref": "ServerlessRestApiProdStage" } } }, - "MyApi": { + "MyAnotherApiProdStage": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "MyAnotherApiDeployment0dc7a651a5" + }, + "RestApiId": { + "Ref": "MyAnotherApi" + }, + "StageName": "Prod" + } + }, + "MyAnotherApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { @@ -216,19 +266,7 @@ } }, "paths": { - "/get": { - "put": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws-us-gov:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" - } - }, - "responses": {} - } - }, - "/fetch": { + "/another/get": { "post": { "x-amazon-apigateway-integration": { "httpMethod": "POST", @@ -253,63 +291,61 @@ } } }, - "MyAnotherApiBasePathMapping": { + "MyApifetchBasePathMapping": { "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { - "DomainName": "another-example.com", + "BasePath": "fetch", + "DomainName": "api-example.com", "RestApiId": { - "Ref": "MyAnotherApi" + "Ref": "MyApi" }, "Stage": { - "Ref": "MyAnotherApiProdStage" + "Ref": "MyApiProdStage" } } }, - "MyApiDeploymentb70cda6c19": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "MyApi" - }, - "Description": "RestApi deployment id: b70cda6c195d5d7d6300422874b03fdf3ac8cf16" - } - }, - "ServerlessRestApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "ServerlessRestApiDeployment15c5513463" - }, - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "StageName": "Prod" - } - }, - "ServerlessRestApiDeployment15c5513463": { - "Type": "AWS::ApiGateway::Deployment", + "MyFunctionRole": { + "Type": "AWS::IAM::Role", "Properties": { - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "Description": "RestApi deployment id: 15c5513463f336ce7d80f9107134351289f4dc75", - "StageName": "Stage" + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + } } }, - "MyAnotherApiDeployment619d82c169": { - "Type": "AWS::ApiGateway::Deployment", + "MyApigetBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { + "BasePath": "get", + "DomainName": "api-example.com", "RestApiId": { - "Ref": "MyAnotherApi" + "Ref": "MyApi" }, - "Description": "RestApi deployment id: 619d82c169072c33e3a62ae66f9bbe723d9f6d71" + "Stage": { + "Ref": "MyApiProdStage" + } } }, "MyApiProdStage": { "Type": "AWS::ApiGateway::Stage", "Properties": { "DeploymentId": { - "Ref": "MyApiDeploymentb70cda6c19" + "Ref": "MyApiDeployment6d0cb977c8" }, "RestApiId": { "Ref": "MyApi" @@ -317,18 +353,6 @@ "StageName": "Prod" } }, - "ServerlessRestApiBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", - "Properties": { - "DomainName": "another-example.com", - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "Stage": { - "Ref": "ServerlessRestApiProdStage" - } - } - }, "ServerlessRestApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { @@ -365,18 +389,6 @@ } } }, - "ApiGatewayDomainName7a5525b8a3": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "RegionalCertificateArn": "another-api-arn", - "DomainName": "another-example.com" - } - }, "MyFunctionApiPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { diff --git a/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_intrinsics.json b/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_intrinsics.json index 1b738ec6ef..5852d397ea 100644 --- a/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_intrinsics.json +++ b/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_intrinsics.json @@ -63,13 +63,18 @@ }, "Condition": "C1" }, - "MyApiDeploymentc15ba09b92": { - "Type": "AWS::ApiGateway::Deployment", + "ApiGatewayDomainNamedf402213e0": { + "Type": "AWS::ApiGateway::DomainName", "Properties": { - "RestApiId": { - "Ref": "MyApi" + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] }, - "Description": "RestApi deployment id: c15ba09b92a98c578c133496aa7d330c1666c2b8" + "RegionalCertificateArn": "another-api-arn", + "DomainName": { + "Fn::Sub": "example-us-gov-west-1.com" + } }, "Condition": "C1" }, @@ -215,18 +220,13 @@ }, "Condition": "C1" }, - "ApiGatewayDomainNamedf402213e0": { - "Type": "AWS::ApiGateway::DomainName", + "MyApiDeployment0ba140d008": { + "Type": "AWS::ApiGateway::Deployment", "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] + "RestApiId": { + "Ref": "MyApi" }, - "RegionalCertificateArn": "another-api-arn", - "DomainName": { - "Fn::Sub": "example-us-gov-west-1.com" - } + "Description": "RestApi deployment id: 0ba140d00843cdd83115b4d663463aa0f21c4fef" }, "Condition": "C1" }, @@ -234,7 +234,7 @@ "Type": "AWS::ApiGateway::Stage", "Properties": { "DeploymentId": { - "Ref": "MyApiDeploymentc15ba09b92" + "Ref": "MyApiDeployment0ba140d008" }, "RestApiId": { "Ref": "MyApi" diff --git a/tests/translator/output/aws-us-gov/api_with_custom_domain_route53.json b/tests/translator/output/aws-us-gov/api_with_custom_domain_route53.json new file mode 100644 index 0000000000..b0c08ac44c --- /dev/null +++ b/tests/translator/output/aws-us-gov/api_with_custom_domain_route53.json @@ -0,0 +1,323 @@ +{ + "Parameters": { + "MyHostedZone": { + "Default": "myregionalhostedzoneid", + "Type": "String" + }, + "MyDomainName": { + "Default": "api-edge.com", + "Type": "String" + }, + "MyDomainCert": { + "Default": "my-edge-api-arn", + "Type": "String" + } + }, + "Resources": { + "MyFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Handler": "index.handler", + "Code": { + "ZipFile": "exports.handler = async (event) => {\n const response = {\n statusCode: 200,\n body: JSON.stringify('Hello from Lambda!'),\n };\n return response;\n};\n" + }, + "Role": { + "Fn::GetAtt": [ + "MyFunctionRole", + "Arn" + ] + }, + "Runtime": "nodejs8.10", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] + } + }, + "MyFunctionImplicitGetPermissionProd": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "apigateway.amazonaws.com", + "FunctionName": { + "Ref": "MyFunction" + }, + "SourceArn": { + "Fn::Sub": [ + "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", + { + "__Stage__": "*", + "__ApiId__": { + "Ref": "ServerlessRestApi" + } + } + ] + } + } + }, + "RecordSetGroup2102f285a7": { + "Type": "AWS::Route53::RecordSetGroup", + "Properties": { + "HostedZoneId": "myregionalhostedzoneid", + "RecordSets": [ + { + "AliasTarget": { + "EvaluateTargetHealth": true, + "HostedZoneId": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameb4325e3ba6", + "RegionalHostedZoneId" + ] + }, + "DNSName": { + "Fn::GetAtt": [ + "ApiGatewayDomainNameb4325e3ba6", + "RegionalDomainName" + ] + } + }, + "Type": "A", + "Name": "api-edge.com" + } + ] + } + }, + "ServerlessRestApiBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", + "Properties": { + "DomainName": "api-edge.com", + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "Stage": { + "Ref": "ServerlessRestApiProdStage" + } + } + }, + "MyFunctionFetchPermissionProd": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "apigateway.amazonaws.com", + "FunctionName": { + "Ref": "MyFunction" + }, + "SourceArn": { + "Fn::Sub": [ + "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch/another", + { + "__Stage__": "*", + "__ApiId__": { + "Ref": "MyApi" + } + } + ] + } + } + }, + "ServerlessRestApiProdStage": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "ServerlessRestApiDeploymentc7f91ee60c" + }, + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "StageName": "Prod" + } + }, + "MyApifetchBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", + "Properties": { + "BasePath": "fetch", + "DomainName": "api-regional.com", + "RestApiId": { + "Ref": "MyApi" + }, + "Stage": { + "Ref": "MyApiProdStage" + } + } + }, + "MyFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + } + } + }, + "RecordSetGroup3505b49f8a": { + "Type": "AWS::Route53::RecordSetGroup", + "Properties": { + "HostedZoneId": "my-edge-hosted-zone", + "RecordSets": [ + { + "AliasTarget": { + "EvaluateTargetHealth": true, + "HostedZoneId": "Z2FDTNDATAQYW2", + "DNSName": "api-regional.com" + }, + "Type": "AAAA", + "Name": "api-regional.com" + }, + { + "AliasTarget": { + "EvaluateTargetHealth": true, + "HostedZoneId": "Z2FDTNDATAQYW2", + "DNSName": "api-regional.com" + }, + "Type": "AAAA", + "Name": "api-regional.com" + } + ] + } + }, + "MyApi": { + "Type": "AWS::ApiGateway::RestApi", + "Properties": { + "Body": { + "info": { + "version": "1.0", + "title": { + "Ref": "AWS::StackName" + } + }, + "paths": { + "/fetch/another": { + "post": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:aws-us-gov:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" + } + }, + "responses": {} + } + } + }, + "openapi": "3.0.1" + }, + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "Parameters": { + "endpointConfigurationTypes": "REGIONAL" + } + } + }, + "MyApiDeploymentece2396345": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "MyApi" + }, + "Description": "RestApi deployment id: ece23963453cba09e1dd80334d4ea64521c62c39" + } + }, + "ServerlessRestApiDeploymentc7f91ee60c": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "Description": "RestApi deployment id: c7f91ee60c6682d93d33ed09ae55ece2400e3469", + "StageName": "Stage" + } + }, + "ApiGatewayDomainNameb4325e3ba6": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": "my-edge-api-arn", + "DomainName": "api-edge.com" + } + }, + "ApiGatewayDomainName80a04c0ec3": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "CertificateArn": "my-regional-cert-arn", + "EndpointConfiguration": { + "Types": [ + "EDGE" + ] + }, + "DomainName": "api-regional.com" + } + }, + "MyApiProdStage": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "MyApiDeploymentece2396345" + }, + "RestApiId": { + "Ref": "MyApi" + }, + "StageName": "Prod" + } + }, + "ServerlessRestApi": { + "Type": "AWS::ApiGateway::RestApi", + "Properties": { + "Body": { + "info": { + "version": "1.0", + "title": { + "Ref": "AWS::StackName" + } + }, + "paths": { + "/implicit": { + "post": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:aws-us-gov:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" + } + }, + "responses": {} + } + } + }, + "swagger": "2.0" + }, + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "Parameters": { + "endpointConfigurationTypes": "REGIONAL" + } + } + } + } +} \ No newline at end of file diff --git a/tests/translator/output/error_api_with_custom_domains_route53_invalid.json b/tests/translator/output/error_api_with_custom_domains_route53_invalid.json new file mode 100644 index 0000000000..5f21a0ab82 --- /dev/null +++ b/tests/translator/output/error_api_with_custom_domains_route53_invalid.json @@ -0,0 +1,8 @@ +{ + "errors": [ + { + "errorMessage": "Resource with id [MyApi] is invalid. HostedZoneId is required to enable Route53 support on Custom Domains." + } + ], + "errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [MyApi] is invalid. HostedZoneId is required to enable Route53 support on Custom Domains." +} diff --git a/tests/translator/test_translator.py b/tests/translator/test_translator.py index 9b0a5363fc..6f91b77708 100644 --- a/tests/translator/test_translator.py +++ b/tests/translator/test_translator.py @@ -316,6 +316,7 @@ def test_transform_success(self, testcase, partition_with_region): 'api_with_apikey_required_openapi_3', 'api_with_basic_custom_domain', 'api_with_basic_custom_domain_intrinsics', + 'api_with_custom_domain_route53' ], [ ("aws", "ap-southeast-1"), @@ -545,7 +546,8 @@ def _generate_new_deployment_hash(self, logical_id, dict_to_hash, rest_api_to_sw 'error_function_with_invalid_condition_name', 'error_invalid_document_empty_semantic_version', 'error_api_with_invalid_open_api_version_type', - 'error_api_with_custom_domains_invalid' + 'error_api_with_custom_domains_invalid', + 'error_api_with_custom_domains_route53_invalid' ]) @patch('boto3.session.Session.region_name', 'ap-southeast-1') @patch('samtranslator.plugins.application.serverless_app_plugin.ServerlessAppPlugin._sar_service_call', mock_sar_service_call) From 322d1a985e28610686782a7d238feb58a9a1b478 Mon Sep 17 00:00:00 2001 From: praneetap Date: Fri, 27 Sep 2019 22:34:43 -0700 Subject: [PATCH 2/4] some fixes --- samtranslator/model/api/api_generator.py | 25 +++++--- .../input/api_with_custom_domain_route53.yaml | 64 ++++++++++--------- 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/samtranslator/model/api/api_generator.py b/samtranslator/model/api/api_generator.py index de4fac323d..bdae353de1 100644 --- a/samtranslator/model/api/api_generator.py +++ b/samtranslator/model/api/api_generator.py @@ -228,7 +228,7 @@ def _construct_api_domain(self, rest_api): " are provided") self.domain['ApiDomainName'] = "{}{}".format('ApiGatewayDomainName', - logical_id_generator.LogicalIdGenerator("", self.domain).gen()) + logical_id_generator.LogicalIdGenerator("", self.domain.get('DomainName')).gen()) domain = ApiGatewayDomainName(self.domain.get('ApiDomainName'), attributes=self.passthrough_resource_attributes) @@ -286,7 +286,7 @@ def _construct_api_domain(self, rest_api): if route53.get('HostedZoneId') is None: raise InvalidResourceException(self.logical_id, "HostedZoneId is required to enable Route53 support on Custom Domains.") - logical_id = logical_id_generator.LogicalIdGenerator("", self.domain).gen() + logical_id = logical_id_generator.LogicalIdGenerator("", route53.get('HostedZoneId')).gen() record_set_group = Route53RecordSetGroup('RecordSetGroup' + logical_id, attributes=self.passthrough_resource_attributes) record_set_group.HostedZoneId = route53.get('HostedZoneId') @@ -295,22 +295,23 @@ def _construct_api_domain(self, rest_api): return domain, basepath_resource_list, record_set_group def _construct_record_sets_for_domain(self, domain): - record_set_list = [] + recordset_list = [] recordset = {} route53 = domain.get('Route53') recordset['Name'] = domain.get('DomainName') recordset['Type'] = 'A' recordset['AliasTarget'] = self._construct_alias_target(self.domain) - record_set_list.extend([recordset]) + recordset_list.extend([recordset]) + recordset_ipv6 = {} if route53.get('IpV6') is not None and route53.get('IpV6') is True: - recordset['Name'] = domain.get('DomainName') - recordset['Type'] = 'AAAA' - recordset['AliasTarget'] = self._construct_alias_target(self.domain) - record_set_list.extend([recordset]) + recordset_ipv6['Name'] = domain.get('DomainName') + recordset_ipv6['Type'] = 'AAAA' + recordset_ipv6['AliasTarget'] = self._construct_alias_target(self.domain) + recordset_list.extend([recordset_ipv6]) - return record_set_list + return recordset_list def _construct_alias_target(self, domain): alias_target = {} @@ -323,8 +324,12 @@ 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: + raise InvalidResourceException(self.logical_id, + "Custom Domains support for EDGE requires the name " + "of a Distribution resource") alias_target['HostedZoneId'] = 'Z2FDTNDATAQYW2' - alias_target['DNSName'] = domain.get('DomainName') + alias_target['DNSName'] = route53.get('DistributionDomainName') return alias_target def to_cloudformation(self): diff --git a/tests/translator/input/api_with_custom_domain_route53.yaml b/tests/translator/input/api_with_custom_domain_route53.yaml index dd60eee1cc..cae179a766 100644 --- a/tests/translator/input/api_with_custom_domain_route53.yaml +++ b/tests/translator/input/api_with_custom_domain_route53.yaml @@ -1,26 +1,10 @@ Parameters: - MyDomainName: + DomainName: Type: String - Default: api-edge.com - - MyDomainCert: - Type: String - Default: my-edge-api-arn - - MyHostedZone: + Default: 'sam-edge.com' + ACMCertificateArn: Type: String - Default: myregionalhostedzoneid - -Globals: - Api: - Domain: - DomainName: !Ref MyDomainName - CertificateArn: !Ref MyDomainCert - Route53: - EvaluateTargetHealth: true - HostedZoneId: !Ref MyHostedZone - - + Default: 'arn:aws:acm:us-east-1:551213647843:certificate/cd16c460-cd67-41ea-9de5-0f306e225b73' Resources: MyFunction: Type: AWS::Serverless::Function @@ -41,12 +25,7 @@ Resources: Properties: RestApiId: !Ref MyApi Method: Post - Path: /fetch/another - ImplicitGet: - Type: Api - Properties: - Method: Post - Path: /implicit + Path: /fetch MyApi: Type: AWS::Serverless::Api @@ -54,13 +33,38 @@ Resources: OpenApiVersion: 3.0.1 StageName: Prod Domain: - DomainName: 'api-regional.com' - CertificateArn: 'my-regional-cert-arn' + DomainName: !Ref DomainName + CertificateArn: !Ref ACMCertificateArn EndpointConfiguration: EDGE BasePath: - /fetch Route53: - HostedZoneId: my-edge-hosted-zone + HostedZoneId: ZQ1UAL4EFZVME IpV6: true + DistributionDomainName: !GetAtt Distribution.DomainName - + Distribution: + Type: AWS::CloudFront::Distribution + Properties: + DistributionConfig: + Enabled: true + HttpVersion: http2 + Origins: + - DomainName: !Ref DomainName + Id: !Ref DomainName + CustomOriginConfig: + HTTPPort: 80 + HTTPSPort: 443 + OriginProtocolPolicy: https-only + DefaultCacheBehavior: + AllowedMethods: [ HEAD, DELETE, POST, GET, OPTIONS, PUT, PATCH ] + ForwardedValues: + QueryString: false + SmoothStreaming: false + Compress: true + TargetOriginId: !Ref DomainName + ViewerProtocolPolicy: redirect-to-https + PriceClass: PriceClass_100 + ViewerCertificate: + SslSupportMethod: sni-only + AcmCertificateArn: !Ref ACMCertificateArn \ No newline at end of file From 467fef9a9303eabb432bc4c98ccfbab6478498d5 Mon Sep 17 00:00:00 2001 From: praneetap Date: Fri, 27 Sep 2019 23:47:56 -0700 Subject: [PATCH 3/4] test fixes and examples --- .../custom_domains_with_route53/README.md | 21 ++ .../custom_domains_with_route53/template.yaml | 70 ++++ samtranslator/model/api/api_generator.py | 3 +- .../input/api_with_custom_domain_route53.yaml | 4 +- .../output/api_with_basic_custom_domain.json | 312 ++++++++-------- ...i_with_basic_custom_domain_intrinsics.json | 98 ++--- .../aws-cn/api_with_basic_custom_domain.json | 334 ++++++++--------- ...i_with_basic_custom_domain_intrinsics.json | 48 +-- .../api_with_basic_custom_domain.json | 348 +++++++++--------- ...i_with_basic_custom_domain_intrinsics.json | 42 +-- 10 files changed, 668 insertions(+), 612 deletions(-) create mode 100644 examples/2016-10-31/custom_domains_with_route53/README.md create mode 100644 examples/2016-10-31/custom_domains_with_route53/template.yaml diff --git a/examples/2016-10-31/custom_domains_with_route53/README.md b/examples/2016-10-31/custom_domains_with_route53/README.md new file mode 100644 index 0000000000..e4f6670b59 --- /dev/null +++ b/examples/2016-10-31/custom_domains_with_route53/README.md @@ -0,0 +1,21 @@ +# Custom Domains support + +Example SAM template for setting up Api Gateway resources for custom domains. + +## Prerequisites for setting up custom domains +1. A domain name. You can purchase a domain name from a domain name provider. +1. A certificate ARN. Set up or import a valid certificate into AWS Certificate Manager. If the endpoint is EDGE, the certificate must be created in us-east-1. +1. A HostedZone in Route53 for the domain name. +1. A Cloudfront Distribution for the domain if the endpoint is set to EDGE. + +## PostRequisites +After deploying the template, make sure you configure the DNS settings on the domain name provider's website. You will need to add Type A and Type AAAA DNS records that are point to ApiGateway's Hosted Zone Id. Read more [here](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-api-gateway.html) + +## Running the example + +```bash +$ sam deploy \ + --template-file /path_to_template/packaged-template.yaml \ + --stack-name my-new-stack \ + --capabilities CAPABILITY_IAM +``` diff --git a/examples/2016-10-31/custom_domains_with_route53/template.yaml b/examples/2016-10-31/custom_domains_with_route53/template.yaml new file mode 100644 index 0000000000..80aaeebc7b --- /dev/null +++ b/examples/2016-10-31/custom_domains_with_route53/template.yaml @@ -0,0 +1,70 @@ +Parameters: + DomainName: + Type: String + Default: 'example.com' + ACMCertificateArn: + Type: String + Default: 'cert-arn-in-us-east-1' +Resources: + MyFunction: + Type: AWS::Serverless::Function + Properties: + InlineCode: | + exports.handler = async (event) => { + const response = { + statusCode: 200, + body: JSON.stringify('Hello from Lambda!'), + }; + return response; + }; + Handler: index.handler + Runtime: nodejs8.10 + Events: + Fetch: + Type: Api + Properties: + RestApiId: !Ref MyApi + Method: Post + Path: /fetch + + MyApi: + Type: AWS::Serverless::Api + Properties: + OpenApiVersion: 3.0.1 + StageName: Prod + Domain: + DomainName: !Ref DomainName + CertificateArn: !Ref ACMCertificateArn + EndpointConfiguration: EDGE + BasePath: + - /fetch + Route53: + HostedZoneId: ZQ1UAL4EFZVME + IpV6: true + DistributionDomainName: !GetAtt Distribution.DomainName + + Distribution: + Type: AWS::CloudFront::Distribution + Properties: + DistributionConfig: + Enabled: true + HttpVersion: http2 + Origins: + - DomainName: !Ref DomainName + Id: !Ref DomainName + CustomOriginConfig: + HTTPPort: 80 + HTTPSPort: 443 + OriginProtocolPolicy: https-only + DefaultCacheBehavior: + AllowedMethods: [ HEAD, DELETE, POST, GET, OPTIONS, PUT, PATCH ] + ForwardedValues: + QueryString: false + SmoothStreaming: false + Compress: true + TargetOriginId: !Ref DomainName + ViewerProtocolPolicy: redirect-to-https + PriceClass: PriceClass_100 + ViewerCertificate: + SslSupportMethod: sni-only + AcmCertificateArn: !Ref ACMCertificateArn \ No newline at end of file diff --git a/samtranslator/model/api/api_generator.py b/samtranslator/model/api/api_generator.py index bdae353de1..fd237a2c49 100644 --- a/samtranslator/model/api/api_generator.py +++ b/samtranslator/model/api/api_generator.py @@ -228,7 +228,8 @@ def _construct_api_domain(self, rest_api): " are provided") self.domain['ApiDomainName'] = "{}{}".format('ApiGatewayDomainName', - logical_id_generator.LogicalIdGenerator("", self.domain.get('DomainName')).gen()) + logical_id_generator. + LogicalIdGenerator("", self.domain.get('DomainName')).gen()) domain = ApiGatewayDomainName(self.domain.get('ApiDomainName'), attributes=self.passthrough_resource_attributes) diff --git a/tests/translator/input/api_with_custom_domain_route53.yaml b/tests/translator/input/api_with_custom_domain_route53.yaml index cae179a766..80aaeebc7b 100644 --- a/tests/translator/input/api_with_custom_domain_route53.yaml +++ b/tests/translator/input/api_with_custom_domain_route53.yaml @@ -1,10 +1,10 @@ Parameters: DomainName: Type: String - Default: 'sam-edge.com' + Default: 'example.com' ACMCertificateArn: Type: String - Default: 'arn:aws:acm:us-east-1:551213647843:certificate/cd16c460-cd67-41ea-9de5-0f306e225b73' + Default: 'cert-arn-in-us-east-1' Resources: MyFunction: Type: AWS::Serverless::Function diff --git a/tests/translator/output/api_with_basic_custom_domain.json b/tests/translator/output/api_with_basic_custom_domain.json index c496d19661..708cfa50de 100644 --- a/tests/translator/output/api_with_basic_custom_domain.json +++ b/tests/translator/output/api_with_basic_custom_domain.json @@ -10,7 +10,29 @@ } }, "Resources": { - "MyFunctionImplicitGetPermissionProd": { + "MyFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Handler": "index.handler", + "Code": { + "ZipFile": "exports.handler = async (event) => {\n const response = {\n statusCode: 200,\n body: JSON.stringify('Hello from Lambda!'),\n };\n return response;\n};\n" + }, + "Role": { + "Fn::GetAtt": [ + "MyFunctionRole", + "Arn" + ] + }, + "Runtime": "nodejs8.10", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] + } + }, + "MyFunctionAnotherGetPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:invokeFunction", @@ -20,18 +42,30 @@ }, "SourceArn": { "Fn::Sub": [ - "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", + "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/another/get", { "__Stage__": "*", "__ApiId__": { - "Ref": "ServerlessRestApi" + "Ref": "MyAnotherApi" } } ] } } }, - "MyFunctionAnotherGetPermissionProd": { + "ApiGatewayDomainName23cdccdf9c": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "CertificateArn": "my-api-cert-arn", + "EndpointConfiguration": { + "Types": [ + "EDGE" + ] + }, + "DomainName": "api-example.com" + } + }, + "MyFunctionImplicitGetPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:invokeFunction", @@ -41,61 +75,63 @@ }, "SourceArn": { "Fn::Sub": [ - "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/another/get", + "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", { "__Stage__": "*", "__ApiId__": { - "Ref": "MyAnotherApi" + "Ref": "ServerlessRestApi" } } ] } } }, - "MyAnotherApiBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", - "Properties": { - "DomainName": "another-example.com", - "RestApiId": { - "Ref": "MyAnotherApi" - }, - "Stage": { - "Ref": "MyAnotherApiProdStage" - } - } - }, - "ServerlessRestApiProdStage": { + "MyAnotherApiProdStage": { "Type": "AWS::ApiGateway::Stage", "Properties": { "DeploymentId": { - "Ref": "ServerlessRestApiDeploymentbfc913cadd" + "Ref": "MyAnotherApiDeploymente89573907a" }, "RestApiId": { - "Ref": "ServerlessRestApi" + "Ref": "MyAnotherApi" }, "StageName": "Prod" } }, - "ServerlessRestApiDeploymentbfc913cadd": { - "Type": "AWS::ApiGateway::Deployment", + "MyFunctionFetchPermissionProd": { + "Type": "AWS::Lambda::Permission", "Properties": { - "RestApiId": { - "Ref": "ServerlessRestApi" + "Action": "lambda:invokeFunction", + "Principal": "apigateway.amazonaws.com", + "FunctionName": { + "Ref": "MyFunction" }, - "Description": "RestApi deployment id: bfc913caddb202a47127e0e76466ec861a0d643a", - "StageName": "Stage" + "SourceArn": { + "Fn::Sub": [ + "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch", + { + "__Stage__": "*", + "__ApiId__": { + "Ref": "MyApi" + } + } + ] + } } }, - "MyAnotherApiDeploymentdb326cbbeb": { - "Type": "AWS::ApiGateway::Deployment", + "MyAnotherApiBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { + "DomainName": "another-example.com", "RestApiId": { "Ref": "MyAnotherApi" }, - "Description": "RestApi deployment id: db326cbbeb414a456a1fc90ed87c3ca3eb7e096f" + "Stage": { + "Ref": "MyAnotherApiProdStage" + } } }, - "MyApi": { + "MyAnotherApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { @@ -106,19 +142,7 @@ } }, "paths": { - "/get": { - "put": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" - } - }, - "responses": {} - } - }, - "/fetch": { + "/another/get": { "post": { "x-amazon-apigateway-integration": { "httpMethod": "POST", @@ -135,119 +159,53 @@ } } }, - "ApiGatewayDomainName461285836f": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "CertificateArn": "my-api-cert-arn", - "EndpointConfiguration": { - "Types": [ - "EDGE" - ] - }, - "DomainName": "api-example.com" - } - }, - "MyApiDeploymente8b6567c21": { + "MyApiDeploymentddf2dae73e": { "Type": "AWS::ApiGateway::Deployment", "Properties": { "RestApiId": { "Ref": "MyApi" }, - "Description": "RestApi deployment id: e8b6567c2175a539627c1d0e9c94a7737679c7de" - } - }, - "ApiGatewayDomainNamed12ce5c759": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "RegionalCertificateArn": "another-api-arn", - "DomainName": "another-example.com" - } - }, - "ApiGatewayDomainName7a5525b8a3": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "RegionalCertificateArn": "another-api-arn", - "DomainName": "another-example.com" + "Description": "RestApi deployment id: ddf2dae73e4e91595e8de4be7a30a1d207f32aab" } }, - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Handler": "index.handler", - "Code": { - "ZipFile": "exports.handler = async (event) => {\n const response = {\n statusCode: 200,\n body: JSON.stringify('Hello from Lambda!'),\n };\n return response;\n};\n" - }, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs8.10", - "Tags": [ - { - "Value": "SAM", - "Key": "lambda:createdBy" - } - ] - } - }, - "MyFunctionFetchPermissionProd": { - "Type": "AWS::Lambda::Permission", + "MyFunctionRole": { + "Type": "AWS::IAM::Role", "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "MyFunction" - }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch", + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ { - "__Stage__": "*", - "__ApiId__": { - "Ref": "MyApi" + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] } } ] } } }, - "ServerlessRestApiBasePathMapping": { + "MyApigetBasePathMapping": { "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { - "DomainName": "another-example.com", + "BasePath": "get", + "DomainName": "api-example.com", "RestApiId": { - "Ref": "ServerlessRestApi" + "Ref": "MyApi" }, "Stage": { - "Ref": "ServerlessRestApiProdStage" + "Ref": "MyApiProdStage" } } }, - "MyAnotherApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "MyAnotherApiDeploymentdb326cbbeb" - }, - "RestApiId": { - "Ref": "MyAnotherApi" - }, - "StageName": "Prod" - } - }, - "MyAnotherApi": { + "MyApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { @@ -258,7 +216,19 @@ } }, "paths": { - "/another/get": { + "/get": { + "put": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" + } + }, + "responses": {} + } + }, + "/fetch": { "post": { "x-amazon-apigateway-integration": { "httpMethod": "POST", @@ -275,6 +245,27 @@ } } }, + "MyAnotherApiDeploymente89573907a": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "MyAnotherApi" + }, + "Description": "RestApi deployment id: e89573907aa0c18379ba3bcc497b31454e88a664" + } + }, + "ApiGatewayDomainNameeab65c1531": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": "another-api-arn", + "DomainName": "another-example.com" + } + }, "MyApifetchBasePathMapping": { "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { @@ -288,40 +279,37 @@ } } }, - "MyFunctionRole": { - "Type": "AWS::IAM::Role", + "ServerlessRestApiProdStage": { + "Type": "AWS::ApiGateway::Stage", "Properties": { - "ManagedPolicyArns": [ - "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], - "AssumeRolePolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Action": [ - "sts:AssumeRole" - ], - "Effect": "Allow", - "Principal": { - "Service": [ - "lambda.amazonaws.com" - ] - } - } - ] - } + "DeploymentId": { + "Ref": "ServerlessRestApiDeployment7db01b740c" + }, + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "StageName": "Prod" } }, - "MyApigetBasePathMapping": { + "ServerlessRestApiDeployment7db01b740c": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "Description": "RestApi deployment id: 7db01b740cb897c4fc4175031f25e8123cc57ca9", + "StageName": "Stage" + } + }, + "ServerlessRestApiBasePathMapping": { "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { - "BasePath": "get", - "DomainName": "api-example.com", + "DomainName": "another-example.com", "RestApiId": { - "Ref": "MyApi" + "Ref": "ServerlessRestApi" }, "Stage": { - "Ref": "MyApiProdStage" + "Ref": "ServerlessRestApiProdStage" } } }, @@ -329,7 +317,7 @@ "Type": "AWS::ApiGateway::Stage", "Properties": { "DeploymentId": { - "Ref": "MyApiDeploymente8b6567c21" + "Ref": "MyApiDeploymentddf2dae73e" }, "RestApiId": { "Ref": "MyApi" diff --git a/tests/translator/output/api_with_basic_custom_domain_intrinsics.json b/tests/translator/output/api_with_basic_custom_domain_intrinsics.json index 8c626f4399..4b7879e7d7 100644 --- a/tests/translator/output/api_with_basic_custom_domain_intrinsics.json +++ b/tests/translator/output/api_with_basic_custom_domain_intrinsics.json @@ -63,6 +63,31 @@ }, "Condition": "C1" }, + "ApiGatewayDomainNamec0ed6fae34": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": "another-api-arn", + "DomainName": { + "Fn::Sub": "example-ap-southeast-1.com" + } + }, + "Condition": "C1" + }, + "MyApiDeployment6e1ee39b06": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "MyApi" + }, + "Description": "RestApi deployment id: 6e1ee39b068c65688d05f859c3952e41396ecede" + }, + "Condition": "C1" + }, "ServerlessRestApiProdStage": { "Type": "AWS::ApiGateway::Stage", "Properties": { @@ -133,7 +158,7 @@ }, "Condition": "C1" }, - "ServerlessRestApi": { + "MyApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { @@ -144,11 +169,11 @@ } }, "paths": { - "/implicit": { + "/get": { "Fn::If": [ "C1", { - "post": { + "put": { "Fn::If": [ "C1", { @@ -181,22 +206,36 @@ ] } }, - "swagger": "2.0" + "openapi": "3.0.1" } }, "Condition": "C1" }, - "MyApiDeployment9c28d20064": { + "ServerlessRestApiDeployment43c34b4e46": { "Type": "AWS::ApiGateway::Deployment", "Properties": { + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "Description": "RestApi deployment id: 43c34b4e46d381101dd94b95856a2cea244411b4", + "StageName": "Stage" + }, + "Condition": "C1" + }, + "MyApiProdStage": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "MyApiDeployment6e1ee39b06" + }, "RestApiId": { "Ref": "MyApi" }, - "Description": "RestApi deployment id: 9c28d20064b889d33964c909f03a6eb8da6b7c59" + "StageName": "Prod" }, "Condition": "C1" }, - "MyApi": { + "ServerlessRestApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { @@ -207,11 +246,11 @@ } }, "paths": { - "/get": { + "/implicit": { "Fn::If": [ "C1", { - "put": { + "post": { "Fn::If": [ "C1", { @@ -244,50 +283,11 @@ ] } }, - "openapi": "3.0.1" - } - }, - "Condition": "C1" - }, - "ApiGatewayDomainName2bd847e760": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "RegionalCertificateArn": "another-api-arn", - "DomainName": { - "Fn::Sub": "example-ap-southeast-1.com" + "swagger": "2.0" } }, "Condition": "C1" }, - "MyApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "MyApiDeployment9c28d20064" - }, - "RestApiId": { - "Ref": "MyApi" - }, - "StageName": "Prod" - }, - "Condition": "C1" - }, - "ServerlessRestApiDeployment43c34b4e46": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "Description": "RestApi deployment id: 43c34b4e46d381101dd94b95856a2cea244411b4", - "StageName": "Stage" - }, - "Condition": "C1" - }, "MyFunctionApiPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { diff --git a/tests/translator/output/aws-cn/api_with_basic_custom_domain.json b/tests/translator/output/aws-cn/api_with_basic_custom_domain.json index 3c670d96fa..889f4512a6 100644 --- a/tests/translator/output/aws-cn/api_with_basic_custom_domain.json +++ b/tests/translator/output/aws-cn/api_with_basic_custom_domain.json @@ -10,25 +10,26 @@ } }, "Resources": { - "MyFunctionImplicitGetPermissionProd": { - "Type": "AWS::Lambda::Permission", + "MyFunction": { + "Type": "AWS::Lambda::Function", "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "MyFunction" + "Handler": "index.handler", + "Code": { + "ZipFile": "exports.handler = async (event) => {\n const response = {\n statusCode: 200,\n body: JSON.stringify('Hello from Lambda!'),\n };\n return response;\n};\n" }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", - { - "__Stage__": "*", - "__ApiId__": { - "Ref": "ServerlessRestApi" - } - } + "Role": { + "Fn::GetAtt": [ + "MyFunctionRole", + "Arn" ] - } + }, + "Runtime": "nodejs8.10", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] } }, "MyFunctionAnotherGetPermissionProd": { @@ -52,79 +53,16 @@ } } }, - "MyAnotherApiBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", - "Properties": { - "DomainName": "another-example.com", - "RestApiId": { - "Ref": "MyAnotherApi" - }, - "Stage": { - "Ref": "MyAnotherApiProdStage" - } - } - }, - "ServerlessRestApiProdStage": { - "Type": "AWS::ApiGateway::Stage", + "MyApiDeploymentf93c9d77b0": { + "Type": "AWS::ApiGateway::Deployment", "Properties": { - "DeploymentId": { - "Ref": "ServerlessRestApiDeploymentab9e1a0920" - }, "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "StageName": "Prod" - } - }, - "MyApi": { - "Type": "AWS::ApiGateway::RestApi", - "Properties": { - "Body": { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/get": { - "put": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" - } - }, - "responses": {} - } - }, - "/fetch": { - "post": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" - } - }, - "responses": {} - } - } - }, - "openapi": "3.0.1" - }, - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] + "Ref": "MyApi" }, - "Parameters": { - "endpointConfigurationTypes": "REGIONAL" - } + "Description": "RestApi deployment id: f93c9d77b03a49d41597a99e8aaecf51eb585698" } }, - "ApiGatewayDomainName461285836f": { + "ApiGatewayDomainName23cdccdf9c": { "Type": "AWS::ApiGateway::DomainName", "Properties": { "CertificateArn": "my-api-cert-arn", @@ -136,69 +74,37 @@ "DomainName": "api-example.com" } }, - "MyAnotherApiDeployment97cd66ec36": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "MyAnotherApi" - }, - "Description": "RestApi deployment id: 97cd66ec36e6bcd41a2cb4568a77d6fd88c99db9" - } - }, - "ApiGatewayDomainNamed12ce5c759": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "RegionalCertificateArn": "another-api-arn", - "DomainName": "another-example.com" - } - }, - "ServerlessRestApiDeploymentab9e1a0920": { - "Type": "AWS::ApiGateway::Deployment", + "MyFunctionImplicitGetPermissionProd": { + "Type": "AWS::Lambda::Permission", "Properties": { - "RestApiId": { - "Ref": "ServerlessRestApi" + "Action": "lambda:invokeFunction", + "Principal": "apigateway.amazonaws.com", + "FunctionName": { + "Ref": "MyFunction" }, - "Description": "RestApi deployment id: ab9e1a092083a857077258033574270d894a8551", - "StageName": "Stage" - } - }, - "ApiGatewayDomainName7a5525b8a3": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" + "SourceArn": { + "Fn::Sub": [ + "arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", + { + "__Stage__": "*", + "__ApiId__": { + "Ref": "ServerlessRestApi" + } + } ] - }, - "RegionalCertificateArn": "another-api-arn", - "DomainName": "another-example.com" + } } }, - "MyFunction": { - "Type": "AWS::Lambda::Function", + "MyAnotherApiProdStage": { + "Type": "AWS::ApiGateway::Stage", "Properties": { - "Handler": "index.handler", - "Code": { - "ZipFile": "exports.handler = async (event) => {\n const response = {\n statusCode: 200,\n body: JSON.stringify('Hello from Lambda!'),\n };\n return response;\n};\n" + "DeploymentId": { + "Ref": "MyAnotherApiDeployment78a7819e1c" }, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] + "RestApiId": { + "Ref": "MyAnotherApi" }, - "Runtime": "nodejs8.10", - "Tags": [ - { - "Value": "SAM", - "Key": "lambda:createdBy" - } - ] + "StageName": "Prod" } }, "MyFunctionFetchPermissionProd": { @@ -222,39 +128,6 @@ } } }, - "MyApiDeploymentf9af62f948": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "MyApi" - }, - "Description": "RestApi deployment id: f9af62f9487c3b8737c3b40e1edaf7a1549eb5f6" - } - }, - "ServerlessRestApiBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", - "Properties": { - "DomainName": "another-example.com", - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "Stage": { - "Ref": "ServerlessRestApiProdStage" - } - } - }, - "MyAnotherApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "MyAnotherApiDeployment97cd66ec36" - }, - "RestApiId": { - "Ref": "MyAnotherApi" - }, - "StageName": "Prod" - } - }, "MyAnotherApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { @@ -341,11 +214,126 @@ } } }, + "MyApi": { + "Type": "AWS::ApiGateway::RestApi", + "Properties": { + "Body": { + "info": { + "version": "1.0", + "title": { + "Ref": "AWS::StackName" + } + }, + "paths": { + "/get": { + "put": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" + } + }, + "responses": {} + } + }, + "/fetch": { + "post": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" + } + }, + "responses": {} + } + } + }, + "openapi": "3.0.1" + }, + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "Parameters": { + "endpointConfigurationTypes": "REGIONAL" + } + } + }, + "MyAnotherApiBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", + "Properties": { + "DomainName": "another-example.com", + "RestApiId": { + "Ref": "MyAnotherApi" + }, + "Stage": { + "Ref": "MyAnotherApiProdStage" + } + } + }, + "ApiGatewayDomainNameeab65c1531": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": "another-api-arn", + "DomainName": "another-example.com" + } + }, + "ServerlessRestApiDeployment06e2333f46": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "Description": "RestApi deployment id: 06e2333f46f9e8ce75b6d105e0fb5b1b7fed3aca", + "StageName": "Stage" + } + }, + "MyAnotherApiDeployment78a7819e1c": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "MyAnotherApi" + }, + "Description": "RestApi deployment id: 78a7819e1cd42aa753a8dfc29d0026d44aaf6335" + } + }, + "ServerlessRestApiProdStage": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "ServerlessRestApiDeployment06e2333f46" + }, + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "StageName": "Prod" + } + }, + "ServerlessRestApiBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", + "Properties": { + "DomainName": "another-example.com", + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "Stage": { + "Ref": "ServerlessRestApiProdStage" + } + } + }, "MyApiProdStage": { "Type": "AWS::ApiGateway::Stage", "Properties": { "DeploymentId": { - "Ref": "MyApiDeploymentf9af62f948" + "Ref": "MyApiDeploymentf93c9d77b0" }, "RestApiId": { "Ref": "MyApi" diff --git a/tests/translator/output/aws-cn/api_with_basic_custom_domain_intrinsics.json b/tests/translator/output/aws-cn/api_with_basic_custom_domain_intrinsics.json index 0e5bcb8798..f3efb64927 100644 --- a/tests/translator/output/aws-cn/api_with_basic_custom_domain_intrinsics.json +++ b/tests/translator/output/aws-cn/api_with_basic_custom_domain_intrinsics.json @@ -92,6 +92,16 @@ }, "Condition": "C1" }, + "MyApiDeploymentf260697bb0": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "MyApi" + }, + "Description": "RestApi deployment id: f260697bb02eda112f7c58d850cf875f82e745a4" + }, + "Condition": "C1" + }, "ServerlessRestApiDeployment599c0b434d": { "Type": "AWS::ApiGateway::Deployment", "Properties": { @@ -144,16 +154,6 @@ }, "Condition": "C1" }, - "MyApiDeployment616cc3af2f": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "MyApi" - }, - "Description": "RestApi deployment id: 616cc3af2fced60efa5a5e30524f22ab69d68dd3" - }, - "Condition": "C1" - }, "MyApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { @@ -215,7 +215,20 @@ }, "Condition": "C1" }, - "ApiGatewayDomainName4bfafc5803": { + "MyApiProdStage": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "MyApiDeploymentf260697bb0" + }, + "RestApiId": { + "Ref": "MyApi" + }, + "StageName": "Prod" + }, + "Condition": "C1" + }, + "ApiGatewayDomainNamec0cd2d9dfc": { "Type": "AWS::ApiGateway::DomainName", "Properties": { "EndpointConfiguration": { @@ -230,19 +243,6 @@ }, "Condition": "C1" }, - "MyApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "MyApiDeployment616cc3af2f" - }, - "RestApiId": { - "Ref": "MyApi" - }, - "StageName": "Prod" - }, - "Condition": "C1" - }, "ServerlessRestApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { diff --git a/tests/translator/output/aws-us-gov/api_with_basic_custom_domain.json b/tests/translator/output/aws-us-gov/api_with_basic_custom_domain.json index 53a0f661a5..2ba58f4ad5 100644 --- a/tests/translator/output/aws-us-gov/api_with_basic_custom_domain.json +++ b/tests/translator/output/aws-us-gov/api_with_basic_custom_domain.json @@ -10,25 +10,26 @@ } }, "Resources": { - "MyFunctionImplicitGetPermissionProd": { - "Type": "AWS::Lambda::Permission", + "MyFunction": { + "Type": "AWS::Lambda::Function", "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "MyFunction" + "Handler": "index.handler", + "Code": { + "ZipFile": "exports.handler = async (event) => {\n const response = {\n statusCode: 200,\n body: JSON.stringify('Hello from Lambda!'),\n };\n return response;\n};\n" }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", - { - "__Stage__": "*", - "__ApiId__": { - "Ref": "ServerlessRestApi" - } - } + "Role": { + "Fn::GetAtt": [ + "MyFunctionRole", + "Arn" ] - } + }, + "Runtime": "nodejs8.10", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] } }, "MyFunctionAnotherGetPermissionProd": { @@ -52,74 +53,73 @@ } } }, - "MyAnotherApiBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", - "Properties": { - "DomainName": "another-example.com", - "RestApiId": { - "Ref": "MyAnotherApi" - }, - "Stage": { - "Ref": "MyAnotherApiProdStage" - } - } - }, - "ServerlessRestApiProdStage": { + "MyApiProdStage": { "Type": "AWS::ApiGateway::Stage", "Properties": { "DeploymentId": { - "Ref": "ServerlessRestApiDeploymentdb4e2ac130" + "Ref": "MyApiDeploymentf3135fd1a7" }, "RestApiId": { - "Ref": "ServerlessRestApi" + "Ref": "MyApi" }, "StageName": "Prod" } }, - "ServerlessRestApiDeploymentdb4e2ac130": { - "Type": "AWS::ApiGateway::Deployment", + "MyFunctionImplicitGetPermissionProd": { + "Type": "AWS::Lambda::Permission", "Properties": { - "RestApiId": { - "Ref": "ServerlessRestApi" + "Action": "lambda:invokeFunction", + "Principal": "apigateway.amazonaws.com", + "FunctionName": { + "Ref": "MyFunction" }, - "Description": "RestApi deployment id: db4e2ac130d60a5397755c9e502cd2df4deca9a0", - "StageName": "Stage" + "SourceArn": { + "Fn::Sub": [ + "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", + { + "__Stage__": "*", + "__ApiId__": { + "Ref": "ServerlessRestApi" + } + } + ] + } } }, - "MyAnotherApiDeployment0dc7a651a5": { - "Type": "AWS::ApiGateway::Deployment", + "MyAnotherApiProdStage": { + "Type": "AWS::ApiGateway::Stage", "Properties": { + "DeploymentId": { + "Ref": "MyAnotherApiDeployment836d746e1a" + }, "RestApiId": { "Ref": "MyAnotherApi" }, - "Description": "RestApi deployment id: 0dc7a651a5be25f8dcd62b4fca4ae881e8151bd0" + "StageName": "Prod" } }, - "ApiGatewayDomainName461285836f": { - "Type": "AWS::ApiGateway::DomainName", + "MyFunctionFetchPermissionProd": { + "Type": "AWS::Lambda::Permission", "Properties": { - "CertificateArn": "my-api-cert-arn", - "EndpointConfiguration": { - "Types": [ - "EDGE" - ] + "Action": "lambda:invokeFunction", + "Principal": "apigateway.amazonaws.com", + "FunctionName": { + "Ref": "MyFunction" }, - "DomainName": "api-example.com" - } - }, - "ApiGatewayDomainNamed12ce5c759": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" + "SourceArn": { + "Fn::Sub": [ + "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch", + { + "__Stage__": "*", + "__ApiId__": { + "Ref": "MyApi" + } + } ] - }, - "RegionalCertificateArn": "another-api-arn", - "DomainName": "another-example.com" + } } }, - "MyApi": { + "MyAnotherApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { @@ -130,19 +130,7 @@ } }, "paths": { - "/get": { - "put": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws-us-gov:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" - } - }, - "responses": {} - } - }, - "/fetch": { + "/another/get": { "post": { "x-amazon-apigateway-integration": { "httpMethod": "POST", @@ -167,95 +155,57 @@ } } }, - "ApiGatewayDomainName7a5525b8a3": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "RegionalCertificateArn": "another-api-arn", - "DomainName": "another-example.com" - } - }, - "MyApiDeployment6d0cb977c8": { - "Type": "AWS::ApiGateway::Deployment", + "MyApifetchBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { + "BasePath": "fetch", + "DomainName": "api-example.com", "RestApiId": { "Ref": "MyApi" }, - "Description": "RestApi deployment id: 6d0cb977c8290881fb8b3f75bae7116d04a23782" - } - }, - "MyFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Handler": "index.handler", - "Code": { - "ZipFile": "exports.handler = async (event) => {\n const response = {\n statusCode: 200,\n body: JSON.stringify('Hello from Lambda!'),\n };\n return response;\n};\n" - }, - "Role": { - "Fn::GetAtt": [ - "MyFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs8.10", - "Tags": [ - { - "Value": "SAM", - "Key": "lambda:createdBy" - } - ] + "Stage": { + "Ref": "MyApiProdStage" + } } }, - "MyFunctionFetchPermissionProd": { - "Type": "AWS::Lambda::Permission", + "MyFunctionRole": { + "Type": "AWS::IAM::Role", "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "MyFunction" - }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch", + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ { - "__Stage__": "*", - "__ApiId__": { - "Ref": "MyApi" + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] } } ] } } }, - "ServerlessRestApiBasePathMapping": { + "MyApigetBasePathMapping": { "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { - "DomainName": "another-example.com", + "BasePath": "get", + "DomainName": "api-example.com", "RestApiId": { - "Ref": "ServerlessRestApi" + "Ref": "MyApi" }, "Stage": { - "Ref": "ServerlessRestApiProdStage" + "Ref": "MyApiProdStage" } } }, - "MyAnotherApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "MyAnotherApiDeployment0dc7a651a5" - }, - "RestApiId": { - "Ref": "MyAnotherApi" - }, - "StageName": "Prod" - } - }, - "MyAnotherApi": { + "ServerlessRestApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { @@ -266,7 +216,7 @@ } }, "paths": { - "/another/get": { + "/implicit": { "post": { "x-amazon-apigateway-integration": { "httpMethod": "POST", @@ -279,7 +229,7 @@ } } }, - "openapi": "3.0.1" + "swagger": "2.0" }, "EndpointConfiguration": { "Types": [ @@ -291,69 +241,86 @@ } } }, - "MyApifetchBasePathMapping": { + "MyAnotherApiBasePathMapping": { "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { - "BasePath": "fetch", - "DomainName": "api-example.com", + "DomainName": "another-example.com", "RestApiId": { - "Ref": "MyApi" + "Ref": "MyAnotherApi" }, "Stage": { - "Ref": "MyApiProdStage" + "Ref": "MyAnotherApiProdStage" } } }, - "MyFunctionRole": { - "Type": "AWS::IAM::Role", + "ApiGatewayDomainNameeab65c1531": { + "Type": "AWS::ApiGateway::DomainName", "Properties": { - "ManagedPolicyArns": [ - "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], - "AssumeRolePolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Action": [ - "sts:AssumeRole" - ], - "Effect": "Allow", - "Principal": { - "Service": [ - "lambda.amazonaws.com" - ] - } - } + "EndpointConfiguration": { + "Types": [ + "REGIONAL" ] - } + }, + "RegionalCertificateArn": "another-api-arn", + "DomainName": "another-example.com" } }, - "MyApigetBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", + "ServerlessRestApiDeployment850347783d": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "Description": "RestApi deployment id: 850347783d64d7c9e7f9528c3e117f7b29ef8bd9", + "StageName": "Stage" + } + }, + "MyApiDeploymentf3135fd1a7": { + "Type": "AWS::ApiGateway::Deployment", "Properties": { - "BasePath": "get", - "DomainName": "api-example.com", "RestApiId": { "Ref": "MyApi" }, - "Stage": { - "Ref": "MyApiProdStage" - } + "Description": "RestApi deployment id: f3135fd1a745bd03eb49425618a88b1a2ca1c06e" } }, - "MyApiProdStage": { + "ServerlessRestApiProdStage": { "Type": "AWS::ApiGateway::Stage", "Properties": { "DeploymentId": { - "Ref": "MyApiDeployment6d0cb977c8" + "Ref": "ServerlessRestApiDeployment850347783d" }, "RestApiId": { - "Ref": "MyApi" + "Ref": "ServerlessRestApi" }, "StageName": "Prod" } }, - "ServerlessRestApi": { + "ServerlessRestApiBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", + "Properties": { + "DomainName": "another-example.com", + "RestApiId": { + "Ref": "ServerlessRestApi" + }, + "Stage": { + "Ref": "ServerlessRestApiProdStage" + } + } + }, + "ApiGatewayDomainName23cdccdf9c": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "CertificateArn": "my-api-cert-arn", + "EndpointConfiguration": { + "Types": [ + "EDGE" + ] + }, + "DomainName": "api-example.com" + } + }, + "MyApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { @@ -364,7 +331,19 @@ } }, "paths": { - "/implicit": { + "/get": { + "put": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:aws-us-gov:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" + } + }, + "responses": {} + } + }, + "/fetch": { "post": { "x-amazon-apigateway-integration": { "httpMethod": "POST", @@ -377,7 +356,7 @@ } } }, - "swagger": "2.0" + "openapi": "3.0.1" }, "EndpointConfiguration": { "Types": [ @@ -389,6 +368,15 @@ } } }, + "MyAnotherApiDeployment836d746e1a": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "MyAnotherApi" + }, + "Description": "RestApi deployment id: 836d746e1af20f1dcc2c03b81a12a53828bf22e4" + } + }, "MyFunctionApiPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { diff --git a/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_intrinsics.json b/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_intrinsics.json index 5852d397ea..217a892907 100644 --- a/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_intrinsics.json +++ b/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_intrinsics.json @@ -63,18 +63,13 @@ }, "Condition": "C1" }, - "ApiGatewayDomainNamedf402213e0": { - "Type": "AWS::ApiGateway::DomainName", + "MyApiDeployment49388946f5": { + "Type": "AWS::ApiGateway::Deployment", "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] + "RestApiId": { + "Ref": "MyApi" }, - "RegionalCertificateArn": "another-api-arn", - "DomainName": { - "Fn::Sub": "example-us-gov-west-1.com" - } + "Description": "RestApi deployment id: 49388946f5e0e030c3139bb3f1b984fba94bbc84" }, "Condition": "C1" }, @@ -159,6 +154,21 @@ }, "Condition": "C1" }, + "ApiGatewayDomainName9c93aac102": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": "another-api-arn", + "DomainName": { + "Fn::Sub": "example-us-gov-west-1.com" + } + }, + "Condition": "C1" + }, "MyApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { @@ -220,21 +230,11 @@ }, "Condition": "C1" }, - "MyApiDeployment0ba140d008": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "MyApi" - }, - "Description": "RestApi deployment id: 0ba140d00843cdd83115b4d663463aa0f21c4fef" - }, - "Condition": "C1" - }, "MyApiProdStage": { "Type": "AWS::ApiGateway::Stage", "Properties": { "DeploymentId": { - "Ref": "MyApiDeployment0ba140d008" + "Ref": "MyApiDeployment49388946f5" }, "RestApiId": { "Ref": "MyApi" From ddff359533a3588239d82f22961d82b8e5b56e8f Mon Sep 17 00:00:00 2001 From: praneetap Date: Sat, 28 Sep 2019 00:19:21 -0700 Subject: [PATCH 4/4] add docs and fix tests --- .../api_with_custom_domain_route53.json | 269 +++++++---------- .../api_with_custom_domain_route53.json | 279 +++++++----------- .../api_with_custom_domain_route53.json | 279 +++++++----------- versions/2016-10-31.md | 12 +- 4 files changed, 314 insertions(+), 525 deletions(-) diff --git a/tests/translator/output/api_with_custom_domain_route53.json b/tests/translator/output/api_with_custom_domain_route53.json index f6328fea0f..fca043de36 100644 --- a/tests/translator/output/api_with_custom_domain_route53.json +++ b/tests/translator/output/api_with_custom_domain_route53.json @@ -1,15 +1,11 @@ { "Parameters": { - "MyHostedZone": { - "Default": "myregionalhostedzoneid", + "ACMCertificateArn": { + "Default": "cert-arn-in-us-east-1", "Type": "String" }, - "MyDomainName": { - "Default": "api-edge.com", - "Type": "String" - }, - "MyDomainCert": { - "Default": "my-edge-api-arn", + "DomainName": { + "Default": "example.com", "Type": "String" } }, @@ -36,7 +32,7 @@ ] } }, - "MyFunctionImplicitGetPermissionProd": { + "MyFunctionFetchPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:invokeFunction", @@ -46,109 +42,146 @@ }, "SourceArn": { "Fn::Sub": [ - "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", + "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch", { "__Stage__": "*", "__ApiId__": { - "Ref": "ServerlessRestApi" + "Ref": "MyApi" } } ] } } }, - "RecordSetGroup2102f285a7": { + "ApiGatewayDomainName0caaf24ab1": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "CertificateArn": "cert-arn-in-us-east-1", + "EndpointConfiguration": { + "Types": [ + "EDGE" + ] + }, + "DomainName": "example.com" + } + }, + "MyApiProdStage": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "MyApiDeployment967cf1a6ff" + }, + "RestApiId": { + "Ref": "MyApi" + }, + "StageName": "Prod" + } + }, + "RecordSetGroupbd00d962a4": { "Type": "AWS::Route53::RecordSetGroup", "Properties": { - "HostedZoneId": "myregionalhostedzoneid", + "HostedZoneId": "ZQ1UAL4EFZVME", "RecordSets": [ { "AliasTarget": { - "EvaluateTargetHealth": true, - "HostedZoneId": { + "HostedZoneId": "Z2FDTNDATAQYW2", + "DNSName": { "Fn::GetAtt": [ - "ApiGatewayDomainNameb4325e3ba6", - "RegionalHostedZoneId" + "Distribution", + "DomainName" ] - }, + } + }, + "Type": "A", + "Name": "example.com" + }, + { + "AliasTarget": { + "HostedZoneId": "Z2FDTNDATAQYW2", "DNSName": { "Fn::GetAtt": [ - "ApiGatewayDomainNameb4325e3ba6", - "RegionalDomainName" + "Distribution", + "DomainName" ] } }, - "Type": "A", - "Name": "api-edge.com" + "Type": "AAAA", + "Name": "example.com" } ] } }, - "ServerlessRestApiBasePathMapping": { + "MyApifetchBasePathMapping": { "Type": "AWS::ApiGateway::BasePathMapping", "Properties": { - "DomainName": "api-edge.com", + "BasePath": "fetch", + "DomainName": "example.com", "RestApiId": { - "Ref": "ServerlessRestApi" + "Ref": "MyApi" }, "Stage": { - "Ref": "ServerlessRestApiProdStage" + "Ref": "MyApiProdStage" } } }, - "MyFunctionFetchPermissionProd": { - "Type": "AWS::Lambda::Permission", + "Distribution": { + "Type": "AWS::CloudFront::Distribution", "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "MyFunction" - }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch/another", + "DistributionConfig": { + "Origins": [ { - "__Stage__": "*", - "__ApiId__": { - "Ref": "MyApi" + "DomainName": { + "Ref": "DomainName" + }, + "Id": { + "Ref": "DomainName" + }, + "CustomOriginConfig": { + "OriginProtocolPolicy": "https-only", + "HTTPPort": 80, + "HTTPSPort": 443 } } - ] + ], + "PriceClass": "PriceClass_100", + "Enabled": true, + "DefaultCacheBehavior": { + "Compress": true, + "TargetOriginId": { + "Ref": "DomainName" + }, + "ViewerProtocolPolicy": "redirect-to-https", + "ForwardedValues": { + "QueryString": false + }, + "SmoothStreaming": false, + "AllowedMethods": [ + "HEAD", + "DELETE", + "POST", + "GET", + "OPTIONS", + "PUT", + "PATCH" + ] + }, + "ViewerCertificate": { + "SslSupportMethod": "sni-only", + "AcmCertificateArn": { + "Ref": "ACMCertificateArn" + } + }, + "HttpVersion": "http2" } } }, - "ServerlessRestApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "ServerlessRestApiDeployment5332408c06" - }, - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "StageName": "Prod" - } - }, - "MyApiDeploymentb23755fe76": { + "MyApiDeployment967cf1a6ff": { "Type": "AWS::ApiGateway::Deployment", "Properties": { "RestApiId": { "Ref": "MyApi" }, - "Description": "RestApi deployment id: b23755fe76eda84d559e1656bb6251c157662141" - } - }, - "MyApifetchBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", - "Properties": { - "BasePath": "fetch", - "DomainName": "api-regional.com", - "RestApiId": { - "Ref": "MyApi" - }, - "Stage": { - "Ref": "MyApiProdStage" - } + "Description": "RestApi deployment id: 967cf1a6ff8e58a6e739bf5b7b59a7d658e01a40" } }, "MyFunctionRole": { @@ -175,42 +208,6 @@ } } }, - "RecordSetGroup3505b49f8a": { - "Type": "AWS::Route53::RecordSetGroup", - "Properties": { - "HostedZoneId": "my-edge-hosted-zone", - "RecordSets": [ - { - "AliasTarget": { - "EvaluateTargetHealth": true, - "HostedZoneId": "Z2FDTNDATAQYW2", - "DNSName": "api-regional.com" - }, - "Type": "AAAA", - "Name": "api-regional.com" - }, - { - "AliasTarget": { - "EvaluateTargetHealth": true, - "HostedZoneId": "Z2FDTNDATAQYW2", - "DNSName": "api-regional.com" - }, - "Type": "AAAA", - "Name": "api-regional.com" - } - ] - } - }, - "ServerlessRestApiDeployment5332408c06": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "Description": "RestApi deployment id: 5332408c060674292fe4785c8cfe8b3a70858887", - "StageName": "Stage" - } - }, "MyApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { @@ -222,7 +219,7 @@ } }, "paths": { - "/fetch/another": { + "/fetch": { "post": { "x-amazon-apigateway-integration": { "httpMethod": "POST", @@ -238,70 +235,6 @@ "openapi": "3.0.1" } } - }, - "ApiGatewayDomainNameb4325e3ba6": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "RegionalCertificateArn": "my-edge-api-arn", - "DomainName": "api-edge.com" - } - }, - "ApiGatewayDomainName80a04c0ec3": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "CertificateArn": "my-regional-cert-arn", - "EndpointConfiguration": { - "Types": [ - "EDGE" - ] - }, - "DomainName": "api-regional.com" - } - }, - "MyApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "MyApiDeploymentb23755fe76" - }, - "RestApiId": { - "Ref": "MyApi" - }, - "StageName": "Prod" - } - }, - "ServerlessRestApi": { - "Type": "AWS::ApiGateway::RestApi", - "Properties": { - "Body": { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/implicit": { - "post": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" - } - }, - "responses": {} - } - } - }, - "swagger": "2.0" - } - } } } } \ No newline at end of file diff --git a/tests/translator/output/aws-cn/api_with_custom_domain_route53.json b/tests/translator/output/aws-cn/api_with_custom_domain_route53.json index 6bc36b0083..30113d4e37 100644 --- a/tests/translator/output/aws-cn/api_with_custom_domain_route53.json +++ b/tests/translator/output/aws-cn/api_with_custom_domain_route53.json @@ -1,15 +1,11 @@ { "Parameters": { - "MyHostedZone": { - "Default": "myregionalhostedzoneid", + "ACMCertificateArn": { + "Default": "cert-arn-in-us-east-1", "Type": "String" }, - "MyDomainName": { - "Default": "api-edge.com", - "Type": "String" - }, - "MyDomainCert": { - "Default": "my-edge-api-arn", + "DomainName": { + "Default": "example.com", "Type": "String" } }, @@ -36,7 +32,7 @@ ] } }, - "MyFunctionImplicitGetPermissionProd": { + "MyFunctionFetchPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:invokeFunction", @@ -46,100 +42,146 @@ }, "SourceArn": { "Fn::Sub": [ - "arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", + "arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch", { "__Stage__": "*", "__ApiId__": { - "Ref": "ServerlessRestApi" + "Ref": "MyApi" } } ] } } }, - "RecordSetGroup2102f285a7": { + "ApiGatewayDomainName0caaf24ab1": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "CertificateArn": "cert-arn-in-us-east-1", + "EndpointConfiguration": { + "Types": [ + "EDGE" + ] + }, + "DomainName": "example.com" + } + }, + "MyApifetchBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", + "Properties": { + "BasePath": "fetch", + "DomainName": "example.com", + "RestApiId": { + "Ref": "MyApi" + }, + "Stage": { + "Ref": "MyApiProdStage" + } + } + }, + "RecordSetGroupbd00d962a4": { "Type": "AWS::Route53::RecordSetGroup", "Properties": { - "HostedZoneId": "myregionalhostedzoneid", + "HostedZoneId": "ZQ1UAL4EFZVME", "RecordSets": [ { "AliasTarget": { - "EvaluateTargetHealth": true, - "HostedZoneId": { + "HostedZoneId": "Z2FDTNDATAQYW2", + "DNSName": { "Fn::GetAtt": [ - "ApiGatewayDomainNameb4325e3ba6", - "RegionalHostedZoneId" + "Distribution", + "DomainName" ] - }, + } + }, + "Type": "A", + "Name": "example.com" + }, + { + "AliasTarget": { + "HostedZoneId": "Z2FDTNDATAQYW2", "DNSName": { "Fn::GetAtt": [ - "ApiGatewayDomainNameb4325e3ba6", - "RegionalDomainName" + "Distribution", + "DomainName" ] } }, - "Type": "A", - "Name": "api-edge.com" + "Type": "AAAA", + "Name": "example.com" } ] } }, - "ServerlessRestApiBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", + "MyApiDeployment22e6f8d813": { + "Type": "AWS::ApiGateway::Deployment", "Properties": { - "DomainName": "api-edge.com", "RestApiId": { - "Ref": "ServerlessRestApi" + "Ref": "MyApi" }, - "Stage": { - "Ref": "ServerlessRestApiProdStage" - } + "Description": "RestApi deployment id: 22e6f8d8130f68b2813a6e31d74b0ecccbf7820d" } }, - "MyFunctionFetchPermissionProd": { - "Type": "AWS::Lambda::Permission", + "Distribution": { + "Type": "AWS::CloudFront::Distribution", "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "MyFunction" - }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch/another", + "DistributionConfig": { + "Origins": [ { - "__Stage__": "*", - "__ApiId__": { - "Ref": "MyApi" + "DomainName": { + "Ref": "DomainName" + }, + "Id": { + "Ref": "DomainName" + }, + "CustomOriginConfig": { + "OriginProtocolPolicy": "https-only", + "HTTPPort": 80, + "HTTPSPort": 443 } } - ] + ], + "PriceClass": "PriceClass_100", + "Enabled": true, + "DefaultCacheBehavior": { + "Compress": true, + "TargetOriginId": { + "Ref": "DomainName" + }, + "ViewerProtocolPolicy": "redirect-to-https", + "ForwardedValues": { + "QueryString": false + }, + "SmoothStreaming": false, + "AllowedMethods": [ + "HEAD", + "DELETE", + "POST", + "GET", + "OPTIONS", + "PUT", + "PATCH" + ] + }, + "ViewerCertificate": { + "SslSupportMethod": "sni-only", + "AcmCertificateArn": { + "Ref": "ACMCertificateArn" + } + }, + "HttpVersion": "http2" } } }, - "ServerlessRestApiProdStage": { + "MyApiProdStage": { "Type": "AWS::ApiGateway::Stage", "Properties": { "DeploymentId": { - "Ref": "ServerlessRestApiDeployment538d879eb6" - }, - "RestApiId": { - "Ref": "ServerlessRestApi" + "Ref": "MyApiDeployment22e6f8d813" }, - "StageName": "Prod" - } - }, - "MyApifetchBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", - "Properties": { - "BasePath": "fetch", - "DomainName": "api-regional.com", "RestApiId": { "Ref": "MyApi" }, - "Stage": { - "Ref": "MyApiProdStage" - } + "StageName": "Prod" } }, "MyFunctionRole": { @@ -166,41 +208,6 @@ } } }, - "RecordSetGroup3505b49f8a": { - "Type": "AWS::Route53::RecordSetGroup", - "Properties": { - "HostedZoneId": "my-edge-hosted-zone", - "RecordSets": [ - { - "AliasTarget": { - "EvaluateTargetHealth": true, - "HostedZoneId": "Z2FDTNDATAQYW2", - "DNSName": "api-regional.com" - }, - "Type": "AAAA", - "Name": "api-regional.com" - }, - { - "AliasTarget": { - "EvaluateTargetHealth": true, - "HostedZoneId": "Z2FDTNDATAQYW2", - "DNSName": "api-regional.com" - }, - "Type": "AAAA", - "Name": "api-regional.com" - } - ] - } - }, - "MyApiDeploymentfa6919f89c": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "MyApi" - }, - "Description": "RestApi deployment id: fa6919f89c4b45e3f562e33a0a5b06b3f7dc93ae" - } - }, "MyApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { @@ -212,7 +219,7 @@ } }, "paths": { - "/fetch/another": { + "/fetch": { "post": { "x-amazon-apigateway-integration": { "httpMethod": "POST", @@ -236,88 +243,6 @@ "endpointConfigurationTypes": "REGIONAL" } } - }, - "ServerlessRestApiDeployment538d879eb6": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "Description": "RestApi deployment id: 538d879eb60b7bb6dff2551103783a7b29c4851d", - "StageName": "Stage" - } - }, - "ApiGatewayDomainNameb4325e3ba6": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "RegionalCertificateArn": "my-edge-api-arn", - "DomainName": "api-edge.com" - } - }, - "ApiGatewayDomainName80a04c0ec3": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "CertificateArn": "my-regional-cert-arn", - "EndpointConfiguration": { - "Types": [ - "EDGE" - ] - }, - "DomainName": "api-regional.com" - } - }, - "MyApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "MyApiDeploymentfa6919f89c" - }, - "RestApiId": { - "Ref": "MyApi" - }, - "StageName": "Prod" - } - }, - "ServerlessRestApi": { - "Type": "AWS::ApiGateway::RestApi", - "Properties": { - "Body": { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/implicit": { - "post": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" - } - }, - "responses": {} - } - } - }, - "swagger": "2.0" - }, - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "Parameters": { - "endpointConfigurationTypes": "REGIONAL" - } - } } } } \ No newline at end of file diff --git a/tests/translator/output/aws-us-gov/api_with_custom_domain_route53.json b/tests/translator/output/aws-us-gov/api_with_custom_domain_route53.json index b0c08ac44c..860a1a2bf3 100644 --- a/tests/translator/output/aws-us-gov/api_with_custom_domain_route53.json +++ b/tests/translator/output/aws-us-gov/api_with_custom_domain_route53.json @@ -1,15 +1,11 @@ { "Parameters": { - "MyHostedZone": { - "Default": "myregionalhostedzoneid", + "ACMCertificateArn": { + "Default": "cert-arn-in-us-east-1", "Type": "String" }, - "MyDomainName": { - "Default": "api-edge.com", - "Type": "String" - }, - "MyDomainCert": { - "Default": "my-edge-api-arn", + "DomainName": { + "Default": "example.com", "Type": "String" } }, @@ -36,7 +32,7 @@ ] } }, - "MyFunctionImplicitGetPermissionProd": { + "MyFunctionFetchPermissionProd": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:invokeFunction", @@ -46,100 +42,146 @@ }, "SourceArn": { "Fn::Sub": [ - "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit", + "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch", { "__Stage__": "*", "__ApiId__": { - "Ref": "ServerlessRestApi" + "Ref": "MyApi" } } ] } } }, - "RecordSetGroup2102f285a7": { + "ApiGatewayDomainName0caaf24ab1": { + "Type": "AWS::ApiGateway::DomainName", + "Properties": { + "CertificateArn": "cert-arn-in-us-east-1", + "EndpointConfiguration": { + "Types": [ + "EDGE" + ] + }, + "DomainName": "example.com" + } + }, + "MyApifetchBasePathMapping": { + "Type": "AWS::ApiGateway::BasePathMapping", + "Properties": { + "BasePath": "fetch", + "DomainName": "example.com", + "RestApiId": { + "Ref": "MyApi" + }, + "Stage": { + "Ref": "MyApiProdStage" + } + } + }, + "RecordSetGroupbd00d962a4": { "Type": "AWS::Route53::RecordSetGroup", "Properties": { - "HostedZoneId": "myregionalhostedzoneid", + "HostedZoneId": "ZQ1UAL4EFZVME", "RecordSets": [ { "AliasTarget": { - "EvaluateTargetHealth": true, - "HostedZoneId": { + "HostedZoneId": "Z2FDTNDATAQYW2", + "DNSName": { "Fn::GetAtt": [ - "ApiGatewayDomainNameb4325e3ba6", - "RegionalHostedZoneId" + "Distribution", + "DomainName" ] - }, + } + }, + "Type": "A", + "Name": "example.com" + }, + { + "AliasTarget": { + "HostedZoneId": "Z2FDTNDATAQYW2", "DNSName": { "Fn::GetAtt": [ - "ApiGatewayDomainNameb4325e3ba6", - "RegionalDomainName" + "Distribution", + "DomainName" ] } }, - "Type": "A", - "Name": "api-edge.com" + "Type": "AAAA", + "Name": "example.com" } ] } }, - "ServerlessRestApiBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", + "MyApiDeploymentf3b0901355": { + "Type": "AWS::ApiGateway::Deployment", "Properties": { - "DomainName": "api-edge.com", "RestApiId": { - "Ref": "ServerlessRestApi" + "Ref": "MyApi" }, - "Stage": { - "Ref": "ServerlessRestApiProdStage" - } + "Description": "RestApi deployment id: f3b0901355f3d895ddaa0964df0aef6171c1d400" } }, - "MyFunctionFetchPermissionProd": { - "Type": "AWS::Lambda::Permission", + "Distribution": { + "Type": "AWS::CloudFront::Distribution", "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "MyFunction" - }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch/another", + "DistributionConfig": { + "Origins": [ { - "__Stage__": "*", - "__ApiId__": { - "Ref": "MyApi" + "DomainName": { + "Ref": "DomainName" + }, + "Id": { + "Ref": "DomainName" + }, + "CustomOriginConfig": { + "OriginProtocolPolicy": "https-only", + "HTTPPort": 80, + "HTTPSPort": 443 } } - ] + ], + "PriceClass": "PriceClass_100", + "Enabled": true, + "DefaultCacheBehavior": { + "Compress": true, + "TargetOriginId": { + "Ref": "DomainName" + }, + "ViewerProtocolPolicy": "redirect-to-https", + "ForwardedValues": { + "QueryString": false + }, + "SmoothStreaming": false, + "AllowedMethods": [ + "HEAD", + "DELETE", + "POST", + "GET", + "OPTIONS", + "PUT", + "PATCH" + ] + }, + "ViewerCertificate": { + "SslSupportMethod": "sni-only", + "AcmCertificateArn": { + "Ref": "ACMCertificateArn" + } + }, + "HttpVersion": "http2" } } }, - "ServerlessRestApiProdStage": { + "MyApiProdStage": { "Type": "AWS::ApiGateway::Stage", "Properties": { "DeploymentId": { - "Ref": "ServerlessRestApiDeploymentc7f91ee60c" - }, - "RestApiId": { - "Ref": "ServerlessRestApi" + "Ref": "MyApiDeploymentf3b0901355" }, - "StageName": "Prod" - } - }, - "MyApifetchBasePathMapping": { - "Type": "AWS::ApiGateway::BasePathMapping", - "Properties": { - "BasePath": "fetch", - "DomainName": "api-regional.com", "RestApiId": { "Ref": "MyApi" }, - "Stage": { - "Ref": "MyApiProdStage" - } + "StageName": "Prod" } }, "MyFunctionRole": { @@ -166,32 +208,6 @@ } } }, - "RecordSetGroup3505b49f8a": { - "Type": "AWS::Route53::RecordSetGroup", - "Properties": { - "HostedZoneId": "my-edge-hosted-zone", - "RecordSets": [ - { - "AliasTarget": { - "EvaluateTargetHealth": true, - "HostedZoneId": "Z2FDTNDATAQYW2", - "DNSName": "api-regional.com" - }, - "Type": "AAAA", - "Name": "api-regional.com" - }, - { - "AliasTarget": { - "EvaluateTargetHealth": true, - "HostedZoneId": "Z2FDTNDATAQYW2", - "DNSName": "api-regional.com" - }, - "Type": "AAAA", - "Name": "api-regional.com" - } - ] - } - }, "MyApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { @@ -203,7 +219,7 @@ } }, "paths": { - "/fetch/another": { + "/fetch": { "post": { "x-amazon-apigateway-integration": { "httpMethod": "POST", @@ -227,97 +243,6 @@ "endpointConfigurationTypes": "REGIONAL" } } - }, - "MyApiDeploymentece2396345": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "MyApi" - }, - "Description": "RestApi deployment id: ece23963453cba09e1dd80334d4ea64521c62c39" - } - }, - "ServerlessRestApiDeploymentc7f91ee60c": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "Description": "RestApi deployment id: c7f91ee60c6682d93d33ed09ae55ece2400e3469", - "StageName": "Stage" - } - }, - "ApiGatewayDomainNameb4325e3ba6": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "RegionalCertificateArn": "my-edge-api-arn", - "DomainName": "api-edge.com" - } - }, - "ApiGatewayDomainName80a04c0ec3": { - "Type": "AWS::ApiGateway::DomainName", - "Properties": { - "CertificateArn": "my-regional-cert-arn", - "EndpointConfiguration": { - "Types": [ - "EDGE" - ] - }, - "DomainName": "api-regional.com" - } - }, - "MyApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "MyApiDeploymentece2396345" - }, - "RestApiId": { - "Ref": "MyApi" - }, - "StageName": "Prod" - } - }, - "ServerlessRestApi": { - "Type": "AWS::ApiGateway::RestApi", - "Properties": { - "Body": { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/implicit": { - "post": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws-us-gov:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" - } - }, - "responses": {} - } - } - }, - "swagger": "2.0" - }, - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "Parameters": { - "endpointConfigurationTypes": "REGIONAL" - } - } } } } \ No newline at end of file diff --git a/versions/2016-10-31.md b/versions/2016-10-31.md index 7b204bc197..03c5067d68 100644 --- a/versions/2016-10-31.md +++ b/versions/2016-10-31.md @@ -996,7 +996,13 @@ Enable custom domains to be configured with your Api. Currently only supports Cr ```yaml Domain: - DomainName: "example.com" # REQUIRED - CertificateARN: "" # REQUIRED | Must be a valid certificate ARN, and for EDGE endpoint configuration the certificate must be in us-east-1 + DomainName: String # REQUIRED | custom domain name being configured on the api, "www.example.com" + CertificateARN: String # REQUIRED | Must be a valid [certificate ARN](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-certificatemanager-certificate.html), and for EDGE endpoint configuration the certificate must be in us-east-1 EndpointConfiguration: "EDGE" # optional | Default value is REGIONAL | Accepted values are EDGE | REGIONAL - BasePath: ["/foo"] # optional | Default value is '/' | List of basepaths to be configured with the ApiGateway Domain Name \ No newline at end of file + BasePath: + - String # optional | Default value is '/' | List of basepaths to be configured with the ApiGateway Domain Name + Route53: # optional | Default behavior is to treat as None - does not create Route53 resources | Enable these settings to create Route53 Recordsets + HostedZoneId: String # REQUIRED | Must be a hostedzoneid value of a [`AWS::Route53::HostedZone`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-route53-hostedzone.html) resource + EvaluateTargetHealth: Boolean # optional | default value is false + DistributionDomainName: String # REQUIRED IF the EndpointConfiguration is EDGE | Domain name of a [cloudfront distribution](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudfront-distribution.html) is required to create Route53 recordsets +``` \ No newline at end of file