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/open_api/open_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ def get_integration_function_logical_id(self, path_name, method_name):

# Extract the integration uri out of a conditional if necessary
uri = integration.get("uri")
if not isinstance(uri, dict):
return ""
if self._CONDITIONAL_IF in uri:
arn = uri[self._CONDITIONAL_IF][1].get("Fn::Sub")
else:
arn = uri.get("Fn::Sub")
arn = uri.get("Fn::Sub", "")

# Extract lambda integration (${LambdaName.Arn}) and split ".Arn" off from it
regex = "([A-Za-z0-9]+\.Arn)"
Expand Down
22 changes: 20 additions & 2 deletions tests/translator/input/explicit_http_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ Resources:
Type: HttpApi
Properties:
ApiId: !Ref MyApi
SimpleCase2:
BasePath:
Type: HttpApi
Properties:
ApiId: !Ref MyApi2
Path: /
Method: get
MyApi:
Type: AWS::Serverless::HttpApi
Properties:
Expand All @@ -40,4 +42,20 @@ Resources:
audience:
- MyApi
IdentitySource: "$request.querystring.param"
DefaultAuthorizer: OAuth2
DefaultAuthorizer: OAuth2
DefinitionBody:
openapi: '3.0'
info:
title: !Sub ${AWS::StackName}-Apiv2
paths:
/:
get:
responses: {}
$default:
x-amazon-apigateway-any-method:
isDefaultRoute: true
x-amazon-apigateway-integration:
httpMethod: ANY
type: http_proxy
uri: https://www.alphavantage.co/
payloadFormatVersion: '1.0'
26 changes: 20 additions & 6 deletions tests/translator/output/aws-cn/explicit_http_api.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,29 @@
"Properties": {
"Body": {
"info": {
"version": "1.0",
"title": {
"Ref": "AWS::StackName"
"Fn::Sub": "${AWS::StackName}-Apiv2"
}
},
"paths": {
"$default": {
"x-amazon-apigateway-any-method": {
"x-amazon-apigateway-integration": {
"httpMethod": "ANY",
"type": "http_proxy",
"uri": "https://www.alphavantage.co/",
"payloadFormatVersion": "1.0"
},
"isDefaultRoute": true,
"security": [
{
"OAuth2": []
}
]
}
},
"/": {
"get": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
Expand All @@ -91,7 +106,6 @@
},
"payloadFormatVersion": "1.0"
},
"isDefaultRoute": true,
"security": [
{
"OAuth2": []
Expand All @@ -101,7 +115,7 @@
}
}
},
"openapi": "3.0.1",
"openapi": "3.0",
"components": {
"securitySchemes": {
"OAuth2": {
Expand Down Expand Up @@ -158,7 +172,7 @@
]
}
},
"HttpApiFunctionSimpleCase2Permission": {
"HttpApiFunctionBasePathPermission": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
Expand All @@ -168,7 +182,7 @@
},
"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__}/GET/",
{
"__Stage__": "*",
"__ApiId__": {
Expand Down
26 changes: 20 additions & 6 deletions tests/translator/output/aws-us-gov/explicit_http_api.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,29 @@
"Properties": {
"Body": {
"info": {
"version": "1.0",
"title": {
"Ref": "AWS::StackName"
"Fn::Sub": "${AWS::StackName}-Apiv2"
}
},
"paths": {
"$default": {
"x-amazon-apigateway-any-method": {
"x-amazon-apigateway-integration": {
"httpMethod": "ANY",
"type": "http_proxy",
"uri": "https://www.alphavantage.co/",
"payloadFormatVersion": "1.0"
},
"isDefaultRoute": true,
"security": [
{
"OAuth2": []
}
]
}
},
"/": {
"get": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
Expand All @@ -91,7 +106,6 @@
},
"payloadFormatVersion": "1.0"
},
"isDefaultRoute": true,
"security": [
{
"OAuth2": []
Expand All @@ -101,7 +115,7 @@
}
}
},
"openapi": "3.0.1",
"openapi": "3.0",
"components": {
"securitySchemes": {
"OAuth2": {
Expand Down Expand Up @@ -158,7 +172,7 @@
]
}
},
"HttpApiFunctionSimpleCase2Permission": {
"HttpApiFunctionBasePathPermission": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
Expand All @@ -168,7 +182,7 @@
},
"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__}/GET/",
{
"__Stage__": "*",
"__ApiId__": {
Expand Down
26 changes: 20 additions & 6 deletions tests/translator/output/explicit_http_api.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,29 @@
"Properties": {
"Body": {
"info": {
"version": "1.0",
"title": {
"Ref": "AWS::StackName"
"Fn::Sub": "${AWS::StackName}-Apiv2"
}
},
"paths": {
"$default": {
"x-amazon-apigateway-any-method": {
"x-amazon-apigateway-integration": {
"httpMethod": "ANY",
"type": "http_proxy",
"uri": "https://www.alphavantage.co/",
"payloadFormatVersion": "1.0"
},
"isDefaultRoute": true,
"security": [
{
"OAuth2": []
}
]
}
},
"/": {
"get": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
Expand All @@ -91,7 +106,6 @@
},
"payloadFormatVersion": "1.0"
},
"isDefaultRoute": true,
"security": [
{
"OAuth2": []
Expand All @@ -101,7 +115,7 @@
}
}
},
"openapi": "3.0.1",
"openapi": "3.0",
"components": {
"securitySchemes": {
"OAuth2": {
Expand Down Expand Up @@ -158,7 +172,7 @@
]
}
},
"HttpApiFunctionSimpleCase2Permission": {
"HttpApiFunctionBasePathPermission": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
Expand All @@ -168,7 +182,7 @@
},
"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__}/GET/",
{
"__Stage__": "*",
"__ApiId__": {
Expand Down