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
12 changes: 11 additions & 1 deletion samtranslator/model/sam_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
from .s3_utils.uri_parser import construct_s3_location_object
from .tags.resource_tagging import get_tag_list
from samtranslator.model import PropertyType, SamResourceMacro, ResourceTypeResolver
from samtranslator.model.apigateway import ApiGatewayDeployment, ApiGatewayStage, ApiGatewayDomainName
from samtranslator.model.apigateway import (
ApiGatewayDeployment,
ApiGatewayStage,
ApiGatewayDomainName,
ApiGatewayUsagePlan,
ApiGatewayUsagePlanKey,
ApiGatewayApiKey,
)
from samtranslator.model.apigatewayv2 import ApiGatewayV2Stage
from samtranslator.model.cloudformation import NestedStack
from samtranslator.model.dynamodb import DynamoDBTable
Expand Down Expand Up @@ -764,6 +771,9 @@ class SamApi(SamResourceMacro):
"Stage": ApiGatewayStage.resource_type,
"Deployment": ApiGatewayDeployment.resource_type,
"DomainName": ApiGatewayDomainName.resource_type,
"UsagePlan": ApiGatewayUsagePlan.resource_type,
"UsagePlanKey": ApiGatewayUsagePlanKey.resource_type,
"ApiKey": ApiGatewayApiKey.resource_type,
}

def to_cloudformation(self, **kwargs):
Expand Down
12 changes: 12 additions & 0 deletions tests/translator/input/api_with_usageplans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,15 @@ Outputs:
Description: "API endpoint URL for Prod environment"
Value:
Fn::Sub: 'https://${MyApiThree}.execute-api.${AWS::Region}.amazonaws.com/Prod/'
UsagePlan:
Description: "Usage Plan physical Id"
Value:
!Ref MyApiTwo.UsagePlan
UsagePlanKey:
Description: "Usage Plan Key"
Value:
!Ref MyApiTwo.UsagePlanKey
ApiKey:
Description: "Api Key"
Value:
!Ref MyApiThree.ApiKey
18 changes: 18 additions & 0 deletions tests/translator/output/api_with_usageplans.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@
"Value": {
"Fn::Sub": "https://${MyApiOne}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
}
},
"ApiKey": {
"Description": "Api Key",
"Value": {
"Ref": "ServerlessApiKey"
}
},
"UsagePlanKey": {
"Description": "Usage Plan Key",
"Value": {
"Ref": "MyApiTwoUsagePlanKey"
}
},
"UsagePlan": {
"Description": "Usage Plan physical Id",
"Value": {
"Ref": "MyApiTwoUsagePlan"
}
}
},
"Resources": {
Expand Down
18 changes: 18 additions & 0 deletions tests/translator/output/aws-cn/api_with_usageplans.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@
"Value": {
"Fn::Sub": "https://${MyApiOne}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
}
},
"ApiKey": {
"Description": "Api Key",
"Value": {
"Ref": "ServerlessApiKey"
}
},
"UsagePlanKey": {
"Description": "Usage Plan Key",
"Value": {
"Ref": "MyApiTwoUsagePlanKey"
}
},
"UsagePlan": {
"Description": "Usage Plan physical Id",
"Value": {
"Ref": "MyApiTwoUsagePlan"
}
}
},
"Resources": {
Expand Down
18 changes: 18 additions & 0 deletions tests/translator/output/aws-us-gov/api_with_usageplans.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@
"Value": {
"Fn::Sub": "https://${MyApiOne}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
}
},
"ApiKey": {
"Description": "Api Key",
"Value": {
"Ref": "ServerlessApiKey"
}
},
"UsagePlanKey": {
"Description": "Usage Plan Key",
"Value": {
"Ref": "MyApiTwoUsagePlanKey"
}
},
"UsagePlan": {
"Description": "Usage Plan physical Id",
"Value": {
"Ref": "MyApiTwoUsagePlan"
}
}
},
"Resources": {
Expand Down