Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion samtranslator/model/api/http_api_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,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:
Expand Down Expand Up @@ -492,13 +493,14 @@ 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
stage.RouteSettings = self.route_settings

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
Expand Down
5 changes: 2 additions & 3 deletions samtranslator/model/apigatewayv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
}

Expand All @@ -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)),
}
Expand All @@ -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)),
}


Expand Down
10 changes: 8 additions & 2 deletions tests/translator/output/api_with_basic_custom_domain_http.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
"Ref": "MyApi"
},
"AutoDeploy": true,
"StageName": "Prod"
"StageName": "Prod",
"Tags": {
"httpapi:createdBy": "SAM"
}
}
},
"HttpApiFunction": {
Expand Down Expand Up @@ -158,7 +161,10 @@
"EndpointType": "REGIONAL"
}
],
"DomainName": "sam-v2-regional-test.com"
"DomainName": "sam-v2-regional-test.com",
"Tags": {
"httpapi:createdBy": "SAM"
}
}
},
"MyApi": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -274,7 +277,10 @@
"Ref": "ServerlessHttpApi"
},
"AutoDeploy": true,
"StageName": "$default"
"StageName": "$default",
"Tags": {
"httpapi:createdBy": "SAM"
}
},
"Condition": "C1"
},
Expand All @@ -285,7 +291,10 @@
"Ref": "MyApi"
},
"AutoDeploy": true,
"StageName": "Prod"
"StageName": "Prod",
"Tags": {
"httpapi:createdBy": "SAM"
}
},
"Condition": "C1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
"Ref": "MyApi"
},
"AutoDeploy": true,
"StageName": "Prod"
"StageName": "Prod",
"Tags": {
"httpapi:createdBy": "SAM"
}
}
},
"MyApioneApiMapping": {
Expand All @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -100,7 +103,10 @@
"Ref": "MyApi"
},
"AutoDeploy": true,
"StageName": "Prod"
"StageName": "Prod",
"Tags": {
"httpapi:createdBy": "SAM"
}
}
},
"MyFunctionRole": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
"Ref": "MyApi"
},
"AutoDeploy": true,
"StageName": "Prod"
"StageName": "Prod",
"Tags": {
"httpapi:createdBy": "SAM"
}
}
},
"HttpApiFunction": {
Expand Down Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@
"Ref": "MyApi"
},
"AutoDeploy": true,
"StageName": "Prod"
"StageName": "Prod",
"Tags": {
"httpapi:createdBy": "SAM"
}
},
"Condition": "C1"
},
Expand Down Expand Up @@ -176,6 +179,9 @@
],
"DomainName": {
"Fn::Sub": "example-cn-north-1.com"
},
"Tags": {
"httpapi:createdBy": "SAM"
}
},
"Condition": "C1"
Expand Down Expand Up @@ -225,7 +231,10 @@
"Ref": "ServerlessHttpApi"
},
"AutoDeploy": true,
"StageName": "$default"
"StageName": "$default",
"Tags": {
"httpapi:createdBy": "SAM"
}
},
"Condition": "C1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
"Ref": "MyApi"
},
"AutoDeploy": true,
"StageName": "Prod"
"StageName": "Prod",
"Tags": {
"httpapi:createdBy": "SAM"
}
}
},
"MyApioneApiMapping": {
Expand All @@ -66,7 +69,10 @@
"EndpointType": "EDGE"
}
],
"DomainName": "example.com"
"DomainName": "example.com",
"Tags": {
"httpapi:createdBy": "SAM"
}
}
},
"RecordSetGroup456ebaf280": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -100,7 +103,10 @@
"Ref": "MyApi"
},
"AutoDeploy": true,
"StageName": "Prod"
"StageName": "Prod",
"Tags": {
"httpapi:createdBy": "SAM"
}
}
},
"MyFunctionRole": {
Expand Down
40 changes: 23 additions & 17 deletions tests/translator/output/aws-cn/explicit_http_api.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"Ref": "MyApi"
},
"AutoDeploy": true,
"StageName": "$default"
"StageName": "$default",
"Tags": {
"httpapi:createdBy": "SAM"
}
}
},
"MyApi2ApiGatewayDefaultStage": {
Expand All @@ -17,7 +20,10 @@
"Ref": "MyApi2"
},
"AutoDeploy": true,
"StageName": "$default"
"StageName": "$default",
"Tags": {
"httpapi:createdBy": "SAM"
}
}
},
"HttpApiFunction": {
Expand Down Expand Up @@ -74,12 +80,6 @@
"Ref": "AWS::StackName"
}
},
"tags": [
{
"name": "httpapi:createdBy",
"x-amazon-apigateway-tag-value": "SAM"
}
],
"paths": {
"$default": {
"x-amazon-apigateway-any-method": {
Expand All @@ -101,6 +101,7 @@
}
}
},
"openapi": "3.0.1",
"components": {
"securitySchemes": {
"OAuth2": {
Expand All @@ -118,7 +119,12 @@
}
}
},
"openapi": "3.0.1"
"tags": [
{
"name": "httpapi:createdBy",
"x-amazon-apigateway-tag-value": "SAM"
}
]
}
}
},
Expand Down Expand Up @@ -183,12 +189,6 @@
"Ref": "AWS::StackName"
}
},
"tags": [
{
"name": "httpapi:createdBy",
"x-amazon-apigateway-tag-value": "SAM"
}
],
"paths": {
"$default": {
"x-amazon-apigateway-any-method": {
Expand All @@ -212,6 +212,7 @@
}
}
},
"openapi": "3.0.1",
"components": {
"securitySchemes": {
"OAuth2": {
Expand All @@ -229,9 +230,14 @@
}
}
},
"openapi": "3.0.1"
"tags": [
{
"name": "httpapi:createdBy",
"x-amazon-apigateway-tag-value": "SAM"
}
]
}
}
}
}
}
}
Loading