Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit 2f9e3ce

Browse files
DevoKunclareliguori
authored andcommitted
added a readme with a list of quickstart steps.
1 parent 1d00970 commit 2f9e3ce

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

example/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
Example for creating an custom Lambda Layer to run PHP 7
2+
========================================================
3+
4+
## Quickstart
5+
6+
```bash
7+
8+
## Build the docker image
9+
10+
docker build -t lambda-php .
11+
12+
## Test locally using Docker
13+
## The bootstrap script will be the entrypoint,
14+
## which will then run the specified lambda function,
15+
## and pass the input data to the lambda function.
16+
17+
docker run lambda-php hello '{"name": "World"}'
18+
19+
## Install img2lambda
20+
21+
wget -O /usr/local/bin/img2lambda \
22+
https://github.com/awslabs/aws-lambda-container-image-converter/releases/download/0.3.0/linux-amd64-img2lambda
23+
chmod 0755 /usr/local/bin/img2lambda
24+
25+
## Deploy lambda layer
26+
27+
img2lambda -i lambda-php:latest -r us-east-1 -n lambda-php
28+
29+
## Deploy Lambda functions: hello and goodbye
30+
## img2lambda creates `output/layers.yaml` which will be combined with `template.yaml` to create `template-with-layers.yaml`
31+
32+
export AWS_REGION="us-east-1"
33+
export MY_LAMBDA_LAYER_BUCKET="devokun-lambda-php"
34+
35+
36+
sed -i 's/^- / - /' ../output/layers.yaml && \
37+
sed -e "/LAYERS_PLACEHOLDER/r ../output/layers.yaml" \
38+
-e "s///" template.yaml > template-with-layers.yaml
39+
40+
41+
## Install AWS CLI
42+
43+
pip3 install aws-cli
44+
45+
## Create S3 bucket for storing Lambda Functions
46+
47+
aws s3 mb s3://${MY_LAMBDA_LAYER_BUCKET}
48+
49+
## Install SAM CLI
50+
51+
pip3 install aws-sam-cli
52+
53+
## Deploy Lambda functions using SAM
54+
55+
sam package --template-file template-with-layers.yaml \
56+
--output-template-file packaged.yaml \
57+
--region ${AWS_REGION} \
58+
--s3-bucket ${MY_LAMBDA_LAYER_BUCKET}
59+
60+
sam deploy --template-file packaged.yaml \
61+
--capabilities CAPABILITY_IAM \
62+
--region ${AWS_REGION} \
63+
--stack-name img2lambda-php-example
64+
65+
```
66+

0 commit comments

Comments
 (0)