From a84166b17ad65904aa393ced68375fc96029ae17 Mon Sep 17 00:00:00 2001 From: Keeton Hodgson Date: Wed, 4 Mar 2020 17:27:12 -0800 Subject: [PATCH 1/2] Propogate tags to generated resources --- samtranslator/model/api/http_api_generator.py | 4 +- .../output/aws-cn/explicit_http_api.json | 40 ++-- .../aws-cn/http_api_existing_openapi.json | 71 +++---- .../aws-cn/http_api_explicit_stage.json | 35 ++-- .../output/aws-cn/http_api_with_cors.json | 169 ++++++++-------- ...mplicit_http_api_with_many_conditions.json | 21 +- .../output/aws-us-gov/explicit_http_api.json | 40 ++-- .../aws-us-gov/http_api_existing_openapi.json | 71 +++---- .../aws-us-gov/http_api_explicit_stage.json | 48 ++--- .../output/aws-us-gov/http_api_with_cors.json | 180 ++++++++--------- ...mplicit_http_api_with_many_conditions.json | 21 +- .../translator/output/explicit_http_api.json | 40 ++-- .../output/http_api_existing_openapi.json | 73 +++---- .../output/http_api_explicit_stage.json | 47 ++--- .../translator/output/http_api_with_cors.json | 181 +++++++++--------- ...mplicit_http_api_with_many_conditions.json | 21 +- 16 files changed, 564 insertions(+), 498 deletions(-) diff --git a/samtranslator/model/api/http_api_generator.py b/samtranslator/model/api/http_api_generator.py index a1da483a3e..725ead4c46 100644 --- a/samtranslator/model/api/http_api_generator.py +++ b/samtranslator/model/api/http_api_generator.py @@ -195,6 +195,7 @@ def _construct_api_domain(self, http_api): ) domain_config = dict() domain.DomainName = self.domain.get("DomainName") + domain.Tags = self.tags endpoint = self.domain.get("EndpointConfiguration") if endpoint is None: @@ -489,12 +490,13 @@ def _construct_stage(self): stage.StageVariables = self.stage_variables stage.AccessLogSettings = self.access_log_settings stage.DefaultRouteSettings = self.default_route_settings + stage.Tags = self.tags stage.AutoDeploy = True return stage def to_cloudformation(self): - """Generates CloudFormation resources from a SAM API resource + """Generates CloudFormation resources from a SAM HTTP API resource :returns: a tuple containing the HttpApi and Stage for an empty Api. :rtype: tuple diff --git a/tests/translator/output/aws-cn/explicit_http_api.json b/tests/translator/output/aws-cn/explicit_http_api.json index f104793d30..3672f8b187 100644 --- a/tests/translator/output/aws-cn/explicit_http_api.json +++ b/tests/translator/output/aws-cn/explicit_http_api.json @@ -7,7 +7,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "MyApi2ApiGatewayDefaultStage": { @@ -17,7 +20,10 @@ "Ref": "MyApi2" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "HttpApiFunction": { @@ -74,12 +80,6 @@ "Ref": "AWS::StackName" } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], "paths": { "$default": { "x-amazon-apigateway-any-method": { @@ -101,6 +101,7 @@ } } }, + "openapi": "3.0.1", "components": { "securitySchemes": { "OAuth2": { @@ -118,7 +119,12 @@ } } }, - "openapi": "3.0.1" + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } } }, @@ -183,12 +189,6 @@ "Ref": "AWS::StackName" } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], "paths": { "$default": { "x-amazon-apigateway-any-method": { @@ -212,6 +212,7 @@ } } }, + "openapi": "3.0.1", "components": { "securitySchemes": { "OAuth2": { @@ -229,9 +230,14 @@ } } }, - "openapi": "3.0.1" + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } } } } -} +} \ No newline at end of file diff --git a/tests/translator/output/aws-cn/http_api_existing_openapi.json b/tests/translator/output/aws-cn/http_api_existing_openapi.json index c27d4b4e5a..c1df5c259a 100644 --- a/tests/translator/output/aws-cn/http_api_existing_openapi.json +++ b/tests/translator/output/aws-cn/http_api_existing_openapi.json @@ -1,10 +1,10 @@ { "Parameters": { "Timeout": { - "Default": 15000, + "Default": 15000, "Type": "Number" } - }, + }, "Resources": { "HttpApiFunctionSimpleCasePermission": { "Type": "AWS::Lambda::Permission", @@ -34,7 +34,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "HttpApiFunction": { @@ -51,7 +54,7 @@ "Arn" ] }, - "Runtime": "nodejs12.x", + "Runtime": "nodejs12.x", "Tags": [ { "Value": "SAM", @@ -101,36 +104,17 @@ "Ref": "AWS::StackName" } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], - "x-amazon-apigateway-cors": { - "allowHeaders": [ - "x-apigateway-header" - ], - "allowMethods": [ - "GET" - ], - "allowOrigins": [ - "https://global.com", - "https://local.com" - ], - "maxAge": 6000 - }, "paths": { "/basic": { "post": { "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "timeoutInMillis": 10000, + "payloadFormatVersion": "1.0", "type": "aws_proxy", "uri": { "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${DifferentFunction.Arn}/invocations" }, - "payloadFormatVersion": "1.0" + "httpMethod": "POST", + "timeoutInMillis": 10000 }, "security": [ { @@ -175,15 +159,15 @@ ], "isDefaultRoute": true, "x-amazon-apigateway-integration": { - "httpMethod": "POST", + "payloadFormatVersion": "1.0", "type": "aws_proxy", - "timeoutInMillis": { - "Ref": "Timeout" - }, "uri": { "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations" }, - "payloadFormatVersion": "1.0" + "httpMethod": "POST", + "timeoutInMillis": { + "Ref": "Timeout" + } }, "responses": {} } @@ -209,6 +193,26 @@ } } }, + "x-amazon-apigateway-cors": { + "allowMethods": [ + "GET" + ], + "allowHeaders": [ + "x-apigateway-header" + ], + "allowOrigins": [ + "https://global.com", + "https://local.com" + ], + "maxAge": 6000 + }, + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ], + "openapi": "3.0.1", "components": { "securitySchemes": { "oauth2Auth": { @@ -239,10 +243,9 @@ } } } - }, - "openapi": "3.0.1" + } } } } } -} +} \ No newline at end of file diff --git a/tests/translator/output/aws-cn/http_api_explicit_stage.json b/tests/translator/output/aws-cn/http_api_explicit_stage.json index 13f444fb41..8fcda86276 100644 --- a/tests/translator/output/aws-cn/http_api_explicit_stage.json +++ b/tests/translator/output/aws-cn/http_api_explicit_stage.json @@ -1,10 +1,10 @@ { "Parameters": { "CorsParam": { - "Default": true, + "Default": true, "Type": "String" } - }, + }, "Resources": { "HttpApiFunctionSimpleCasePermission": { "Type": "AWS::Lambda::Permission", @@ -41,7 +41,7 @@ "Arn" ] }, - "Runtime": "nodejs12.x", + "Runtime": "nodejs12.x", "Tags": [ { "Value": "SAM", @@ -53,23 +53,23 @@ "MyApiProdStage": { "Type": "AWS::ApiGatewayV2::Stage", "Properties": { + "AutoDeploy": true, "ApiId": { "Ref": "MyApi" }, - "AutoDeploy": true, - "StageName": "Prod", + "StageName": "Prod", "AccessLogSettings": { - "DestinationArn": "arn:aws:logs:us-east-1:123456789012:log-group:LogGroupName", + "DestinationArn": "arn:aws:logs:us-east-1:123456789012:log-group:LogGroupName", "Format": "$context.requestId" + }, + "Tags": { + "httpapi:createdBy": "SAM" } } }, "HttpApiFunctionRole": { "Type": "AWS::IAM::Role", "Properties": { - "ManagedPolicyArns": [ - "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ @@ -86,6 +86,9 @@ } ] }, + "ManagedPolicyArns": [ + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], "Tags": [ { "Value": "SAM", @@ -103,12 +106,7 @@ "title": { "Ref": "AWS::StackName" } - }, - "x-amazon-apigateway-cors": { - "allowOrigins": [ - "*" - ] - }, + }, "paths": { "$default": { "x-amazon-apigateway-any-method": { @@ -125,6 +123,11 @@ } } }, + "x-amazon-apigateway-cors": { + "allowOrigins": [ + "*" + ] + }, "openapi": "3.0.1", "tags": [ { @@ -136,4 +139,4 @@ } } } -} +} \ No newline at end of file diff --git a/tests/translator/output/aws-cn/http_api_with_cors.json b/tests/translator/output/aws-cn/http_api_with_cors.json index 7aa824cb52..0510e7722d 100644 --- a/tests/translator/output/aws-cn/http_api_with_cors.json +++ b/tests/translator/output/aws-cn/http_api_with_cors.json @@ -2,123 +2,129 @@ "Conditions": { "C1": { "Fn::Equals": [ - true, + true, true ] } - }, + }, "Resources": { "MyApiApiGatewayDefaultStage": { - "Type": "AWS::ApiGatewayV2::Stage", + "Type": "AWS::ApiGatewayV2::Stage", "Properties": { "ApiId": { "Ref": "MyApi" - }, - "AutoDeploy": true, - "StageName": "$default" + }, + "AutoDeploy": true, + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } - }, + }, "ServerlessHttpApiApiGatewayDefaultStage": { - "Type": "AWS::ApiGatewayV2::Stage", + "Type": "AWS::ApiGatewayV2::Stage", "Properties": { "ApiId": { "Ref": "ServerlessHttpApi" - }, - "AutoDeploy": true, - "StageName": "$default" + }, + "AutoDeploy": true, + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } - }, + }, "ServerlessHttpApi": { - "Type": "AWS::ApiGatewayV2::Api", + "Type": "AWS::ApiGatewayV2::Api", "Properties": { "Body": { "info": { - "version": "1.0", + "version": "1.0", "title": { "Ref": "AWS::StackName" } - }, + }, "paths": { "$default": { "x-amazon-apigateway-any-method": { "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", + "httpMethod": "POST", + "type": "aws_proxy", "uri": { "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations" - }, + }, "payloadFormatVersion": "1.0" - }, - "isDefaultRoute": true, + }, + "isDefaultRoute": true, "responses": {} } } - }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], + }, "x-amazon-apigateway-cors": { "Fn::If": [ - "C1", + "C1", { "allowHeaders": [ "x-apigateway-header" - ], + ], "allowMethods": [ "GET" - ], + ], "allowOrigins": [ "https://foo.com" - ], + ], "exposeHeaders": [ "x-amzn-header" ] - }, + }, "AWS::NoValue" ] - }, - "openapi": "3.0.1" + }, + "openapi": "3.0.1", + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } } - }, + }, "HttpApiFunction": { - "Type": "AWS::Lambda::Function", + "Type": "AWS::Lambda::Function", "Properties": { - "Handler": "index.handler", + "Handler": "index.handler", "Code": { "ZipFile": "exports.handler = async (event) => {\n console.log(\"Hello from MyAuthFunction\")\n return {\n statusCode: 200,\n body: JSON.stringify(event),\n headers: {}\n }\n}\n" - }, + }, "Role": { "Fn::GetAtt": [ - "HttpApiFunctionRole", + "HttpApiFunctionRole", "Arn" ] - }, - "Runtime": "nodejs12.x", + }, + "Runtime": "nodejs12.x", "Tags": [ { - "Value": "SAM", + "Value": "SAM", "Key": "lambda:createdBy" } ] } - }, + }, "HttpApiFunctionSimpleCasePermission": { - "Type": "AWS::Lambda::Permission", + "Type": "AWS::Lambda::Permission", "Properties": { - "Action": "lambda:InvokeFunction", - "Principal": "apigateway.amazonaws.com", + "Action": "lambda:InvokeFunction", + "Principal": "apigateway.amazonaws.com", "FunctionName": { "Ref": "HttpApiFunction" - }, + }, "SourceArn": { "Fn::Sub": [ - "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", + "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", { - "__Stage__": "*", + "__Stage__": "*", "__ApiId__": { "Ref": "MyApi" } @@ -126,20 +132,20 @@ ] } } - }, + }, "HttpApiFunctionImplicitApiPermission": { - "Type": "AWS::Lambda::Permission", + "Type": "AWS::Lambda::Permission", "Properties": { - "Action": "lambda:InvokeFunction", - "Principal": "apigateway.amazonaws.com", + "Action": "lambda:InvokeFunction", + "Principal": "apigateway.amazonaws.com", "FunctionName": { "Ref": "HttpApiFunction" - }, + }, "SourceArn": { "Fn::Sub": [ - "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", + "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", { - "__Stage__": "*", + "__Stage__": "*", "__ApiId__": { "Ref": "ServerlessHttpApi" } @@ -147,18 +153,18 @@ ] } } - }, + }, "HttpApiFunctionRole": { - "Type": "AWS::IAM::Role", + "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", + "Version": "2012-10-17", "Statement": [ { "Action": [ "sts:AssumeRole" - ], - "Effect": "Allow", + ], + "Effect": "Allow", "Principal": { "Service": [ "lambda.amazonaws.com" @@ -166,50 +172,44 @@ } } ] - }, + }, "ManagedPolicyArns": [ "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], + ], "Tags": [ { - "Value": "SAM", + "Value": "SAM", "Key": "lambda:createdBy" } ] } - }, + }, "MyApi": { - "Type": "AWS::ApiGatewayV2::Api", + "Type": "AWS::ApiGatewayV2::Api", "Properties": { "Body": { "info": { - "version": "1.0", + "version": "1.0", "title": { "Ref": "AWS::StackName" } - }, + }, "paths": { "$default": { "x-amazon-apigateway-any-method": { "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", + "httpMethod": "POST", + "type": "aws_proxy", "uri": { "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations" - }, + }, "payloadFormatVersion": "1.0" - }, - "isDefaultRoute": true, + }, + "isDefaultRoute": true, "responses": {} } } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], "x-amazon-apigateway-cors": { "Fn::If": [ "C1", @@ -228,8 +228,15 @@ ] }, "AWS::NoValue" - ] }, - "openapi": "3.0.1" + ] + }, + "openapi": "3.0.1", + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } } } diff --git a/tests/translator/output/aws-cn/implicit_http_api_with_many_conditions.json b/tests/translator/output/aws-cn/implicit_http_api_with_many_conditions.json index 519cb8083a..aafd564d62 100644 --- a/tests/translator/output/aws-cn/implicit_http_api_with_many_conditions.json +++ b/tests/translator/output/aws-cn/implicit_http_api_with_many_conditions.json @@ -199,12 +199,6 @@ "Ref": "AWS::StackName" } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], "paths": { "/hello/again": { "Fn::If": [ @@ -659,6 +653,7 @@ ] } }, + "openapi": "3.0.1", "components": { "securitySchemes": { "oauth2": { @@ -676,7 +671,12 @@ } } }, - "openapi": "3.0.1" + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } }, "Condition": "ServerlessHttpApiCondition" @@ -1340,7 +1340,10 @@ "Ref": "ServerlessHttpApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } }, "Condition": "ServerlessHttpApiCondition" }, @@ -1476,4 +1479,4 @@ "Condition": "Cond3" } } -} +} \ No newline at end of file diff --git a/tests/translator/output/aws-us-gov/explicit_http_api.json b/tests/translator/output/aws-us-gov/explicit_http_api.json index 50cb6158ad..0c97ee2c84 100644 --- a/tests/translator/output/aws-us-gov/explicit_http_api.json +++ b/tests/translator/output/aws-us-gov/explicit_http_api.json @@ -7,7 +7,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "MyApi2ApiGatewayDefaultStage": { @@ -17,7 +20,10 @@ "Ref": "MyApi2" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "HttpApiFunction": { @@ -74,12 +80,6 @@ "Ref": "AWS::StackName" } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], "paths": { "$default": { "x-amazon-apigateway-any-method": { @@ -101,6 +101,7 @@ } } }, + "openapi": "3.0.1", "components": { "securitySchemes": { "OAuth2": { @@ -118,7 +119,12 @@ } } }, - "openapi": "3.0.1" + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } } }, @@ -183,12 +189,6 @@ "Ref": "AWS::StackName" } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], "paths": { "$default": { "x-amazon-apigateway-any-method": { @@ -212,6 +212,7 @@ } } }, + "openapi": "3.0.1", "components": { "securitySchemes": { "OAuth2": { @@ -229,9 +230,14 @@ } } }, - "openapi": "3.0.1" + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } } } } -} +} \ No newline at end of file diff --git a/tests/translator/output/aws-us-gov/http_api_existing_openapi.json b/tests/translator/output/aws-us-gov/http_api_existing_openapi.json index 1044072e8f..01da21adf8 100644 --- a/tests/translator/output/aws-us-gov/http_api_existing_openapi.json +++ b/tests/translator/output/aws-us-gov/http_api_existing_openapi.json @@ -1,10 +1,10 @@ { "Parameters": { "Timeout": { - "Default": 15000, + "Default": 15000, "Type": "Number" } - }, + }, "Resources": { "HttpApiFunctionSimpleCasePermission": { "Type": "AWS::Lambda::Permission", @@ -34,7 +34,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "HttpApiFunction": { @@ -51,7 +54,7 @@ "Arn" ] }, - "Runtime": "nodejs12.x", + "Runtime": "nodejs12.x", "Tags": [ { "Value": "SAM", @@ -101,36 +104,17 @@ "Ref": "AWS::StackName" } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], - "x-amazon-apigateway-cors": { - "allowHeaders": [ - "x-apigateway-header" - ], - "allowMethods": [ - "GET" - ], - "allowOrigins": [ - "https://global.com", - "https://local.com" - ], - "maxAge": 6000 - }, "paths": { "/basic": { "post": { "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "timeoutInMillis": 10000, + "payloadFormatVersion": "1.0", "type": "aws_proxy", "uri": { "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${DifferentFunction.Arn}/invocations" }, - "payloadFormatVersion": "1.0" + "httpMethod": "POST", + "timeoutInMillis": 10000 }, "security": [ { @@ -175,15 +159,15 @@ ], "isDefaultRoute": true, "x-amazon-apigateway-integration": { - "httpMethod": "POST", + "payloadFormatVersion": "1.0", "type": "aws_proxy", - "timeoutInMillis": { - "Ref": "Timeout" - }, "uri": { "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations" }, - "payloadFormatVersion": "1.0" + "httpMethod": "POST", + "timeoutInMillis": { + "Ref": "Timeout" + } }, "responses": {} } @@ -209,6 +193,26 @@ } } }, + "x-amazon-apigateway-cors": { + "allowMethods": [ + "GET" + ], + "allowHeaders": [ + "x-apigateway-header" + ], + "allowOrigins": [ + "https://global.com", + "https://local.com" + ], + "maxAge": 6000 + }, + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ], + "openapi": "3.0.1", "components": { "securitySchemes": { "oauth2Auth": { @@ -239,10 +243,9 @@ } } } - }, - "openapi": "3.0.1" + } } } } } -} +} \ No newline at end of file diff --git a/tests/translator/output/aws-us-gov/http_api_explicit_stage.json b/tests/translator/output/aws-us-gov/http_api_explicit_stage.json index b4007733df..0589116ea3 100644 --- a/tests/translator/output/aws-us-gov/http_api_explicit_stage.json +++ b/tests/translator/output/aws-us-gov/http_api_explicit_stage.json @@ -1,11 +1,10 @@ { "Parameters": { "CorsParam": { - "Default": true, + "Default": true, "Type": "String" } - }, - + }, "Resources": { "HttpApiFunctionSimpleCasePermission": { "Type": "AWS::Lambda::Permission", @@ -42,7 +41,7 @@ "Arn" ] }, - "Runtime": "nodejs12.x", + "Runtime": "nodejs12.x", "Tags": [ { "Value": "SAM", @@ -54,23 +53,23 @@ "MyApiProdStage": { "Type": "AWS::ApiGatewayV2::Stage", "Properties": { + "AutoDeploy": true, "ApiId": { "Ref": "MyApi" }, - "AutoDeploy": true, - "StageName": "Prod", + "StageName": "Prod", "AccessLogSettings": { - "DestinationArn": "arn:aws:logs:us-east-1:123456789012:log-group:LogGroupName", + "DestinationArn": "arn:aws:logs:us-east-1:123456789012:log-group:LogGroupName", "Format": "$context.requestId" + }, + "Tags": { + "httpapi:createdBy": "SAM" } } }, "HttpApiFunctionRole": { "Type": "AWS::IAM::Role", "Properties": { - "ManagedPolicyArns": [ - "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ @@ -87,6 +86,9 @@ } ] }, + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], "Tags": [ { "Value": "SAM", @@ -105,17 +107,6 @@ "Ref": "AWS::StackName" } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], - "x-amazon-apigateway-cors": { - "allowOrigins": [ - "*" - ] - }, "paths": { "$default": { "x-amazon-apigateway-any-method": { @@ -132,9 +123,20 @@ } } }, - "openapi": "3.0.1" + "x-amazon-apigateway-cors": { + "allowOrigins": [ + "*" + ] + }, + "openapi": "3.0.1", + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } } } } -} +} \ No newline at end of file diff --git a/tests/translator/output/aws-us-gov/http_api_with_cors.json b/tests/translator/output/aws-us-gov/http_api_with_cors.json index e9f3561604..fe60926e7b 100644 --- a/tests/translator/output/aws-us-gov/http_api_with_cors.json +++ b/tests/translator/output/aws-us-gov/http_api_with_cors.json @@ -2,123 +2,129 @@ "Conditions": { "C1": { "Fn::Equals": [ - true, + true, true ] } - }, + }, "Resources": { "MyApiApiGatewayDefaultStage": { - "Type": "AWS::ApiGatewayV2::Stage", + "Type": "AWS::ApiGatewayV2::Stage", "Properties": { "ApiId": { "Ref": "MyApi" - }, - "AutoDeploy": true, - "StageName": "$default" + }, + "AutoDeploy": true, + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } - }, + }, "ServerlessHttpApiApiGatewayDefaultStage": { - "Type": "AWS::ApiGatewayV2::Stage", + "Type": "AWS::ApiGatewayV2::Stage", "Properties": { "ApiId": { "Ref": "ServerlessHttpApi" - }, - "AutoDeploy": true, - "StageName": "$default" + }, + "AutoDeploy": true, + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } - }, + }, "ServerlessHttpApi": { - "Type": "AWS::ApiGatewayV2::Api", + "Type": "AWS::ApiGatewayV2::Api", "Properties": { "Body": { "info": { - "version": "1.0", + "version": "1.0", "title": { "Ref": "AWS::StackName" } - }, + }, "paths": { "$default": { "x-amazon-apigateway-any-method": { "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", + "httpMethod": "POST", + "type": "aws_proxy", "uri": { "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations" - }, + }, "payloadFormatVersion": "1.0" - }, - "isDefaultRoute": true, + }, + "isDefaultRoute": true, "responses": {} } } - }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], + }, "x-amazon-apigateway-cors": { "Fn::If": [ - "C1", + "C1", { "allowHeaders": [ "x-apigateway-header" - ], + ], "allowMethods": [ "GET" - ], + ], "allowOrigins": [ "https://foo.com" - ], + ], "exposeHeaders": [ "x-amzn-header" ] - }, + }, "AWS::NoValue" ] - }, - "openapi": "3.0.1" + }, + "openapi": "3.0.1", + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } } - }, + }, "HttpApiFunction": { - "Type": "AWS::Lambda::Function", + "Type": "AWS::Lambda::Function", "Properties": { - "Handler": "index.handler", + "Handler": "index.handler", "Code": { "ZipFile": "exports.handler = async (event) => {\n console.log(\"Hello from MyAuthFunction\")\n return {\n statusCode: 200,\n body: JSON.stringify(event),\n headers: {}\n }\n}\n" - }, + }, "Role": { "Fn::GetAtt": [ - "HttpApiFunctionRole", + "HttpApiFunctionRole", "Arn" ] - }, - "Runtime": "nodejs12.x", + }, + "Runtime": "nodejs12.x", "Tags": [ { - "Value": "SAM", + "Value": "SAM", "Key": "lambda:createdBy" } ] } - }, + }, "HttpApiFunctionSimpleCasePermission": { - "Type": "AWS::Lambda::Permission", + "Type": "AWS::Lambda::Permission", "Properties": { - "Action": "lambda:InvokeFunction", - "Principal": "apigateway.amazonaws.com", + "Action": "lambda:InvokeFunction", + "Principal": "apigateway.amazonaws.com", "FunctionName": { "Ref": "HttpApiFunction" - }, + }, "SourceArn": { "Fn::Sub": [ - "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", + "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", { - "__Stage__": "*", + "__Stage__": "*", "__ApiId__": { "Ref": "MyApi" } @@ -126,20 +132,20 @@ ] } } - }, + }, "HttpApiFunctionImplicitApiPermission": { - "Type": "AWS::Lambda::Permission", + "Type": "AWS::Lambda::Permission", "Properties": { - "Action": "lambda:InvokeFunction", - "Principal": "apigateway.amazonaws.com", + "Action": "lambda:InvokeFunction", + "Principal": "apigateway.amazonaws.com", "FunctionName": { "Ref": "HttpApiFunction" - }, + }, "SourceArn": { "Fn::Sub": [ - "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", + "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", { - "__Stage__": "*", + "__Stage__": "*", "__ApiId__": { "Ref": "ServerlessHttpApi" } @@ -147,18 +153,18 @@ ] } } - }, + }, "HttpApiFunctionRole": { - "Type": "AWS::IAM::Role", + "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", + "Version": "2012-10-17", "Statement": [ { "Action": [ "sts:AssumeRole" - ], - "Effect": "Allow", + ], + "Effect": "Allow", "Principal": { "Service": [ "lambda.amazonaws.com" @@ -166,71 +172,71 @@ } } ] - }, + }, "ManagedPolicyArns": [ "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], + ], "Tags": [ { - "Value": "SAM", + "Value": "SAM", "Key": "lambda:createdBy" } ] } - }, + }, "MyApi": { - "Type": "AWS::ApiGatewayV2::Api", + "Type": "AWS::ApiGatewayV2::Api", "Properties": { "Body": { "info": { - "version": "1.0", + "version": "1.0", "title": { "Ref": "AWS::StackName" } - }, + }, "paths": { "$default": { "x-amazon-apigateway-any-method": { "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", + "httpMethod": "POST", + "type": "aws_proxy", "uri": { "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations" - }, + }, "payloadFormatVersion": "1.0" - }, - "isDefaultRoute": true, + }, + "isDefaultRoute": true, "responses": {} } } - }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], + }, "x-amazon-apigateway-cors": { "Fn::If": [ - "C1", + "C1", { "allowHeaders": [ "x-apigateway-header" - ], + ], "allowMethods": [ "GET" - ], + ], "allowOrigins": [ "https://foo.com" - ], + ], "exposeHeaders": [ "x-amzn-header" ] - }, + }, "AWS::NoValue" ] - }, - "openapi": "3.0.1" + }, + "openapi": "3.0.1", + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } } } diff --git a/tests/translator/output/aws-us-gov/implicit_http_api_with_many_conditions.json b/tests/translator/output/aws-us-gov/implicit_http_api_with_many_conditions.json index c5eea99b65..5393ac6d13 100644 --- a/tests/translator/output/aws-us-gov/implicit_http_api_with_many_conditions.json +++ b/tests/translator/output/aws-us-gov/implicit_http_api_with_many_conditions.json @@ -199,12 +199,6 @@ "Ref": "AWS::StackName" } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], "paths": { "/hello/again": { "Fn::If": [ @@ -659,6 +653,7 @@ ] } }, + "openapi": "3.0.1", "components": { "securitySchemes": { "oauth2": { @@ -676,7 +671,12 @@ } } }, - "openapi": "3.0.1" + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } }, "Condition": "ServerlessHttpApiCondition" @@ -1340,7 +1340,10 @@ "Ref": "ServerlessHttpApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } }, "Condition": "ServerlessHttpApiCondition" }, @@ -1476,4 +1479,4 @@ "Condition": "Cond3" } } -} +} \ No newline at end of file diff --git a/tests/translator/output/explicit_http_api.json b/tests/translator/output/explicit_http_api.json index 8fc5d920d1..070bd89351 100644 --- a/tests/translator/output/explicit_http_api.json +++ b/tests/translator/output/explicit_http_api.json @@ -7,7 +7,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "MyApi2ApiGatewayDefaultStage": { @@ -17,7 +20,10 @@ "Ref": "MyApi2" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "HttpApiFunction": { @@ -74,12 +80,6 @@ "Ref": "AWS::StackName" } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], "paths": { "$default": { "x-amazon-apigateway-any-method": { @@ -101,6 +101,7 @@ } } }, + "openapi": "3.0.1", "components": { "securitySchemes": { "OAuth2": { @@ -118,7 +119,12 @@ } } }, - "openapi": "3.0.1" + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } } }, @@ -183,12 +189,6 @@ "Ref": "AWS::StackName" } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], "paths": { "$default": { "x-amazon-apigateway-any-method": { @@ -212,6 +212,7 @@ } } }, + "openapi": "3.0.1", "components": { "securitySchemes": { "OAuth2": { @@ -229,9 +230,14 @@ } } }, - "openapi": "3.0.1" + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } } } } -} +} \ No newline at end of file diff --git a/tests/translator/output/http_api_existing_openapi.json b/tests/translator/output/http_api_existing_openapi.json index 2e3c2446f1..8edcb35ab2 100644 --- a/tests/translator/output/http_api_existing_openapi.json +++ b/tests/translator/output/http_api_existing_openapi.json @@ -1,10 +1,10 @@ { "Parameters": { "Timeout": { - "Default": 15000, + "Default": 15000, "Type": "Number" } - }, + }, "Resources": { "HttpApiFunctionSimpleCasePermission": { "Type": "AWS::Lambda::Permission", @@ -34,7 +34,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "HttpApiFunction": { @@ -51,7 +54,7 @@ "Arn" ] }, - "Runtime": "nodejs12.x", + "Runtime": "nodejs12.x", "Tags": [ { "Value": "SAM", @@ -101,36 +104,17 @@ "Ref": "AWS::StackName" } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], - "x-amazon-apigateway-cors": { - "allowHeaders": [ - "x-apigateway-header" - ], - "allowMethods": [ - "GET" - ], - "allowOrigins": [ - "https://global.com", - "https://local.com" - ], - "maxAge": 6000 - }, "paths": { "/basic": { "post": { "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "timeoutInMillis": 10000, + "payloadFormatVersion": "1.0", "type": "aws_proxy", "uri": { "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${DifferentFunction.Arn}/invocations" }, - "payloadFormatVersion": "1.0" + "httpMethod": "POST", + "timeoutInMillis": 10000 }, "security": [ { @@ -173,17 +157,17 @@ ] } ], - "isDefaultRoute": true, + "isDefaultRoute": true, "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "timeoutInMillis": { - "Ref": "Timeout" - }, + "payloadFormatVersion": "1.0", "type": "aws_proxy", "uri": { "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations" }, - "payloadFormatVersion": "1.0" + "httpMethod": "POST", + "timeoutInMillis": { + "Ref": "Timeout" + } }, "responses": {} } @@ -209,6 +193,26 @@ } } }, + "x-amazon-apigateway-cors": { + "allowMethods": [ + "GET" + ], + "allowHeaders": [ + "x-apigateway-header" + ], + "allowOrigins": [ + "https://global.com", + "https://local.com" + ], + "maxAge": 6000 + }, + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ], + "openapi": "3.0.1", "components": { "securitySchemes": { "oauth2Auth": { @@ -239,10 +243,9 @@ } } } - }, - "openapi": "3.0.1" + } } } } } -} +} \ No newline at end of file diff --git a/tests/translator/output/http_api_explicit_stage.json b/tests/translator/output/http_api_explicit_stage.json index f6795577a9..d01111c051 100644 --- a/tests/translator/output/http_api_explicit_stage.json +++ b/tests/translator/output/http_api_explicit_stage.json @@ -1,10 +1,10 @@ { "Parameters": { "CorsParam": { - "Default": true, + "Default": true, "Type": "String" } - }, + }, "Resources": { "HttpApiFunctionSimpleCasePermission": { "Type": "AWS::Lambda::Permission", @@ -41,7 +41,7 @@ "Arn" ] }, - "Runtime": "nodejs12.x", + "Runtime": "nodejs12.x", "Tags": [ { "Value": "SAM", @@ -53,23 +53,23 @@ "MyApiProdStage": { "Type": "AWS::ApiGatewayV2::Stage", "Properties": { + "AutoDeploy": true, "ApiId": { "Ref": "MyApi" }, - "AutoDeploy": true, - "StageName": "Prod", + "StageName": "Prod", "AccessLogSettings": { - "DestinationArn": "arn:aws:logs:us-east-1:123456789012:log-group:LogGroupName", + "DestinationArn": "arn:aws:logs:us-east-1:123456789012:log-group:LogGroupName", "Format": "$context.requestId" + }, + "Tags": { + "httpapi:createdBy": "SAM" } } }, "HttpApiFunctionRole": { "Type": "AWS::IAM::Role", "Properties": { - "ManagedPolicyArns": [ - "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ @@ -86,6 +86,9 @@ } ] }, + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], "Tags": [ { "Value": "SAM", @@ -104,17 +107,6 @@ "Ref": "AWS::StackName" } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], - "x-amazon-apigateway-cors": { - "allowOrigins": [ - "*" - ] - }, "paths": { "$default": { "x-amazon-apigateway-any-method": { @@ -131,9 +123,20 @@ } } }, - "openapi": "3.0.1" + "x-amazon-apigateway-cors": { + "allowOrigins": [ + "*" + ] + }, + "openapi": "3.0.1", + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } } } } -} +} \ No newline at end of file diff --git a/tests/translator/output/http_api_with_cors.json b/tests/translator/output/http_api_with_cors.json index f80c8dafc4..b9e7aa9c26 100644 --- a/tests/translator/output/http_api_with_cors.json +++ b/tests/translator/output/http_api_with_cors.json @@ -2,123 +2,129 @@ "Conditions": { "C1": { "Fn::Equals": [ - true, + true, true ] } - }, + }, "Resources": { "MyApiApiGatewayDefaultStage": { - "Type": "AWS::ApiGatewayV2::Stage", + "Type": "AWS::ApiGatewayV2::Stage", "Properties": { "ApiId": { "Ref": "MyApi" - }, - "AutoDeploy": true, - "StageName": "$default" + }, + "AutoDeploy": true, + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } - }, + }, "ServerlessHttpApiApiGatewayDefaultStage": { - "Type": "AWS::ApiGatewayV2::Stage", + "Type": "AWS::ApiGatewayV2::Stage", "Properties": { "ApiId": { "Ref": "ServerlessHttpApi" - }, - "AutoDeploy": true, - "StageName": "$default" + }, + "AutoDeploy": true, + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } - }, + }, "ServerlessHttpApi": { - "Type": "AWS::ApiGatewayV2::Api", + "Type": "AWS::ApiGatewayV2::Api", "Properties": { "Body": { "info": { - "version": "1.0", + "version": "1.0", "title": { "Ref": "AWS::StackName" } - }, + }, "paths": { "$default": { "x-amazon-apigateway-any-method": { "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", + "httpMethod": "POST", + "type": "aws_proxy", "uri": { "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations" - }, + }, "payloadFormatVersion": "1.0" - }, - "isDefaultRoute": true, + }, + "isDefaultRoute": true, "responses": {} } } - }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], + }, "x-amazon-apigateway-cors": { "Fn::If": [ - "C1", + "C1", { "allowHeaders": [ "x-apigateway-header" - ], + ], "allowMethods": [ "GET" - ], + ], "allowOrigins": [ "https://foo.com" - ], + ], "exposeHeaders": [ "x-amzn-header" ] - }, + }, "AWS::NoValue" ] - }, - "openapi": "3.0.1" + }, + "openapi": "3.0.1", + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } } - }, + }, "HttpApiFunction": { - "Type": "AWS::Lambda::Function", + "Type": "AWS::Lambda::Function", "Properties": { - "Handler": "index.handler", + "Handler": "index.handler", "Code": { "ZipFile": "exports.handler = async (event) => {\n console.log(\"Hello from MyAuthFunction\")\n return {\n statusCode: 200,\n body: JSON.stringify(event),\n headers: {}\n }\n}\n" - }, + }, "Role": { "Fn::GetAtt": [ - "HttpApiFunctionRole", + "HttpApiFunctionRole", "Arn" ] - }, - "Runtime": "nodejs12.x", + }, + "Runtime": "nodejs12.x", "Tags": [ { - "Value": "SAM", + "Value": "SAM", "Key": "lambda:createdBy" } ] } - }, + }, "HttpApiFunctionSimpleCasePermission": { - "Type": "AWS::Lambda::Permission", + "Type": "AWS::Lambda::Permission", "Properties": { - "Action": "lambda:InvokeFunction", - "Principal": "apigateway.amazonaws.com", + "Action": "lambda:InvokeFunction", + "Principal": "apigateway.amazonaws.com", "FunctionName": { "Ref": "HttpApiFunction" - }, + }, "SourceArn": { "Fn::Sub": [ - "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", + "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", { - "__Stage__": "*", + "__Stage__": "*", "__ApiId__": { "Ref": "MyApi" } @@ -126,20 +132,20 @@ ] } } - }, + }, "HttpApiFunctionImplicitApiPermission": { - "Type": "AWS::Lambda::Permission", + "Type": "AWS::Lambda::Permission", "Properties": { - "Action": "lambda:InvokeFunction", - "Principal": "apigateway.amazonaws.com", + "Action": "lambda:InvokeFunction", + "Principal": "apigateway.amazonaws.com", "FunctionName": { "Ref": "HttpApiFunction" - }, + }, "SourceArn": { "Fn::Sub": [ - "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", + "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*", { - "__Stage__": "*", + "__Stage__": "*", "__ApiId__": { "Ref": "ServerlessHttpApi" } @@ -147,18 +153,18 @@ ] } } - }, + }, "HttpApiFunctionRole": { - "Type": "AWS::IAM::Role", + "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { - "Version": "2012-10-17", + "Version": "2012-10-17", "Statement": [ { "Action": [ "sts:AssumeRole" - ], - "Effect": "Allow", + ], + "Effect": "Allow", "Principal": { "Service": [ "lambda.amazonaws.com" @@ -166,70 +172,71 @@ } } ] - }, + }, "ManagedPolicyArns": [ "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], + ], "Tags": [ { - "Value": "SAM", + "Value": "SAM", "Key": "lambda:createdBy" } ] } - }, + }, "MyApi": { - "Type": "AWS::ApiGatewayV2::Api", + "Type": "AWS::ApiGatewayV2::Api", "Properties": { "Body": { "info": { - "version": "1.0", + "version": "1.0", "title": { "Ref": "AWS::StackName" } - }, + }, "paths": { "$default": { "x-amazon-apigateway-any-method": { "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", + "httpMethod": "POST", + "type": "aws_proxy", "uri": { "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations" - }, + }, "payloadFormatVersion": "1.0" - }, - "isDefaultRoute": true, + }, + "isDefaultRoute": true, "responses": {} } } - }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], + }, "x-amazon-apigateway-cors": { "Fn::If": [ - "C1", + "C1", { "allowHeaders": [ "x-apigateway-header" - ], + ], "allowMethods": [ "GET" - ], + ], "allowOrigins": [ "https://foo.com" - ], + ], "exposeHeaders": [ "x-amzn-header" ] - }, + }, "AWS::NoValue" - ] }, - "openapi": "3.0.1" + ] + }, + "openapi": "3.0.1", + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } } } diff --git a/tests/translator/output/implicit_http_api_with_many_conditions.json b/tests/translator/output/implicit_http_api_with_many_conditions.json index ac14371a17..5a221e6ff1 100644 --- a/tests/translator/output/implicit_http_api_with_many_conditions.json +++ b/tests/translator/output/implicit_http_api_with_many_conditions.json @@ -199,12 +199,6 @@ "Ref": "AWS::StackName" } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], "paths": { "/hello/again": { "Fn::If": [ @@ -659,6 +653,7 @@ ] } }, + "openapi": "3.0.1", "components": { "securitySchemes": { "oauth2": { @@ -676,7 +671,12 @@ } } }, - "openapi": "3.0.1" + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } }, "Condition": "ServerlessHttpApiCondition" @@ -1340,7 +1340,10 @@ "Ref": "ServerlessHttpApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } }, "Condition": "ServerlessHttpApiCondition" }, @@ -1476,4 +1479,4 @@ "Condition": "Cond3" } } -} +} \ No newline at end of file From 804a467862e15bcf9524822fb82477a7893c840b Mon Sep 17 00:00:00 2001 From: Keeton Hodgson Date: Thu, 5 Mar 2020 08:28:42 -0800 Subject: [PATCH 2/2] Update tests for tagging generated resources --- samtranslator/model/apigatewayv2.py | 5 ++-- .../api_with_basic_custom_domain_http.json | 10 ++++++-- ...h_basic_custom_domain_intrinsics_http.json | 17 ++++++++++---- ..._domain_route53_hosted_zone_name_http.json | 10 ++++++-- .../api_with_custom_domain_route53_http.json | 10 ++++++-- .../api_with_basic_custom_domain_http.json | 10 ++++++-- ...h_basic_custom_domain_intrinsics_http.json | 13 +++++++++-- ..._domain_route53_hosted_zone_name_http.json | 10 ++++++-- .../api_with_custom_domain_route53_http.json | 10 ++++++-- .../aws-cn/explicit_http_api_minimum.json | 10 ++++++-- .../http_api_existing_openapi_conditions.json | 7 +++++- .../aws-cn/http_api_explicit_stage.json | 3 +++ .../output/aws-cn/implicit_http_api.json | 5 +++- ...mplicit_http_api_auth_and_simple_case.json | 5 +++- ...mplicit_http_api_with_many_conditions.json | 5 +++- .../api_with_basic_custom_domain_http.json | 10 ++++++-- ...h_basic_custom_domain_intrinsics_http.json | 17 ++++++++++---- ..._domain_route53_hosted_zone_name_http.json | 12 +++++++--- .../api_with_custom_domain_route53_http.json | 10 ++++++-- .../aws-us-gov/explicit_http_api_minimum.json | 10 ++++++-- .../http_api_existing_openapi_conditions.json | 7 +++++- .../output/aws-us-gov/implicit_http_api.json | 5 +++- ...mplicit_http_api_auth_and_simple_case.json | 23 +++++++++++-------- ...mplicit_http_api_with_many_conditions.json | 5 +++- .../output/explicit_http_api_minimum.json | 10 ++++++-- tests/translator/output/http_api_def_uri.json | 20 ++++++++-------- .../http_api_existing_openapi_conditions.json | 7 +++++- .../output/http_api_explicit_stage.json | 3 +++ .../translator/output/implicit_http_api.json | 5 +++- ...mplicit_http_api_auth_and_simple_case.json | 5 +++- ...mplicit_http_api_with_many_conditions.json | 5 +++- 31 files changed, 215 insertions(+), 69 deletions(-) diff --git a/samtranslator/model/apigatewayv2.py b/samtranslator/model/apigatewayv2.py index 589560b232..6c880d57ab 100644 --- a/samtranslator/model/apigatewayv2.py +++ b/samtranslator/model/apigatewayv2.py @@ -12,7 +12,6 @@ class ApiGatewayV2HttpApi(Resource): "Description": PropertyType(False, is_str()), "FailOnWarnings": PropertyType(False, is_type(bool)), "BasePath": PropertyType(False, is_str()), - "Tags": PropertyType(False, list_of(is_type(dict))), "CorsConfiguration": PropertyType(False, is_type(dict)), } @@ -29,7 +28,7 @@ class ApiGatewayV2Stage(Resource): "Description": PropertyType(False, is_str()), "ApiId": PropertyType(True, is_str()), "StageName": PropertyType(False, one_of(is_str(), is_type(dict))), - "Tags": PropertyType(False, list_of(is_type(dict))), + "Tags": PropertyType(False, is_type(dict)), "StageVariables": PropertyType(False, is_type(dict)), "AutoDeploy": PropertyType(False, is_type(bool)), } @@ -42,7 +41,7 @@ class ApiGatewayV2DomainName(Resource): property_types = { "DomainName": PropertyType(True, is_str()), "DomainNameConfigurations": PropertyType(False, list_of(is_type(dict))), - "Tags": PropertyType(False, list_of(is_type(dict))), + "Tags": PropertyType(False, is_type(dict)), } diff --git a/tests/translator/output/api_with_basic_custom_domain_http.json b/tests/translator/output/api_with_basic_custom_domain_http.json index c37e4a826e..7bf4fefba7 100644 --- a/tests/translator/output/api_with_basic_custom_domain_http.json +++ b/tests/translator/output/api_with_basic_custom_domain_http.json @@ -32,7 +32,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "Prod" + "StageName": "Prod", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "HttpApiFunction": { @@ -158,7 +161,10 @@ "EndpointType": "REGIONAL" } ], - "DomainName": "sam-v2-regional-test.com" + "DomainName": "sam-v2-regional-test.com", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "MyApi": { diff --git a/tests/translator/output/api_with_basic_custom_domain_intrinsics_http.json b/tests/translator/output/api_with_basic_custom_domain_intrinsics_http.json index 6a85c1dd7e..4d351c3018 100644 --- a/tests/translator/output/api_with_basic_custom_domain_intrinsics_http.json +++ b/tests/translator/output/api_with_basic_custom_domain_intrinsics_http.json @@ -255,14 +255,17 @@ "ApiGatewayDomainNameV2c0ed6fae34": { "Type": "AWS::ApiGatewayV2::DomainName", "Properties": { + "DomainName": { + "Fn::Sub": "example-ap-southeast-1.com" + }, "DomainNameConfigurations": [ { "CertificateArn": "another-api-arn", "EndpointType": "REGIONAL" } ], - "DomainName": { - "Fn::Sub": "example-ap-southeast-1.com" + "Tags": { + "httpapi:createdBy": "SAM" } }, "Condition": "C1" @@ -274,7 +277,10 @@ "Ref": "ServerlessHttpApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } }, "Condition": "C1" }, @@ -285,7 +291,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "Prod" + "StageName": "Prod", + "Tags": { + "httpapi:createdBy": "SAM" + } }, "Condition": "C1" }, diff --git a/tests/translator/output/api_with_custom_domain_route53_hosted_zone_name_http.json b/tests/translator/output/api_with_custom_domain_route53_hosted_zone_name_http.json index 5c1096fd72..d3351418d8 100644 --- a/tests/translator/output/api_with_custom_domain_route53_hosted_zone_name_http.json +++ b/tests/translator/output/api_with_custom_domain_route53_hosted_zone_name_http.json @@ -39,7 +39,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "Prod" + "StageName": "Prod", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "MyApioneApiMapping": { @@ -60,13 +63,16 @@ "ApiGatewayDomainNameV20caaf24ab1": { "Type": "AWS::ApiGatewayV2::DomainName", "Properties": { + "DomainName": "example.com", "DomainNameConfigurations": [ { "CertificateArn": "cert-arn-in-us-east-1", "EndpointType": "EDGE" } ], - "DomainName": "example.com" + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "RecordSetGroup456ebaf280": { diff --git a/tests/translator/output/api_with_custom_domain_route53_http.json b/tests/translator/output/api_with_custom_domain_route53_http.json index 0a24aca116..92bb463f52 100644 --- a/tests/translator/output/api_with_custom_domain_route53_http.json +++ b/tests/translator/output/api_with_custom_domain_route53_http.json @@ -84,13 +84,16 @@ "ApiGatewayDomainNameV20caaf24ab1": { "Type": "AWS::ApiGatewayV2::DomainName", "Properties": { + "DomainName": "example.com", "DomainNameConfigurations": [ { "CertificateArn": "cert-arn-in-us-east-1", "EndpointType": "EDGE" } ], - "DomainName": "example.com" + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "MyApiProdStage": { @@ -100,7 +103,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "Prod" + "StageName": "Prod", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "MyFunctionRole": { diff --git a/tests/translator/output/aws-cn/api_with_basic_custom_domain_http.json b/tests/translator/output/aws-cn/api_with_basic_custom_domain_http.json index 744faa7444..64561b3b69 100644 --- a/tests/translator/output/aws-cn/api_with_basic_custom_domain_http.json +++ b/tests/translator/output/aws-cn/api_with_basic_custom_domain_http.json @@ -32,7 +32,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "Prod" + "StageName": "Prod", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "HttpApiFunction": { @@ -152,13 +155,16 @@ "ApiGatewayDomainNameV2ab8e63947d": { "Type": "AWS::ApiGatewayV2::DomainName", "Properties": { + "DomainName": "sam-v2-regional-test.com", "DomainNameConfigurations": [ { "CertificateArn": "arn:aws:acm:us-east-1:551213647843:certificate/6c911401-620d-4d41-b89e-366c238bb2f3", "EndpointType": "REGIONAL" } ], - "DomainName": "sam-v2-regional-test.com" + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "MyApi": { diff --git a/tests/translator/output/aws-cn/api_with_basic_custom_domain_intrinsics_http.json b/tests/translator/output/aws-cn/api_with_basic_custom_domain_intrinsics_http.json index 55846f7ad9..e6dbc7df18 100644 --- a/tests/translator/output/aws-cn/api_with_basic_custom_domain_intrinsics_http.json +++ b/tests/translator/output/aws-cn/api_with_basic_custom_domain_intrinsics_http.json @@ -48,7 +48,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "Prod" + "StageName": "Prod", + "Tags": { + "httpapi:createdBy": "SAM" + } }, "Condition": "C1" }, @@ -176,6 +179,9 @@ ], "DomainName": { "Fn::Sub": "example-cn-north-1.com" + }, + "Tags": { + "httpapi:createdBy": "SAM" } }, "Condition": "C1" @@ -225,7 +231,10 @@ "Ref": "ServerlessHttpApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } }, "Condition": "C1" }, diff --git a/tests/translator/output/aws-cn/api_with_custom_domain_route53_hosted_zone_name_http.json b/tests/translator/output/aws-cn/api_with_custom_domain_route53_hosted_zone_name_http.json index 73714c6cdf..f614884a85 100644 --- a/tests/translator/output/aws-cn/api_with_custom_domain_route53_hosted_zone_name_http.json +++ b/tests/translator/output/aws-cn/api_with_custom_domain_route53_hosted_zone_name_http.json @@ -39,7 +39,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "Prod" + "StageName": "Prod", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "MyApioneApiMapping": { @@ -66,7 +69,10 @@ "EndpointType": "EDGE" } ], - "DomainName": "example.com" + "DomainName": "example.com", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "RecordSetGroup456ebaf280": { diff --git a/tests/translator/output/aws-cn/api_with_custom_domain_route53_http.json b/tests/translator/output/aws-cn/api_with_custom_domain_route53_http.json index 82bb133608..f4067c80b0 100644 --- a/tests/translator/output/aws-cn/api_with_custom_domain_route53_http.json +++ b/tests/translator/output/aws-cn/api_with_custom_domain_route53_http.json @@ -84,13 +84,16 @@ "ApiGatewayDomainNameV20caaf24ab1": { "Type": "AWS::ApiGatewayV2::DomainName", "Properties": { + "DomainName": "example.com", "DomainNameConfigurations": [ { "CertificateArn": "cert-arn-in-us-east-1", "EndpointType": "EDGE" } ], - "DomainName": "example.com" + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "MyApiProdStage": { @@ -100,7 +103,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "Prod" + "StageName": "Prod", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "MyFunctionRole": { diff --git a/tests/translator/output/aws-cn/explicit_http_api_minimum.json b/tests/translator/output/aws-cn/explicit_http_api_minimum.json index 01e8424af4..4a7270a868 100644 --- a/tests/translator/output/aws-cn/explicit_http_api_minimum.json +++ b/tests/translator/output/aws-cn/explicit_http_api_minimum.json @@ -138,7 +138,10 @@ "Ref": "ServerlessHttpApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "ApiApiGatewayDefaultStage": { @@ -148,7 +151,10 @@ "Ref": "Api" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } } } diff --git a/tests/translator/output/aws-cn/http_api_existing_openapi_conditions.json b/tests/translator/output/aws-cn/http_api_existing_openapi_conditions.json index 2e839b97a1..1b70975cc7 100644 --- a/tests/translator/output/aws-cn/http_api_existing_openapi_conditions.json +++ b/tests/translator/output/aws-cn/http_api_existing_openapi_conditions.json @@ -37,7 +37,12 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM", + "Tag1": "value1", + "Tag2": "value2" + } } }, "HttpApiFunction": { diff --git a/tests/translator/output/aws-cn/http_api_explicit_stage.json b/tests/translator/output/aws-cn/http_api_explicit_stage.json index 1865807fc3..e08e284090 100644 --- a/tests/translator/output/aws-cn/http_api_explicit_stage.json +++ b/tests/translator/output/aws-cn/http_api_explicit_stage.json @@ -69,6 +69,9 @@ "ThrottlingBurstLimit": 300, "LoggingLevel": "INFO" } + }, + "Tags": { + "httpapi:createdBy": "SAM" } } }, diff --git a/tests/translator/output/aws-cn/implicit_http_api.json b/tests/translator/output/aws-cn/implicit_http_api.json index 72bb1a03d3..1769e0cd4e 100644 --- a/tests/translator/output/aws-cn/implicit_http_api.json +++ b/tests/translator/output/aws-cn/implicit_http_api.json @@ -7,7 +7,10 @@ "Ref": "ServerlessHttpApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "HttpApiFunctionRole": { diff --git a/tests/translator/output/aws-cn/implicit_http_api_auth_and_simple_case.json b/tests/translator/output/aws-cn/implicit_http_api_auth_and_simple_case.json index 48f64be9c1..64d0c153a3 100644 --- a/tests/translator/output/aws-cn/implicit_http_api_auth_and_simple_case.json +++ b/tests/translator/output/aws-cn/implicit_http_api_auth_and_simple_case.json @@ -7,7 +7,10 @@ "Ref": "ServerlessHttpApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "RestApiFunctionRole": { diff --git a/tests/translator/output/aws-cn/implicit_http_api_with_many_conditions.json b/tests/translator/output/aws-cn/implicit_http_api_with_many_conditions.json index f2891303cc..3469cc26fd 100644 --- a/tests/translator/output/aws-cn/implicit_http_api_with_many_conditions.json +++ b/tests/translator/output/aws-cn/implicit_http_api_with_many_conditions.json @@ -1364,7 +1364,10 @@ ] } }, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } }, "Condition": "ServerlessHttpApiCondition" }, diff --git a/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_http.json b/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_http.json index 589b610a23..691caa2faa 100644 --- a/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_http.json +++ b/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_http.json @@ -32,7 +32,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "Prod" + "StageName": "Prod", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "HttpApiFunction": { @@ -158,7 +161,10 @@ "EndpointType": "REGIONAL" } ], - "DomainName": "sam-v2-regional-test.com" + "DomainName": "sam-v2-regional-test.com", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "MyApi": { diff --git a/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_intrinsics_http.json b/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_intrinsics_http.json index f786841828..1086f4a048 100644 --- a/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_intrinsics_http.json +++ b/tests/translator/output/aws-us-gov/api_with_basic_custom_domain_intrinsics_http.json @@ -48,7 +48,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "Prod" + "StageName": "Prod", + "Tags": { + "httpapi:createdBy": "SAM" + } }, "Condition": "C1" }, @@ -168,14 +171,17 @@ "ApiGatewayDomainNameV29c93aac102": { "Type": "AWS::ApiGatewayV2::DomainName", "Properties": { + "DomainName": { + "Fn::Sub": "example-us-gov-west-1.com" + }, "DomainNameConfigurations": [ { "CertificateArn": "another-api-arn", "EndpointType": "REGIONAL" } ], - "DomainName": { - "Fn::Sub": "example-us-gov-west-1.com" + "Tags": { + "httpapi:createdBy": "SAM" } }, "Condition": "C1" @@ -225,7 +231,10 @@ "Ref": "ServerlessHttpApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } }, "Condition": "C1" }, diff --git a/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_hosted_zone_name_http.json b/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_hosted_zone_name_http.json index 821e6bc248..d46cce973a 100644 --- a/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_hosted_zone_name_http.json +++ b/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_hosted_zone_name_http.json @@ -39,7 +39,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "Prod" + "StageName": "Prod", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "MyApioneApiMapping": { @@ -60,13 +63,16 @@ "ApiGatewayDomainNameV20caaf24ab1": { "Type": "AWS::ApiGatewayV2::DomainName", "Properties": { + "DomainName": "example.com", "DomainNameConfigurations": [ { "CertificateArn": "cert-arn-in-us-east-1", "EndpointType": "EDGE" } ], - "DomainName": "example.com" + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "RecordSetGroup456ebaf280": { @@ -177,4 +183,4 @@ } } } -} +} \ No newline at end of file diff --git a/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_http.json b/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_http.json index 956e7ac727..15b6346051 100644 --- a/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_http.json +++ b/tests/translator/output/aws-us-gov/api_with_custom_domain_route53_http.json @@ -84,13 +84,16 @@ "ApiGatewayDomainNameV20caaf24ab1": { "Type": "AWS::ApiGatewayV2::DomainName", "Properties": { + "DomainName": "example.com", "DomainNameConfigurations": [ { "CertificateArn": "cert-arn-in-us-east-1", "EndpointType": "EDGE" } ], - "DomainName": "example.com" + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "MyApiProdStage": { @@ -100,7 +103,10 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "Prod" + "StageName": "Prod", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "MyFunctionRole": { diff --git a/tests/translator/output/aws-us-gov/explicit_http_api_minimum.json b/tests/translator/output/aws-us-gov/explicit_http_api_minimum.json index 0a35ee12b5..205c7c1555 100644 --- a/tests/translator/output/aws-us-gov/explicit_http_api_minimum.json +++ b/tests/translator/output/aws-us-gov/explicit_http_api_minimum.json @@ -138,7 +138,10 @@ "Ref": "ServerlessHttpApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "ApiApiGatewayDefaultStage": { @@ -148,7 +151,10 @@ "Ref": "Api" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } } } diff --git a/tests/translator/output/aws-us-gov/http_api_existing_openapi_conditions.json b/tests/translator/output/aws-us-gov/http_api_existing_openapi_conditions.json index 07e7c51583..e5eb69fb2e 100644 --- a/tests/translator/output/aws-us-gov/http_api_existing_openapi_conditions.json +++ b/tests/translator/output/aws-us-gov/http_api_existing_openapi_conditions.json @@ -37,7 +37,12 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM", + "Tag1": "value1", + "Tag2": "value2" + } } }, "HttpApiFunction": { diff --git a/tests/translator/output/aws-us-gov/implicit_http_api.json b/tests/translator/output/aws-us-gov/implicit_http_api.json index aaee74da6e..46660faf30 100644 --- a/tests/translator/output/aws-us-gov/implicit_http_api.json +++ b/tests/translator/output/aws-us-gov/implicit_http_api.json @@ -7,7 +7,10 @@ "Ref": "ServerlessHttpApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "HttpApiFunctionRole": { diff --git a/tests/translator/output/aws-us-gov/implicit_http_api_auth_and_simple_case.json b/tests/translator/output/aws-us-gov/implicit_http_api_auth_and_simple_case.json index 4e4d6387f8..2b25df5d70 100644 --- a/tests/translator/output/aws-us-gov/implicit_http_api_auth_and_simple_case.json +++ b/tests/translator/output/aws-us-gov/implicit_http_api_auth_and_simple_case.json @@ -7,7 +7,10 @@ "Ref": "ServerlessHttpApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "RestApiFunctionRole": { @@ -55,7 +58,7 @@ "Arn" ] }, - "Runtime": "nodejs12.x", + "Runtime": "nodejs12.x", "Tags": [ { "Value": "SAM", @@ -95,12 +98,6 @@ "Ref": "AWS::StackName" } }, - "tags": [ - { - "name": "httpapi:createdBy", - "x-amazon-apigateway-tag-value": "SAM" - } - ], "paths": { "/scope3": { "post": { @@ -225,6 +222,7 @@ } } }, + "openapi": "3.0.1", "components": { "securitySchemes": { "oauth2Auth": { @@ -256,9 +254,14 @@ } } }, - "openapi": "3.0.1" + "tags": [ + { + "name": "httpapi:createdBy", + "x-amazon-apigateway-tag-value": "SAM" + } + ] } } } } -} +} \ No newline at end of file diff --git a/tests/translator/output/aws-us-gov/implicit_http_api_with_many_conditions.json b/tests/translator/output/aws-us-gov/implicit_http_api_with_many_conditions.json index 24c96e8334..10fbf280fb 100644 --- a/tests/translator/output/aws-us-gov/implicit_http_api_with_many_conditions.json +++ b/tests/translator/output/aws-us-gov/implicit_http_api_with_many_conditions.json @@ -1364,7 +1364,10 @@ ] } }, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } }, "Condition": "ServerlessHttpApiCondition" }, diff --git a/tests/translator/output/explicit_http_api_minimum.json b/tests/translator/output/explicit_http_api_minimum.json index 6695f3404e..bb8fa7b6f3 100644 --- a/tests/translator/output/explicit_http_api_minimum.json +++ b/tests/translator/output/explicit_http_api_minimum.json @@ -138,7 +138,10 @@ "Ref": "ServerlessHttpApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "ApiApiGatewayDefaultStage": { @@ -148,7 +151,10 @@ "Ref": "Api" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } } } diff --git a/tests/translator/output/http_api_def_uri.json b/tests/translator/output/http_api_def_uri.json index e6a1041ffa..fd5dedd146 100644 --- a/tests/translator/output/http_api_def_uri.json +++ b/tests/translator/output/http_api_def_uri.json @@ -45,14 +45,14 @@ "MyApiStage": { "Type": "AWS::ApiGatewayV2::Stage", "Properties": { + "AutoDeploy": true, "ApiId": { "Ref": "MyApi" }, - "AutoDeploy": true, "DefaultRouteSettings": { - "ThrottlingBurstLimit": 50, + "ThrottlingBurstLimit": 50, "ThrottlingRateLimit": 100.0 - }, + }, "StageName": { "Fn::Join": [ "", @@ -67,9 +67,6 @@ "FunctionRole": { "Type": "AWS::IAM::Role", "Properties": { - "ManagedPolicyArns": [ - "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ @@ -86,6 +83,9 @@ } ] }, + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], "Tags": [ { "Value": "SAM", @@ -97,13 +97,13 @@ "MyApi2ApiGatewayDefaultStage": { "Type": "AWS::ApiGatewayV2::Stage", "Properties": { + "AutoDeploy": true, "ApiId": { "Ref": "MyApi2" }, - "AutoDeploy": true, "DefaultRouteSettings": { - "ThrottlingRateLimit": 100 - }, + "ThrottlingRateLimit": 100.0 + }, "StageName": "$default" } }, @@ -148,4 +148,4 @@ } } } -} +} \ No newline at end of file diff --git a/tests/translator/output/http_api_existing_openapi_conditions.json b/tests/translator/output/http_api_existing_openapi_conditions.json index 9dd6bcace4..5a4df14edf 100644 --- a/tests/translator/output/http_api_existing_openapi_conditions.json +++ b/tests/translator/output/http_api_existing_openapi_conditions.json @@ -37,7 +37,12 @@ "Ref": "MyApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM", + "Tag1": "value1", + "Tag2": "value2" + } } }, "HttpApiFunction": { diff --git a/tests/translator/output/http_api_explicit_stage.json b/tests/translator/output/http_api_explicit_stage.json index f0adc81739..3ac88c6a4a 100644 --- a/tests/translator/output/http_api_explicit_stage.json +++ b/tests/translator/output/http_api_explicit_stage.json @@ -69,6 +69,9 @@ "ThrottlingBurstLimit": 300, "LoggingLevel": "INFO" } + }, + "Tags": { + "httpapi:createdBy": "SAM" } } }, diff --git a/tests/translator/output/implicit_http_api.json b/tests/translator/output/implicit_http_api.json index 6218d21173..31bab67999 100644 --- a/tests/translator/output/implicit_http_api.json +++ b/tests/translator/output/implicit_http_api.json @@ -7,7 +7,10 @@ "Ref": "ServerlessHttpApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "HttpApiFunctionRole": { diff --git a/tests/translator/output/implicit_http_api_auth_and_simple_case.json b/tests/translator/output/implicit_http_api_auth_and_simple_case.json index efcd8d3bbd..e23e412869 100644 --- a/tests/translator/output/implicit_http_api_auth_and_simple_case.json +++ b/tests/translator/output/implicit_http_api_auth_and_simple_case.json @@ -7,7 +7,10 @@ "Ref": "ServerlessHttpApi" }, "AutoDeploy": true, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } } }, "RestApiFunctionRole": { diff --git a/tests/translator/output/implicit_http_api_with_many_conditions.json b/tests/translator/output/implicit_http_api_with_many_conditions.json index b653dc3f0e..1d7a3e9c21 100644 --- a/tests/translator/output/implicit_http_api_with_many_conditions.json +++ b/tests/translator/output/implicit_http_api_with_many_conditions.json @@ -1364,7 +1364,10 @@ ] } }, - "StageName": "$default" + "StageName": "$default", + "Tags": { + "httpapi:createdBy": "SAM" + } }, "Condition": "ServerlessHttpApiCondition" },