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
81 changes: 81 additions & 0 deletions tests/translator/input/definition_body_intrinsics_support.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
DefinitionBody currently only supports intrinsics when SwaggerEditor/OpenApiEditor is not used (as of 2022-05-30).
Let's add tests to make sure we keep this support, because we've had a regression where we accidentally
removed this intrinsics support by using the SwaggerEditor.
Note that the only supported intrinsic function for DefinitionBody is Fn::If. Other intrinsics are not supported
because they don't resolve to dictionary.

Conditions:
FalseCondition:
Fn::Equals:
- true
- false

Resources:
# Rest Api with DefinitionBody under If intrinsic, SwaggerEditor not used
RestApiIfIntrinsicAndNoSwaggerEditor:
Type: AWS::Serverless::Api
Properties:
StageName: prod
DefinitionBody:
Fn::If:
- FalseCondition
-
swagger: '2.0'
info:
title: !Sub ${AWS::StackName}-Api
paths:
/post:
post:
x-amazon-apigateway-integration:
httpMethod: POST
type: aws_proxy
uri: https://www.alphavantage.co/
payloadFormatVersion: '1.0'
-
swagger: '2.0'
info:
title: !Sub ${AWS::StackName}-Api
paths:
/post:
post:
x-amazon-apigateway-integration:
httpMethod: POST
type: aws_proxy
uri: https://www.otheruri.co/
payloadFormatVersion: '1.0'

