Last active
February 10, 2016 13:08
-
-
Save marcy-terui/0a7c8b09a5c4d5081b3a to your computer and use it in GitHub Desktop.
CircleCI + LamveryによるLambda functionのdeployベストプラクティス ref: http://qiita.com/marcy-terui/items/900b72efb38f9b26e8f0
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
profile: null | |
region: us-east-1 | |
versioning: false | |
default_alias: master | |
configuration: | |
name: lamvery-deploy-sample | |
runtime: python2.7 | |
role: {{ env['AWS_LAMBDA_ROLE'] }} | |
handler: lambda_function.lambda_handler | |
description: This is a sample lambda function. | |
timeout: 10 | |
memory_size: 128 |
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
--- | |
machine: | |
python: | |
version: 2.7 | |
dependencies: | |
pre: | |
- | | |
virtualenv .venv | |
source .venv/bin/activate | |
pip install -r requirements.txt | |
test: | |
override: | |
- | | |
source .venv/bin/activate | |
flake8 lambda_function.py | |
deployment: | |
master-head: | |
branch: master | |
commands: | |
- | | |
source .venv/bin/activate | |
lamvery deploy | |
staging: | |
branch: staging | |
commands: | |
- | | |
source .venv/bin/activate | |
lamvery deploy -a staging -p | |
production: | |
branch: production | |
commands: | |
- | | |
source .venv/bin/activate | |
lamvery deploy -a production -p |
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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"logs:CreateLogGroup", | |
"logs:CreateLogStream", | |
"logs:PutLogEvents" | |
], | |
"Resource": "arn:aws:logs:*:*:*" | |
}, | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"kms:Decrypt" | |
], | |
"Resource": [ | |
"arn:aws:kms:<region>:<account-number>:key/<key-id>" | |
] | |
} | |
] | |
} |
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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"lambda:*", | |
"iam:PassRole" | |
], | |
"Resource": [ | |
"arn:aws:lambda:<region>:<account-number>:function:<function-name>", | |
"arn:aws:lambda:<region>:<account-number>:function:<function-name>:*", | |
"<function-role-arn>" | |
] | |
}, | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"lambda:CreateFunction", | |
"lambda:ListFunctions", | |
"lambda:ListVersionsByFunction" | |
], | |
"Resource": [ | |
"*" | |
] | |
} | |
] | |
} |
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
$ pip install lamvery | |
$ lamvery init | |
lamvery: Output initial file: .lamvery.yml | |
lamvery: Output initial file: .lamvery.exclude.yml | |
lamvery: Output initial file: .lamvery.event.yml | |
lamvery: Output initial file: .lamvery.secret.yml |
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
pip install flake8 | |
pip freeze > requirements.txt |
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
pip install -r requirements.txt |
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
$ lamvery rollback -a production | |
lamvery: [Function] Previous version: 2 | |
lamvery: [Alias] production: 4 -> 2 |
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
import lamvery | |
def lambda_handler(event, context): | |
print(lamvery.secret.get('foo')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment