-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add modes support for RestApi #2055
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0156efc
Adding Mode passthrough property to RestApi with unit tests.
4a53ceb
Adding integration test for Mode
800be7b
Fixing sam-translate for manual translation.
756a175
running black formatting
6261bd1
Running black formatting, again.
6278227
Clearing pip-wheel-metadata.
ef2dd48
Clearing tmp folder created by integ test.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
11 changes: 11 additions & 0 deletions
11
integration/resources/expected/single/basic_api_with_mode.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,11 @@ | ||
[ | ||
{"LogicalResourceId": "MyApi", "ResourceType": "AWS::ApiGateway::RestApi"}, | ||
{"LogicalResourceId": "MyApiDeploymenta808f15210", "ResourceType": "AWS::ApiGateway::Deployment"}, | ||
{"LogicalResourceId": "MyApiMyNewStageNameStage", "ResourceType": "AWS::ApiGateway::Stage"}, | ||
{"LogicalResourceId": "TestFunction", "ResourceType": "AWS::Lambda::Function"}, | ||
{"LogicalResourceId": "TestFunctionAliaslive", "ResourceType": "AWS::Lambda::Alias"}, | ||
{"LogicalResourceId": "TestFunctionGetPermissionMyNewStageName", "ResourceType": "AWS::Lambda::Permission"}, | ||
{"LogicalResourceId": "TestFunctionPutPermissionMyNewStageName", "ResourceType": "AWS::Lambda::Permission"}, | ||
{"LogicalResourceId": "TestFunctionRole", "ResourceType": "AWS::IAM::Role"}, | ||
{"LogicalResourceId": "TestFunctionVersione9898fd501", "ResourceType": "AWS::Lambda::Version"} | ||
] |
10 changes: 10 additions & 0 deletions
10
integration/resources/expected/single/basic_api_with_mode_update.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,10 @@ | ||
[ | ||
{"LogicalResourceId": "MyApi", "ResourceType": "AWS::ApiGateway::RestApi"}, | ||
{"LogicalResourceId": "MyApiDeploymentada889e3ac", "ResourceType": "AWS::ApiGateway::Deployment"}, | ||
{"LogicalResourceId": "MyApiMyNewStageNameStage", "ResourceType": "AWS::ApiGateway::Stage"}, | ||
{"LogicalResourceId": "TestFunction", "ResourceType": "AWS::Lambda::Function"}, | ||
{"LogicalResourceId": "TestFunctionAliaslive", "ResourceType": "AWS::Lambda::Alias"}, | ||
{"LogicalResourceId": "TestFunctionPutPermissionMyNewStageName", "ResourceType": "AWS::Lambda::Permission"}, | ||
{"LogicalResourceId": "TestFunctionRole", "ResourceType": "AWS::IAM::Role"}, | ||
{"LogicalResourceId": "TestFunctionVersion847aaa5fc1", "ResourceType": "AWS::Lambda::Version"} | ||
] |
34 changes: 34 additions & 0 deletions
34
integration/resources/templates/single/basic_api_with_mode.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,34 @@ | ||
Resources: | ||
MyApi: | ||
Type: AWS::Serverless::Api | ||
Properties: | ||
StageName: MyNewStageName | ||
Mode: overwrite | ||
|
||
TestFunction: | ||
Type: 'AWS::Serverless::Function' | ||
Properties: | ||
Handler: index.handler | ||
Runtime: python3.6 | ||
AutoPublishAlias: live | ||
InlineCode: | | ||
import json | ||
def handler(event, context): | ||
return {'statusCode': 200, 'body': json.dumps('Hello World!')} | ||
Events: | ||
Get: | ||
Type: Api | ||
Properties: | ||
Path: /get | ||
Method: get | ||
RestApiId: !Ref MyApi | ||
Put: | ||
Type: Api | ||
Properties: | ||
Path: /put | ||
Method: put | ||
RestApiId: !Ref MyApi | ||
|
||
Outputs: | ||
ApiEndpoint: | ||
Value: !Sub "https://${MyApi}.execute-api.${AWS::Region}.amazonaws.com/MyNewStageName" |
24 changes: 24 additions & 0 deletions
24
integration/resources/templates/single/basic_api_with_mode_update.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,24 @@ | ||
Resources: | ||
MyApi: | ||
Type: AWS::Serverless::Api | ||
Properties: | ||
StageName: MyNewStageName | ||
Mode: overwrite | ||
|
||
TestFunction: | ||
Type: 'AWS::Serverless::Function' | ||
Properties: | ||
Handler: index.handler | ||
Runtime: python3.6 | ||
AutoPublishAlias: live | ||
InlineCode: | | ||
def handler(event, context): | ||
print("Hello, world!") | ||
Events: | ||
Put: | ||
Type: Api | ||
Properties: | ||
Path: /put | ||
Method: put | ||
RestApiId: !Ref MyApi | ||
|
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
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
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
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
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: | ||
Function: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/member_portal.zip | ||
Handler: index.gethtml | ||
Runtime: nodejs12.x | ||
Events: | ||
GetHtml: | ||
Type: Api | ||
Properties: | ||
RestApiId: Api | ||
Path: / | ||
Method: get | ||
|
||
Api: | ||
Type: AWS::Serverless::Api | ||
Properties: | ||
StageName: Prod | ||
DefinitionUri: s3://sam-demo-bucket/webpage_swagger.json | ||
Description: my description | ||
Mode: overwrite |
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,109 @@ | ||
{ | ||
"Resources": { | ||
"FunctionRole": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"ManagedPolicyArns": [ | ||
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
], | ||
"Tags": [ | ||
{ | ||
"Value": "SAM", | ||
"Key": "lambda:createdBy" | ||
} | ||
], | ||
"AssumeRolePolicyDocument": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"sts:AssumeRole" | ||
], | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
"lambda.amazonaws.com" | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"ApiProdStage": { | ||
"Type": "AWS::ApiGateway::Stage", | ||
"Properties": { | ||
"DeploymentId": { | ||
"Ref": "ApiDeploymentf117c932f7" | ||
}, | ||
"RestApiId": { | ||
"Ref": "Api" | ||
}, | ||
"StageName": "Prod" | ||
} | ||
}, | ||
"FunctionGetHtmlPermissionProd": { | ||
"Type": "AWS::Lambda::Permission", | ||
"Properties": { | ||
"Action": "lambda:InvokeFunction", | ||
"Principal": "apigateway.amazonaws.com", | ||
"FunctionName": { | ||
"Ref": "Function" | ||
}, | ||
"SourceArn": { | ||
"Fn::Sub": [ | ||
"arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/", | ||
{ | ||
"__Stage__": "*", | ||
"__ApiId__": "Api" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"ApiDeploymentf117c932f7": { | ||
"Type": "AWS::ApiGateway::Deployment", | ||
"Properties": { | ||
"RestApiId": { | ||
"Ref": "Api" | ||
}, | ||
"Description": "RestApi deployment id: f117c932f75cfa87d23dfed64e9430d0081ef289", | ||
"StageName": "Stage" | ||
} | ||
}, | ||
"Api": { | ||
"Type": "AWS::ApiGateway::RestApi", | ||
"Properties": { | ||
"BodyS3Location": { | ||
"Bucket": "sam-demo-bucket", | ||
"Key": "webpage_swagger.json" | ||
}, | ||
"Description": "my description", | ||
"Mode": "overwrite" | ||
} | ||
}, | ||
"Function": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"S3Bucket": "sam-demo-bucket", | ||
"S3Key": "member_portal.zip" | ||
}, | ||
"Handler": "index.gethtml", | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"FunctionRole", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "nodejs12.x", | ||
"Tags": [ | ||
{ | ||
"Value": "SAM", | ||
"Key": "lambda:createdBy" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typed Execptions?