Created
May 11, 2019 06:48
-
-
Save alex-harvey-z3q/819cc46a45392a2686713075c856bc54 to your computer and use it in GitHub Desktop.
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
## Using the original template | |
+ sam deploy --template-file packaged.yaml --stack-name HelloWorld --capabilities CAPABILITY_IAM | |
Waiting for changeset to be created.. | |
Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Invalid template property or properties [Api] | |
+ exit 255 | |
## Template after correcting errors | |
AWSTemplateFormatVersion: '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Description: 'testimg | |
Sample SAM Template for testimg | |
' | |
Globals: | |
Function: | |
Timeout: 60 | |
Api: | |
BinaryMediaTypes: | |
- image/png | |
Resources: | |
HelloWorldFunction: | |
Type: AWS::Serverless::Function | |
Properties: | |
CodeUri: hello_world/ | |
Handler: app.lambda_handler | |
Runtime: python2.7 | |
Events: | |
HelloWorld: | |
Type: Api | |
Properties: | |
Path: /hello | |
Method: post | |
Outputs: | |
HelloWorldApi: | |
Description: API Gateway endpoint URL for Prod stage for Hello World function | |
Value: | |
Fn::Sub: https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/ | |
HelloWorldFunction: | |
Description: Hello World Lambda Function ARN | |
Value: | |
Fn::GetAtt: | |
- HelloWorldFunction | |
- Arn | |
HelloWorldFunctionIamRole: | |
Description: Implicit IAM Role created for Hello World function | |
Value: | |
Fn::GetAtt: | |
- HelloWorldFunctionRole | |
- Arn | |
## build and deploy | |
▶ bash deploy-stack.sh | |
+ sam build | |
2019-05-11 16:46:53 Building resource 'HelloWorldFunction' | |
2019-05-11 16:46:53 Running PythonPipBuilder:ResolveDependencies | |
2019-05-11 16:46:54 Running PythonPipBuilder:CopySource | |
Build Succeeded | |
Built Artifacts : .aws-sam/build | |
Built Template : .aws-sam/build/template.yaml | |
Commands you can use next | |
========================= | |
[*] Invoke Function: sam local invoke | |
[*] Package: sam package --s3-bucket <yourbucket> | |
+ sam package --output-template-file packaged.yaml --s3-bucket alexharvey3118 | |
Uploading to 2950fc88469276b9aab4f3353caa154b 528074 / 528074.0 (100.00%) | |
Successfully packaged artifacts and wrote output template to file packaged.yaml. | |
Execute the following command to deploy the packaged template | |
aws cloudformation deploy --template-file /Users/alexharvey/git/home/sam-test/sam-app/packaged.yaml --stack-name <YOUR STACK NAME> | |
+ sam deploy --template-file packaged.yaml --stack-name HelloWorld --capabilities CAPABILITY_IAM | |
Waiting for changeset to be created.. | |
Waiting for stack create/update to complete | |
Successfully created/updated stack - HelloWorld | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment