Skip to content

Commit cc1f144

Browse files
committed
Adds SAM config
1 parent 990e44f commit cc1f144

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
*.sublime-*
2-
32
.pytest_cache
3+
tmp.sh
44

55
# Byte-compiled / optimized / DLL files
66
__pycache__/

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Deployment and application code adaptors are being added for the following:
1111

1212
| Platform | Deployment | Status |
1313
|--------------------------|-----------------------|:----------------------:|
14-
| AWS Lambda | AWS SAM | |
14+
| AWS Lambda | AWS SAM | :heavy_check_mark: |
1515
| AWS Lambda | Terraform | :heavy_check_mark: |
1616
| Azure Functions | Terraform | |
1717
| Google Cloud Functions | Terraform | |
@@ -108,6 +108,35 @@ $ http-prompt $(cd terraform && terraform output api_url)
108108
GET artists
109109
```
110110

111+
### [AWS Serverless Application Model (SAM)](https://aws.amazon.com/about-aws/whats-new/2016/11/introducing-the-aws-serverless-application-model/) Deployment
112+
113+
Unlike Terraform SAM doesn't upload the zip bundle so do this using the `aws-cli` tool.
114+
```Shell
115+
$ aws s3 mb s3://<mybucket>
116+
$ aws s3 cp terraform/dist/python-serverless-api.zip s3://<mybucket>/python-serverless-api.zip
117+
```
118+
119+
Update the S3 bucket value in the SAM config.
120+
```YAML
121+
# template.yaml
122+
AWSTemplateFormatVersion: '2010-09-09'
123+
Transform: 'AWS::Serverless-2016-10-31'
124+
Description: 'Boilerplate Python 3.6 Flask App.'
125+
Resources:
126+
FlaskAPI:
127+
Type: 'AWS::Serverless::Function'
128+
Properties:
129+
CodeUri: s3://<mybucket>/flask-app.zip
130+
```
131+
132+
Deploy the SAM template with Cloudformation.
133+
```Shell
134+
$ aws cloudformation deploy \
135+
--template-file template.yaml \
136+
--stack-name python-serverless-stack-sam
137+
--capabilities CAPABILITY_IAM
138+
```
139+
111140

112141
-----------------------------------------------------------
113142
## Test

template.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Transform: 'AWS::Serverless-2016-10-31'
3+
Description: 'Boilerplate Python 3.6 Flask App.'
4+
Resources:
5+
FlaskAPI:
6+
Type: 'AWS::Serverless::Function'
7+
Properties:
8+
CodeUri: s3://<mybucket>/flask-app.zip
9+
Handler: run_lambda.http_server
10+
Runtime: python3.6
11+
Events:
12+
HTTPRequest:
13+
Type: Api
14+
Properties:
15+
Path: /{proxy+}
16+
Method: ANY

0 commit comments

Comments
 (0)