# HttpApi with DefinitionBody under If intrinsic, OpenApiEditor not used
HttpApiIfIntrinsicAndNoOpenApiEditor:
Type: AWS::Serverless::HttpApi
Properties:
StageName: prod
DefinitionBody:
Fn::If:
- FalseCondition
-
openapi: '3.0'
info:
title: !Sub ${AWS::StackName}-Api
paths:
/post:
post:
x-amazon-apigateway-integration:
httpMethod: POST
type: aws_proxy
uri: https://www.alphavantage.co/
payloadFormatVersion: '1.0'
-
openapi: '3.0'
info:
title: !Sub ${AWS::StackName}-Api
paths:
/post:
post:
x-amazon-apigateway-integration:
httpMethod: POST
type: aws_proxy
uri: https://www.otheruri.co/
payloadFormatVersion: '1.0'
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "DefinitionBody currently only supports intrinsics when SwaggerEditor/OpenApiEditor is not used (as of 2022-05-30). Let's add tests to make sure we keep this support, because we've had a regression where we accidentally removed this intrinsics support by using the SwaggerEditor. Note that the only supported intrinsic function for DefinitionBody is Fn::If. Other intrinsics are not supported because they don't resolve to dictionary. \n",
"Conditions": {
"FalseCondition": {
"Fn::Equals": [
true,
false
]
}
},
"Resources": {
"RestApiIfIntrinsicAndNoSwaggerEditorDeployment2f0411dccd": {
"Type": "AWS::ApiGateway::Deployment",
"Properties": {
"Description": "RestApi deployment id: 2f0411dccde517dcb5c82d3848dbc431e7479ebc",
"RestApiId": {
"Ref": "RestApiIfIntrinsicAndNoSwaggerEditor"
},
"StageName": "Stage"
}
},
"RestApiIfIntrinsicAndNoSwaggerEditorprodStage": {
"Type": "AWS::ApiGateway::Stage",
"Properties": {
"DeploymentId": {
"Ref": "RestApiIfIntrinsicAndNoSwaggerEditorDeployment2f0411dccd"
},
"RestApiId": {
"Ref": "RestApiIfIntrinsicAndNoSwaggerEditor"
},
"StageName": "prod"
}
},
"HttpApiIfIntrinsicAndNoOpenApiEditorprodStage": {
"Type": "AWS::ApiGatewayV2::Stage",
"Properties": {
"ApiId": {
"Ref": "HttpApiIfIntrinsicAndNoOpenApiEditor"
},
"StageName": "prod",
"AutoDeploy": true
}
},
"RestApiIfIntrinsicAndNoSwaggerEditor": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"Body": {
"Fn::If": [
"FalseCondition",
{
"info": {
"title": {
"Fn::Sub": "${AWS::StackName}-Api"
}
},
"paths": {
"/post": {
"post": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": "https://www.alphavantage.co/",
"payloadFormatVersion": "1.0"
}
}
}
},
"swagger": "2.0"
},
{
"info": {
"title": {
"Fn::Sub": "${AWS::StackName}-Api"
}
},
"paths": {
"/post": {
"post": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": "https://www.otheruri.co/",
"payloadFormatVersion": "1.0"
}
}
}
},
"swagger": "2.0"
}
]
},
"Parameters": {
"endpointConfigurationTypes": "REGIONAL"
},
"EndpointConfiguration": {
"Types": [
"REGIONAL"
]
}
}
},
"HttpApiIfIntrinsicAndNoOpenApiEditor": {
"Type": "AWS::ApiGatewayV2::Api",
"Properties": {
"Body": {
"Fn::If": [
"FalseCondition",
{
"info": {
"title": {
"Fn::Sub": "${AWS::StackName}-Api"
}
},
"paths": {
"/post": {
"post": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": "https://www.alphavantage.co/",
"payloadFormatVersion": "1.0"
}
}
}
},
"openapi": "3.0"
},
{
"info": {
"title": {
"Fn::Sub": "${AWS::StackName}-Api"
}
},
"paths": {
"/post": {
"post": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": "https://www.otheruri.co/",
"payloadFormatVersion": "1.0"
}
}
}
},
"openapi": "3.0"
}
]
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "DefinitionBody currently only supports intrinsics when SwaggerEditor/OpenApiEditor is not used (as of 2022-05-30). Let's add tests to make sure we keep this support, because we've had a regression where we accidentally removed this intrinsics support by using the SwaggerEditor. Note that the only supported intrinsic function for DefinitionBody is Fn::If. Other intrinsics are not supported because they don't resolve to dictionary. \n",
"Conditions": {
"FalseCondition": {
"Fn::Equals": [
true,
false
]
}
},
"Resources": {
"RestApiIfIntrinsicAndNoSwaggerEditorDeployment2f0411dccd": {
"Type": "AWS::ApiGateway::Deployment",
"Properties": {
"Description": "RestApi deployment id: 2f0411dccde517dcb5c82d3848dbc431e7479ebc",
"RestApiId": {
"Ref": "RestApiIfIntrinsicAndNoSwaggerEditor"
},
"StageName": "Stage"
}
},
"RestApiIfIntrinsicAndNoSwaggerEditorprodStage": {
"Type": "AWS::ApiGateway::Stage",
"Properties": {
"DeploymentId": {
"Ref": "RestApiIfIntrinsicAndNoSwaggerEditorDeployment2f0411dccd"
},
"RestApiId": {
"Ref": "RestApiIfIntrinsicAndNoSwaggerEditor"
},
"StageName": "prod"
}
},
"HttpApiIfIntrinsicAndNoOpenApiEditorprodStage": {
"Type": "AWS::ApiGatewayV2::Stage",
"Properties": {
"ApiId": {
"Ref": "HttpApiIfIntrinsicAndNoOpenApiEditor"
},
"StageName": "prod",
"AutoDeploy": true
}
},
"RestApiIfIntrinsicAndNoSwaggerEditor": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"Body": {
"Fn::If": [
"FalseCondition",
{
"info": {
"title": {
"Fn::Sub": "${AWS::StackName}-Api"
}
},
"paths": {
"/post": {
"post": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": "https://www.alphavantage.co/",
"payloadFormatVersion": "1.0"
}
}
}
},
"swagger": "2.0"
},
{
"info": {
"title": {
"Fn::Sub": "${AWS::StackName}-Api"
}
},
"paths": {
"/post": {
"post": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": "https://www.otheruri.co/",
"payloadFormatVersion": "1.0"
}
}
}
},
"swagger": "2.0"
}
]
},
"Parameters": {
"endpointConfigurationTypes": "REGIONAL"
},
"EndpointConfiguration": {
"Types": [
"REGIONAL"
]
}
}
},
"HttpApiIfIntrinsicAndNoOpenApiEditor": {
"Type": "AWS::ApiGatewayV2::Api",
"Properties": {
"Body": {
"Fn::If": [
"FalseCondition",
{
"info": {
"title": {
"Fn::Sub": "${AWS::StackName}-Api"
}
},
"paths": {
"/post": {
"post": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": "https://www.alphavantage.co/",
"payloadFormatVersion": "1.0"
}
}
}
},
"openapi": "3.0"
},
{
"info": {
"title": {
"Fn::Sub": "${AWS::StackName}-Api"
}
},
"paths": {
"/post": {
"post": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": "https://www.otheruri.co/",
"payloadFormatVersion": "1.0"
}
}
}
},
"openapi": "3.0"
}
]
}
}
}
}
}
Loading