-
-
Save maa42/865c73991408b5ab51ad4b78cb67116e 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
# Source: https://gist.github.com/7e0ada996b5d09486f2df0d7e1cbbea2 | |
############################################### | |
# Amazon Lambda Containers # | |
# Packaging AWS Functions as Container Images # | |
# https://youtu.be/DsQbBVr-GwU # | |
############################################### | |
# Requirements: | |
# - AWS account (https://aws.amazon.com/) | |
# - `aws` CLI (https://aws.amazon.com/cli/) | |
# - AWS config or env. vars with access keys and the default region | |
# - Docker (https://www.docker.com/) | |
# ... or ... | |
# - Gitpod with the Chrome extension (https://youtu.be/QV1fYt-7SLU) | |
# - Environment variables *AWS_ACCESS_KEY_ID*, *AWS_SECRET_ACCESS_KEY*, and *AWS_DEFAULT_REGION* (https://gitpod.io/settings/) | |
# - Gitpod *Feature Preview* enabled | |
# Open https://github.com/vfarcic/lambda-container-demo | |
# Fork it | |
# Click the *Gitpod* button | |
# ECR public repository: https://gallery.ecr.aws/ | |
docker image build \ | |
--tag lambda-container-demo:0.0.1 \ | |
$PWD | |
docker container run \ | |
--publish 9000:8080 \ | |
lambda-container-demo:0.0.1 | |
curl \ | |
"http://localhost:9000/2015-03-31/functions/function/invocations" \ | |
-d '{"name":"Viktor"}' && echo | |
exit | |
aws ecr create-repository \ | |
--repository-name lambda-container-demo \ | |
--image-scanning-configuration scanOnPush=true | |
export REPO_URI=[...] | |
aws ecr get-login-password \ | |
| docker login \ | |
--username AWS \ | |
--password-stdin \ | |
$REPO_URI | |
docker image tag lambda-container-demo:0.0.1 \ | |
$REPO_URI:0.0.1 | |
docker image tag lambda-container-demo:0.0.1 \ | |
$REPO_URI:latest | |
docker image push $REPO_URI:0.0.1 | |
docker image push $REPO_URI:latest | |
docker image ls | |
# AWS Lambda: https://console.aws.amazon.com/lambda/home | |
export PAYLOAD=$(\ | |
echo '{"name":"Viktor"}' | base64) | |
aws lambda invoke \ | |
--function-name lambda-container-demo \ | |
--payload $PAYLOAD \ | |
response.json | |
cat response.json && echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment