Skip to content

Instantly share code, notes, and snippets.

@marcy-terui
Last active July 15, 2016 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcy-terui/4de92550a9a4faf01583 to your computer and use it in GitHub Desktop.
Save marcy-terui/4de92550a9a4faf01583 to your computer and use it in GitHub Desktop.
AWS Lambda向けデプロイ・管理ツール「Lamvery」について ref: http://qiita.com/marcy-terui/items/1617ab4e20e3339d1930
api_id: myipugal74
stage: dev
cors:
origin: '*'
methods:
- GET
- OPTION
headers:
- Content-Type
- X-Amz-Date
- Authorization
- X-Api-Key
configuration:
swagger: '2.0'
info:
title: Sample API
schemes:
- https
paths:
/:
get:
produces:
- application/json
parameters:
- name: sample
in: query
required: false
type: string
responses:
'200':
description: 200 response
schema:
$ref: '#/definitions/Sample'
definitions:
Sample:
type: object
rules:
- name: foo
description: bar
schedule: 'rate(5 minutes)'
targets:
- id: test-target-id
input:
this:
- is: a
- sample: input
- ^\.lamvery\.yml$
- ^\.lamvery\.event\.yml$
- ^\.lamvery\.secret\.yml$
- ^\.lamvery\.exclude\.yml$
build:
pre:
- pip install -r requirements.txt -t ./
post: []
key_id: a5ed61a9-fa57-4ebf-9b3f-457b95de05ce # <-ここ!!!
cipher_texts: {}
profile: default
region: us-east-1
configuration:
name: sample_lambda_function
runtime: python2.7 # or nodejs
role: arn:aws:iam::000000000000:role/lambda_basic_execution
handler: lambda_function.lambda_handler
description: This is sample lambda function.
timeout: 10
memory_size: 128
virtualenv -p <path-to-python2.7> .venv
. .venv/bin/activate
pip install lamvery
echo "deb https://dl.bintray.com/willyworks/deb trusty main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install lamvery
export PATH=/opt/lamvery/bin:$PATH
$ lamvery init -h
usage: lamvery init [-h] [-c CONF_FILE]
optional arguments:
-h, --help show this help message and exit
-c CONF_FILE, --conf-file CONF_FILE
Configuration YAML file (default: .lamvery.yml)
$ lamvery generate -h
usage: lamvery generate [-h] [-c CONF_FILE] -k KIND
optional arguments:
-h, --help show this help message and exit
-c CONF_FILE, --conf-file CONF_FILE
Configuration YAML file (default: .lamvery.yml)
-k KIND, --kind KIND The kind of the file # accepts "function"
$ lamvery build -h
usage: lamvery build [-h] [-c CONF_FILE] [-s] [-l] [-e ENV]
optional arguments:
-h, --help show this help message and exit
-c CONF_FILE, --conf-file CONF_FILE
Configuration YAML file (default: .lamvery.yml)
-s, --single-file Only use the main lambda function file
-l, --no-libs Archiving without all libraries
-e ENV, --env ENV Environment variables that pass to the function
$ lamvery deploy -h
usage: lamvery deploy [-h] [-a ALIAS] [-c CONF_FILE] [-d] [-s] [-l] [-p]
[-e ENV]
optional arguments:
-h, --help show this help message and exit
-a ALIAS, --alias ALIAS
Alias for a version of the function
-c CONF_FILE, --conf-file CONF_FILE
Configuration YAML file (default: .lamvery.yml)
-d, --dry-run Dry run
-s, --single-file Only use the main lambda function file
-l, --no-libs Archiving without all libraries
-p, --publish Publish the version as an atomic operation
-e ENV, --env ENV Environment variables that pass to the function
$ lamvery rollback -h
usage: lamvery rollback [-h] [-a ALIAS] [-c CONF_FILE] [-v VERSION]
optional arguments:
-h, --help show this help message and exit
-a ALIAS, --alias ALIAS
Alias for a version of the function
-c CONF_FILE, --conf-file CONF_FILE
Configuration YAML file (default: .lamvery.yml)
-v VERSION, --version VERSION
Version of the function
$ lamvery configure -h
usage: lamvery configure [-h] [-c CONF_FILE] [-d]
optional arguments:
-h, --help show this help message and exit
-c CONF_FILE, --conf-file CONF_FILE
Configuration YAML file (default: .lamvery.yml)
-d, --dry-run Dry run
$ lamvery set-alias -h
usage: lamvery set-alias [-h] [-a ALIAS] [-c CONF_FILE] [-d] [-v VERSION]
[-t TARGET]
optional arguments:
-h, --help show this help message and exit
-a ALIAS, --alias ALIAS
Alias for a version of the function
-c CONF_FILE, --conf-file CONF_FILE
Configuration YAML file (default: .lamvery.yml)
-d, --dry-run Dry run
-v VERSION, --version VERSION
Version of the function
-t TARGET, --target TARGET
The alias of the version that is targeted for setting
alias
$ lamvery encrypt -h
usage: lamvery encrypt [-h] [-c CONF_FILE] [-n SECRET_NAME] [-s] text
positional arguments:
text The text value to encrypt
optional arguments:
-h, --help show this help message and exit
-c CONF_FILE, --conf-file CONF_FILE
Configuration YAML file (default: .lamvery.yml)
-n SECRET_NAME, --secret-name SECRET_NAME
The name of the secret value
-s, --store Store encripted value to the configuration file
(default: .lamvery.secret.yml)
$ lamvery encrypt-file -h
usage: lamvery encrypt-file [-h] [-c CONF_FILE] -p PATH [-s] file
positional arguments:
file The file path to encrypt
optional arguments:
-h, --help show this help message and exit
-c CONF_FILE, --conf-file CONF_FILE
Configuration YAML file (default: .lamvery.yml)
-p PATH, --path PATH The path to put the decrypted file in the function
-s, --store Store encripted value to the configuration file
(default: .lamvery.secret.yml)
$ lamvery decrypt -h
usage: lamvery decrypt [-h] [-c CONF_FILE] [-n SECRET_NAME]
optional arguments:
-h, --help show this help message and exit
-c CONF_FILE, --conf-file CONF_FILE
Configuration YAML file (default: .lamvery.yml)
-n SECRET_NAME, --secret-name SECRET_NAME
The name of the secret value
echo "
[bintraybintray-willyworks-rpm]
name=bintray-willyworks-rpm
baseurl=https://dl.bintray.com/willyworks/rpm/centos/\$releaserver/\$basearch/
gpgcheck=0
enabled=1
" | sudo tee -a /etc/yum.repos.d/bintray-willyworks-rpm.repo
sudo yum install lamvery
export PATH=/opt/lamvery/bin:$PATH
lamvery events [-k]
$ lamvery invoke -h
usage: lamvery invoke [-h] [-a ALIAS] [-c CONF_FILE] [-v VERSION] json
positional arguments:
json The JSON string or file that pass to the function
optional arguments:
-h, --help show this help message and exit
-a ALIAS, --alias ALIAS
Alias for a version of the function
-c CONF_FILE, --conf-file CONF_FILE
Configuration YAML file (default: .lamvery.yml)
-v VERSION, --version VERSION
Version of the function
$ lamvery logs -h
usage: lamvery logs [-h] [-c CONF_FILE] [-f] [-F FILTER] [-i INTERVAL]
[-s START]
optional arguments:
-h, --help show this help message and exit
-c CONF_FILE, --conf-file CONF_FILE
Configuration YAML file (default: .lamvery.yml)
-f, --follow Watch the log events and updates the display (like
`tail -f`)
-F FILTER, --filter FILTER
Filtering pattern for the log messages
-i INTERVAL, --interval INTERVAL
Intervals(seconds) to watch the log events
-s START, --start START
Time to start the log events watching
$ lamvery api -h
usage: lamvery api [-h] [-c CONF_FILE] [-d] [-n] [-r] [-s STAGE] [-w]
optional arguments:
-h, --help show this help message and exit
-c CONF_FILE, --conf-file CONF_FILE
Configuration YAML file (default: .lamvery.yml)
-d, --dry-run Dry run
-n, --no-integrate Without automatic integration
-r, --remove Remove your API
-s STAGE, --stage STAGE
The name of the stage in API Gateway
-w, --write-id Write the id of your API to the configuration file
(default: .lamvery.api.yml)
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"kms:Decrypt"
],
"Resource": [
"arn:aws:kms:us-east-1:<your-account-number>:key/<your-key-id>"
]
}
]
}
lamvery init
lamvery generate -k function
lamvery encrypt -s -n foo "This is a secret"
lambery invoke {}
lamvery init
START RequestId: 13829c9c-9f13-11e5-921b-6f048cff3c2d Version: $LATEST
This is a secret
END RequestId: 13829c9c-9f13-11e5-921b-6f048cff3c2d
lamvery deploy
lambery invoke {}
START RequestId: 13829c9c-9f13-11e5-921b-6f048cff3c2d Version: $LATEST
This is a secret
END RequestId: 13829c9c-9f13-11e5-921b-6f048cff3c2d
lamvery deploy
lamvery set-alias -a <alias> -v <alias-version>
lamvery archive
lamvery deploy
lamvery deploy
lamvery configure
var lamvery = require('./lamvery.js');
exports.lambda_handler = function(event, context) {
lamvery.secret.get('foo', function(err, data) {
console.log(data);
});
}
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