-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing DisableExecuteApiEndpoint property for REST and adding integ t… (
#2272) * Fixing DisableExecuteApiEndpoint property for REST and adding integ tests. * Fixing DisableExecuteApiEndpoint property for REST and adding integ tests. * Fixing output templates to match py2 hashing.
- Loading branch information
Showing
6 changed files
with
432 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/translator/input/api_with_disable_api_execute_endpoint.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Resources: | ||
ApiGatewayApi: | ||
Type: AWS::Serverless::Api | ||
Properties: | ||
StageName: prod | ||
DisableExecuteApiEndpoint: True | ||
ApiFunction: # Adds a GET api endpoint at "/" to the ApiGatewayApi via an Api event | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Events: | ||
ApiEvent: | ||
Type: Api | ||
Properties: | ||
Path: / | ||
Method: get | ||
RestApiId: | ||
Ref: ApiGatewayApi | ||
Runtime: python3.7 | ||
Handler: index.handler | ||
InlineCode: | | ||
def handler(event, context): | ||
return {'body': 'Hello World!', 'statusCode': 200} |
130 changes: 130 additions & 0 deletions
130
tests/translator/output/api_with_disable_api_execute_endpoint.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
{ | ||
"Resources": { | ||
"ApiGatewayApi": { | ||
"Type": "AWS::ApiGateway::RestApi", | ||
"Properties": { | ||
"Body": { | ||
"info": { | ||
"version": "1.0", | ||
"title": { | ||
"Ref": "AWS::StackName" | ||
} | ||
}, | ||
"paths": { | ||
"/": { | ||
"get": { | ||
"x-amazon-apigateway-integration": { | ||
"httpMethod": "POST", | ||
"type": "aws_proxy", | ||
"uri": { | ||
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiFunction.Arn}/invocations" | ||
} | ||
}, | ||
"responses": {} | ||
} | ||
} | ||
}, | ||
"swagger": "2.0", | ||
"x-amazon-apigateway-endpoint-configuration": { | ||
"disableExecuteApiEndpoint": true | ||
} | ||
} | ||
} | ||
}, | ||
"ApiGatewayApiDeploymenta13ba42368": { | ||
"Type": "AWS::ApiGateway::Deployment", | ||
"Properties": { | ||
"RestApiId": { | ||
"Ref": "ApiGatewayApi" | ||
}, | ||
"Description": "RestApi deployment id: a13ba42368cb482635c1d715f5e0199e94d79222", | ||
"StageName": "Stage" | ||
} | ||
}, | ||
"ApiFunctionRole": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"sts:AssumeRole" | ||
], | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
"lambda.amazonaws.com" | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"ManagedPolicyArns": [ | ||
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
], | ||
"Tags": [ | ||
{ | ||
"Value": "SAM", | ||
"Key": "lambda:createdBy" | ||
} | ||
] | ||
} | ||
}, | ||
"ApiFunction": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Handler": "index.handler", | ||
"Code": { | ||
"ZipFile": "def handler(event, context):\n return {'body': 'Hello World!', 'statusCode': 200}" | ||
}, | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"ApiFunctionRole", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "python3.7", | ||
"Tags": [ | ||
{ | ||
"Value": "SAM", | ||
"Key": "lambda:createdBy" | ||
} | ||
] | ||
} | ||
}, | ||
"ApiFunctionApiEventPermissionprod": { | ||
"Type": "AWS::Lambda::Permission", | ||
"Properties": { | ||
"Action": "lambda:InvokeFunction", | ||
"Principal": "apigateway.amazonaws.com", | ||
"FunctionName": { | ||
"Ref": "ApiFunction" | ||
}, | ||
"SourceArn": { | ||
"Fn::Sub": [ | ||
"arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/", | ||
{ | ||
"__Stage__": "*", | ||
"__ApiId__": { | ||
"Ref": "ApiGatewayApi" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"ApiGatewayApiprodStage": { | ||
"Type": "AWS::ApiGateway::Stage", | ||
"Properties": { | ||
"DeploymentId": { | ||
"Ref": "ApiGatewayApiDeploymenta13ba42368" | ||
}, | ||
"RestApiId": { | ||
"Ref": "ApiGatewayApi" | ||
}, | ||
"StageName": "prod" | ||
} | ||
} | ||
} | ||
} |
138 changes: 138 additions & 0 deletions
138
tests/translator/output/aws-cn/api_with_disable_api_execute_endpoint.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
{ | ||
"Resources": { | ||
"ApiGatewayApi": { | ||
"Type": "AWS::ApiGateway::RestApi", | ||
"Properties": { | ||
"Body": { | ||
"info": { | ||
"version": "1.0", | ||
"title": { | ||
"Ref": "AWS::StackName" | ||
} | ||
}, | ||
"paths": { | ||
"/": { | ||
"get": { | ||
"x-amazon-apigateway-integration": { | ||
"httpMethod": "POST", | ||
"type": "aws_proxy", | ||
"uri": { | ||
"Fn::Sub": "arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiFunction.Arn}/invocations" | ||
} | ||
}, | ||
"responses": {} | ||
} | ||
} | ||
}, | ||
"swagger": "2.0", | ||
"x-amazon-apigateway-endpoint-configuration": { | ||
"disableExecuteApiEndpoint": true | ||
} | ||
}, | ||
"EndpointConfiguration": { | ||
"Types": [ | ||
"REGIONAL" | ||
] | ||
}, | ||
"Parameters": { | ||
"endpointConfigurationTypes": "REGIONAL" | ||
} | ||
} | ||
}, | ||
"ApiGatewayApiDeployment31ce724e39": { | ||
"Type": "AWS::ApiGateway::Deployment", | ||
"Properties": { | ||
"RestApiId": { | ||
"Ref": "ApiGatewayApi" | ||
}, | ||
"Description": "RestApi deployment id: 31ce724e3998cb16b80266cfb4868670a87430bf", | ||
"StageName": "Stage" | ||
} | ||
}, | ||
"ApiFunctionRole": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"sts:AssumeRole" | ||
], | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
"lambda.amazonaws.com" | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"ManagedPolicyArns": [ | ||
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
], | ||
"Tags": [ | ||
{ | ||
"Value": "SAM", | ||
"Key": "lambda:createdBy" | ||
} | ||
] | ||
} | ||
}, | ||
"ApiFunction": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Handler": "index.handler", | ||
"Code": { | ||
"ZipFile": "def handler(event, context):\n return {'body': 'Hello World!', 'statusCode': 200}" | ||
}, | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"ApiFunctionRole", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "python3.7", | ||
"Tags": [ | ||
{ | ||
"Value": "SAM", | ||
"Key": "lambda:createdBy" | ||
} | ||
] | ||
} | ||
}, | ||
"ApiFunctionApiEventPermissionprod": { | ||
"Type": "AWS::Lambda::Permission", | ||
"Properties": { | ||
"Action": "lambda:InvokeFunction", | ||
"Principal": "apigateway.amazonaws.com", | ||
"FunctionName": { | ||
"Ref": "ApiFunction" | ||
}, | ||
"SourceArn": { | ||
"Fn::Sub": [ | ||
"arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/", | ||
{ | ||
"__Stage__": "*", | ||
"__ApiId__": { | ||
"Ref": "ApiGatewayApi" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"ApiGatewayApiprodStage": { | ||
"Type": "AWS::ApiGateway::Stage", | ||
"Properties": { | ||
"DeploymentId": { | ||
"Ref": "ApiGatewayApiDeployment31ce724e39" | ||
}, | ||
"RestApiId": { | ||
"Ref": "ApiGatewayApi" | ||
}, | ||
"StageName": "prod" | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.