From 1aa7981b66c1dde3dd55b552ff27343f8f85b948 Mon Sep 17 00:00:00 2001 From: Sam Liu Date: Wed, 31 Aug 2022 15:33:21 -0700 Subject: [PATCH 1/2] Support "Name" for AWS::Serverless::HttpApi --- samtranslator/model/api/http_api_generator.py | 24 +++ samtranslator/model/apigatewayv2.py | 1 + samtranslator/model/sam_resources.py | 2 + samtranslator/open_api/open_api.py | 12 +- tests/model/api/test_http_api_generator.py | 2 + .../input/explicit_http_api_with_name.yaml | 26 +++ .../aws-cn/explicit_http_api_with_name.json | 195 ++++++++++++++++++ .../explicit_http_api_with_name.json | 195 ++++++++++++++++++ .../output/explicit_http_api_with_name.json | 195 ++++++++++++++++++ tests/translator/test_translator.py | 1 + 10 files changed, 652 insertions(+), 1 deletion(-) create mode 100644 tests/translator/input/explicit_http_api_with_name.yaml create mode 100644 tests/translator/output/aws-cn/explicit_http_api_with_name.json create mode 100644 tests/translator/output/aws-us-gov/explicit_http_api_with_name.json create mode 100644 tests/translator/output/explicit_http_api_with_name.json diff --git a/samtranslator/model/api/http_api_generator.py b/samtranslator/model/api/http_api_generator.py index 9b223248b..215f8fc75 100644 --- a/samtranslator/model/api/http_api_generator.py +++ b/samtranslator/model/api/http_api_generator.py @@ -37,6 +37,7 @@ def __init__( depends_on, definition_body, definition_uri, + name, stage_name, tags=None, auth=None, @@ -72,6 +73,7 @@ def __init__( self.definition_body = definition_body self.definition_uri = definition_uri self.stage_name = stage_name + self.name = name if not self.stage_name: self.stage_name = DefaultStageName self.auth = auth @@ -112,6 +114,7 @@ def _construct_http_api(self): if self.disable_execute_api_endpoint is not None: self._add_endpoint_configuration() + self._add_title() self._add_description() if self.definition_uri: @@ -635,6 +638,27 @@ def _add_description(self): open_api_editor.add_description(self.description) self.definition_body = open_api_editor.openapi + def _add_title(self): + if not self.name: + return + + if not self.definition_body: + raise InvalidResourceException( + self.logical_id, + "Name works only with inline OpenApi specified in the 'DefinitionBody' property.", + ) + + if self.definition_body.get("info", {}).get("title") != OpenApiEditor._DEFAULT_OPENAPI_TITLE: + raise InvalidResourceException( + self.logical_id, + "Unable to set Name because it is already defined within inline OpenAPI specified in the " + "'DefinitionBody' property.", + ) + + open_api_editor = OpenApiEditor(self.definition_body) + open_api_editor.add_title(self.name) + self.definition_body = open_api_editor.openapi + @cw_timer(prefix="Generator", name="HttpApi") def to_cloudformation(self, route53_record_set_groups): """Generates CloudFormation resources from a SAM HTTP API resource diff --git a/samtranslator/model/apigatewayv2.py b/samtranslator/model/apigatewayv2.py index ece8166d3..5a649d2ac 100644 --- a/samtranslator/model/apigatewayv2.py +++ b/samtranslator/model/apigatewayv2.py @@ -14,6 +14,7 @@ class ApiGatewayV2HttpApi(Resource): "BodyS3Location": PropertyType(False, is_type(dict)), "Description": PropertyType(False, is_str()), "FailOnWarnings": PropertyType(False, is_type(bool)), + "Name": PropertyType(False, is_str()), "DisableExecuteApiEndpoint": PropertyType(False, is_type(bool)), "BasePath": PropertyType(False, is_str()), "CorsConfiguration": PropertyType(False, is_type(dict)), diff --git a/samtranslator/model/sam_resources.py b/samtranslator/model/sam_resources.py index 4eee50562..d59788d78 100644 --- a/samtranslator/model/sam_resources.py +++ b/samtranslator/model/sam_resources.py @@ -1192,6 +1192,7 @@ class SamHttpApi(SamResourceMacro): # In the future, we might rename and expose this property to customers so they can have SAM manage Explicit APIs # Swagger. "__MANAGE_SWAGGER": PropertyType(False, is_type(bool)), + "Name": PropertyType(False, one_of(is_str(), is_type(dict))), "StageName": PropertyType(False, one_of(is_str(), is_type(dict))), "Tags": PropertyType(False, is_type(dict)), "DefinitionBody": PropertyType(False, is_type(dict)), @@ -1233,6 +1234,7 @@ def to_cloudformation(self, **kwargs): self.depends_on, self.DefinitionBody, self.DefinitionUri, + self.Name, self.StageName, tags=self.Tags, auth=self.Auth, diff --git a/samtranslator/open_api/open_api.py b/samtranslator/open_api/open_api.py index 5a49d01f6..b1b8fc7e1 100644 --- a/samtranslator/open_api/open_api.py +++ b/samtranslator/open_api/open_api.py @@ -30,6 +30,7 @@ class OpenApiEditor(object): _X_ANY_METHOD = "x-amazon-apigateway-any-method" _ALL_HTTP_METHODS = ["OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE", "PATCH"] _DEFAULT_PATH = "$default" + _DEFAULT_OPENAPI_TITLE = ref("AWS::StackName") def __init__(self, doc): """ @@ -599,6 +600,15 @@ def add_description(self, description): return self.info["description"] = description + def add_title(self, title: str) -> None: + """Add title in open api definition, if it is not already defined + + :param string description: Description of the API + """ + if self.info.get("title") != OpenApiEditor._DEFAULT_OPENAPI_TITLE: + return + self.info["title"] = title + def has_api_gateway_cors(self): if self._doc.get(self._X_APIGW_CORS): return True @@ -655,7 +665,7 @@ def gen_skeleton(): skeleton["openapi"] = "3.0.1" skeleton["info"] = Py27Dict() skeleton["info"]["version"] = "1.0" - skeleton["info"]["title"] = ref("AWS::StackName") + skeleton["info"]["title"] = OpenApiEditor._DEFAULT_OPENAPI_TITLE skeleton["paths"] = Py27Dict() return skeleton diff --git a/tests/model/api/test_http_api_generator.py b/tests/model/api/test_http_api_generator.py index 007952421..e892acce9 100644 --- a/tests/model/api/test_http_api_generator.py +++ b/tests/model/api/test_http_api_generator.py @@ -15,6 +15,7 @@ class TestHttpApiGenerator(TestCase): "depends_on": None, "definition_body": None, "definition_uri": None, + "name": None, "stage_name": None, "tags": None, "auth": None, @@ -208,6 +209,7 @@ class TestCustomDomains(TestCase): "depends_on": None, "definition_body": None, "definition_uri": "s3://bucket/key", + "name": None, "stage_name": None, "tags": None, "auth": None, diff --git a/tests/translator/input/explicit_http_api_with_name.yaml b/tests/translator/input/explicit_http_api_with_name.yaml new file mode 100644 index 000000000..e4b15ff10 --- /dev/null +++ b/tests/translator/input/explicit_http_api_with_name.yaml @@ -0,0 +1,26 @@ +Resources: + HttpApiFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/todo_list.zip + Handler: index.restapi + Runtime: python3.7 + Events: + SimpleCase: + Type: HttpApi + Properties: + ApiId: !Ref MyApi + SimpleCase2: + Type: HttpApi + Properties: + ApiId: !Ref MyApiWithIntrinsicName + + MyApi: + Type: AWS::Serverless::HttpApi + Properties: + Name: MyHttpApi + + MyApiWithIntrinsicName: + Type: AWS::Serverless::HttpApi + Properties: + Name: !Sub "${HttpApiFunction}-HttpApi" diff --git a/tests/translator/output/aws-cn/explicit_http_api_with_name.json b/tests/translator/output/aws-cn/explicit_http_api_with_name.json new file mode 100644 index 000000000..cbef1af03 --- /dev/null +++ b/tests/translator/output/aws-cn/explicit_http_api_with_name.json @@ -0,0 +1,195 @@ +{ + "Resources": { + "HttpApiFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "todo_list.zip" + }, + "Handler": "index.restapi", + "Role": { + "Fn::GetAtt": [ + "HttpApiFunctionRole", + "Arn" + ] + }, + "Runtime": "python3.7", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "HttpApiFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "HttpApiFunctionSimpleCasePermission": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Ref": "HttpApiFunction" + }, + "Principal": "apigateway.amazonaws.com", + "SourceArn": { + "Fn::Sub": [ + "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", + { + "__ApiId__": { + "Ref": "MyApi" + }, + "__Stage__": "*" + } + ] + } + } + }, + "HttpApiFunctionSimpleCase2Permission": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Ref": "HttpApiFunction" + }, + "Principal": "apigateway.amazonaws.com", + "SourceArn": { + "Fn::Sub": [ + "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", + { + "__ApiId__": { + "Ref": "MyApiWithIntrinsicName" + }, + "__Stage__": "*" + } + ] + } + } + }, + "MyApi": { + "Type": "AWS::ApiGatewayV2::Api", + "Properties": { + "Body": { + "info": { + "version": "1.0", + "title": "MyHttpApi" + }, + "paths": { + "$default": { + "x-amazon-apigateway-any-method": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations" + }, + "payloadFormatVersion": "2.0" + }, + "isDefaultRoute": true, + "responses": {} + } + } + }, + "openapi": "3.0.1", + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] + } + } + }, + "MyApiApiGatewayDefaultStage": { + "Type": "AWS::ApiGatewayV2::Stage", + "Properties": { + "ApiId": { + "Ref": "MyApi" + }, + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + }, + "AutoDeploy": true + } + }, + "MyApiWithIntrinsicName": { + "Type": "AWS::ApiGatewayV2::Api", + "Properties": { + "Body": { + "info": { + "version": "1.0", + "title": { + "Fn::Sub": "${HttpApiFunction}-HttpApi" + } + }, + "paths": { + "$default": { + "x-amazon-apigateway-any-method": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations" + }, + "payloadFormatVersion": "2.0" + }, + "isDefaultRoute": true, + "responses": {} + } + } + }, + "openapi": "3.0.1", + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] + } + } + }, + "MyApiWithIntrinsicNameApiGatewayDefaultStage": { + "Type": "AWS::ApiGatewayV2::Stage", + "Properties": { + "ApiId": { + "Ref": "MyApiWithIntrinsicName" + }, + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + }, + "AutoDeploy": true + } + } + } +} diff --git a/tests/translator/output/aws-us-gov/explicit_http_api_with_name.json b/tests/translator/output/aws-us-gov/explicit_http_api_with_name.json new file mode 100644 index 000000000..c2b7af2c6 --- /dev/null +++ b/tests/translator/output/aws-us-gov/explicit_http_api_with_name.json @@ -0,0 +1,195 @@ +{ + "Resources": { + "HttpApiFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "todo_list.zip" + }, + "Handler": "index.restapi", + "Role": { + "Fn::GetAtt": [ + "HttpApiFunctionRole", + "Arn" + ] + }, + "Runtime": "python3.7", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "HttpApiFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "HttpApiFunctionSimpleCasePermission": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Ref": "HttpApiFunction" + }, + "Principal": "apigateway.amazonaws.com", + "SourceArn": { + "Fn::Sub": [ + "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", + { + "__ApiId__": { + "Ref": "MyApi" + }, + "__Stage__": "*" + } + ] + } + } + }, + "HttpApiFunctionSimpleCase2Permission": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Ref": "HttpApiFunction" + }, + "Principal": "apigateway.amazonaws.com", + "SourceArn": { + "Fn::Sub": [ + "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", + { + "__ApiId__": { + "Ref": "MyApiWithIntrinsicName" + }, + "__Stage__": "*" + } + ] + } + } + }, + "MyApi": { + "Type": "AWS::ApiGatewayV2::Api", + "Properties": { + "Body": { + "info": { + "version": "1.0", + "title": "MyHttpApi" + }, + "paths": { + "$default": { + "x-amazon-apigateway-any-method": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations" + }, + "payloadFormatVersion": "2.0" + }, + "isDefaultRoute": true, + "responses": {} + } + } + }, + "openapi": "3.0.1", + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] + } + } + }, + "MyApiApiGatewayDefaultStage": { + "Type": "AWS::ApiGatewayV2::Stage", + "Properties": { + "ApiId": { + "Ref": "MyApi" + }, + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + }, + "AutoDeploy": true + } + }, + "MyApiWithIntrinsicName": { + "Type": "AWS::ApiGatewayV2::Api", + "Properties": { + "Body": { + "info": { + "version": "1.0", + "title": { + "Fn::Sub": "${HttpApiFunction}-HttpApi" + } + }, + "paths": { + "$default": { + "x-amazon-apigateway-any-method": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations" + }, + "payloadFormatVersion": "2.0" + }, + "isDefaultRoute": true, + "responses": {} + } + } + }, + "openapi": "3.0.1", + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] + } + } + }, + "MyApiWithIntrinsicNameApiGatewayDefaultStage": { + "Type": "AWS::ApiGatewayV2::Stage", + "Properties": { + "ApiId": { + "Ref": "MyApiWithIntrinsicName" + }, + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + }, + "AutoDeploy": true + } + } + } +} diff --git a/tests/translator/output/explicit_http_api_with_name.json b/tests/translator/output/explicit_http_api_with_name.json new file mode 100644 index 000000000..62f802419 --- /dev/null +++ b/tests/translator/output/explicit_http_api_with_name.json @@ -0,0 +1,195 @@ +{ + "Resources": { + "HttpApiFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "todo_list.zip" + }, + "Handler": "index.restapi", + "Role": { + "Fn::GetAtt": [ + "HttpApiFunctionRole", + "Arn" + ] + }, + "Runtime": "python3.7", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "HttpApiFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + }, + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + } + }, + "HttpApiFunctionSimpleCasePermission": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Ref": "HttpApiFunction" + }, + "Principal": "apigateway.amazonaws.com", + "SourceArn": { + "Fn::Sub": [ + "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", + { + "__ApiId__": { + "Ref": "MyApi" + }, + "__Stage__": "*" + } + ] + } + } + }, + "HttpApiFunctionSimpleCase2Permission": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Ref": "HttpApiFunction" + }, + "Principal": "apigateway.amazonaws.com", + "SourceArn": { + "Fn::Sub": [ + "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", + { + "__ApiId__": { + "Ref": "MyApiWithIntrinsicName" + }, + "__Stage__": "*" + } + ] + } + } + }, + "MyApi": { + "Type": "AWS::ApiGatewayV2::Api", + "Properties": { + "Body": { + "info": { + "version": "1.0", + "title": "MyHttpApi" + }, + "paths": { + "$default": { + "x-amazon-apigateway-any-method": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations" + }, + "payloadFormatVersion": "2.0" + }, + "isDefaultRoute": true, + "responses": {} + } + } + }, + "openapi": "3.0.1", + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] + } + } + }, + "MyApiApiGatewayDefaultStage": { + "Type": "AWS::ApiGatewayV2::Stage", + "Properties": { + "ApiId": { + "Ref": "MyApi" + }, + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + }, + "AutoDeploy": true + } + }, + "MyApiWithIntrinsicName": { + "Type": "AWS::ApiGatewayV2::Api", + "Properties": { + "Body": { + "info": { + "version": "1.0", + "title": { + "Fn::Sub": "${HttpApiFunction}-HttpApi" + } + }, + "paths": { + "$default": { + "x-amazon-apigateway-any-method": { + "x-amazon-apigateway-integration": { + "httpMethod": "POST", + "type": "aws_proxy", + "uri": { + "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations" + }, + "payloadFormatVersion": "2.0" + }, + "isDefaultRoute": true, + "responses": {} + } + } + }, + "openapi": "3.0.1", + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] + } + } + }, + "MyApiWithIntrinsicNameApiGatewayDefaultStage": { + "Type": "AWS::ApiGatewayV2::Stage", + "Properties": { + "ApiId": { + "Ref": "MyApiWithIntrinsicName" + }, + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + }, + "AutoDeploy": true + } + } + } +} diff --git a/tests/translator/test_translator.py b/tests/translator/test_translator.py index a0b102879..0581b278f 100644 --- a/tests/translator/test_translator.py +++ b/tests/translator/test_translator.py @@ -314,6 +314,7 @@ def test_transform_success(self, testcase, partition_with_region): "http_api_explicit_stage", "http_api_def_uri", "explicit_http_api", + "explicit_http_api_with_name", "http_api_custom_iam_auth", "http_api_with_cors", "http_api_description", From 16050bfbb40a65114ad00653e9317f10b9759b1b Mon Sep 17 00:00:00 2001 From: Sam Liu Date: Wed, 16 Nov 2022 16:03:53 -0800 Subject: [PATCH 2/2] Use `Property` instead of `PropertyType` --- samtranslator/model/api/http_api_generator.py | 2 +- samtranslator/model/apigatewayv2.py | 1 - samtranslator/model/sam_resources.py | 13 ++++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/samtranslator/model/api/http_api_generator.py b/samtranslator/model/api/http_api_generator.py index 2f05578c0..91782a2be 100644 --- a/samtranslator/model/api/http_api_generator.py +++ b/samtranslator/model/api/http_api_generator.py @@ -39,7 +39,7 @@ def __init__( depends_on: Optional[List[str]], definition_body: Optional[Dict[str, Any]], definition_uri: Optional[Intrinsicable[str]], - name: Optional[Intrinsicable[str]], + name: Optional[Any], stage_name: Optional[Intrinsicable[str]], tags: Optional[Dict[str, Intrinsicable[str]]] = None, auth: Optional[Dict[str, Intrinsicable[str]]] = None, diff --git a/samtranslator/model/apigatewayv2.py b/samtranslator/model/apigatewayv2.py index ad6d330f3..b8e6548ea 100644 --- a/samtranslator/model/apigatewayv2.py +++ b/samtranslator/model/apigatewayv2.py @@ -17,7 +17,6 @@ class ApiGatewayV2HttpApi(Resource): "BodyS3Location": PropertyType(False, is_type(dict)), "Description": PropertyType(False, is_str()), "FailOnWarnings": PropertyType(False, is_type(bool)), - "Name": PropertyType(False, is_str()), "DisableExecuteApiEndpoint": PropertyType(False, is_type(bool)), "BasePath": PropertyType(False, is_str()), "CorsConfiguration": PropertyType(False, is_type(dict)), diff --git a/samtranslator/model/sam_resources.py b/samtranslator/model/sam_resources.py index 579dc18b8..7023e717a 100644 --- a/samtranslator/model/sam_resources.py +++ b/samtranslator/model/sam_resources.py @@ -29,7 +29,14 @@ from .s3_utils.uri_parser import construct_s3_location_object, construct_image_code_object from .tags.resource_tagging import get_tag_list from samtranslator.metrics.method_decorator import cw_timer -from samtranslator.model import ResourceResolver, PropertyType, SamResourceMacro, Resource, ResourceTypeResolver +from samtranslator.model import ( + ResourceResolver, + Property, + PropertyType, + SamResourceMacro, + Resource, + ResourceTypeResolver, +) from samtranslator.model.apigateway import ( ApiGatewayDeployment, ApiGatewayStage, @@ -1276,7 +1283,7 @@ class SamHttpApi(SamResourceMacro): # In the future, we might rename and expose this property to customers so they can have SAM manage Explicit APIs # Swagger. "__MANAGE_SWAGGER": PropertyType(False, is_type(bool)), - "Name": PropertyType(False, one_of(is_str(), is_type(dict))), + "Name": Property(False, any_type()), "StageName": PropertyType(False, one_of(is_str(), is_type(dict))), "Tags": PropertyType(False, is_type(dict)), "DefinitionBody": PropertyType(False, is_type(dict)), @@ -1293,7 +1300,7 @@ class SamHttpApi(SamResourceMacro): "DisableExecuteApiEndpoint": PropertyType(False, is_type(bool)), } - Name: Optional[Intrinsicable[str]] + Name: Optional[Any] StageName: Optional[Intrinsicable[str]] Tags: Optional[Dict[str, Any]] DefinitionBody: Optional[Dict[str, Any]]