{"id":24482895,"url":"https://github.com/marcy-terui/lamvery","last_synced_at":"2025-04-13T16:50:30.323Z","repository":{"id":53669544,"uuid":"46028885","full_name":"marcy-terui/lamvery","owner":"marcy-terui","description":"User-friendly deployment and management tool for AWS Lambda function","archived":false,"fork":false,"pushed_at":"2021-03-19T22:26:44.000Z","size":12977,"stargazers_count":92,"open_issues_count":12,"forks_count":16,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-27T07:47:53.321Z","etag":null,"topics":["aws","aws-lambda"],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/lamvery","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcy-terui.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-12T04:13:59.000Z","updated_at":"2023-08-21T22:20:23.000Z","dependencies_parsed_at":"2022-08-29T08:41:19.353Z","dependency_job_id":null,"html_url":"https://github.com/marcy-terui/lamvery","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcy-terui%2Flamvery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcy-terui%2Flamvery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcy-terui%2Flamvery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcy-terui%2Flamvery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcy-terui","download_url":"https://codeload.github.com/marcy-terui/lamvery/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248749880,"owners_count":21155680,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-lambda"],"created_at":"2025-01-21T12:15:49.471Z","updated_at":"2025-04-13T16:50:30.301Z","avatar_url":"https://github.com/marcy-terui.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Lamvery\n=======\n\n[![Build Status](https://img.shields.io/travis/marcy-terui/lamvery/master.svg)](http://travis-ci.org/marcy-terui/lamvery)\n[![Coverage](https://img.shields.io/coveralls/marcy-terui/lamvery.svg)](https://coveralls.io/github/marcy-terui/lamvery)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/marcy-terui/lamvery/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/marcy-terui/lamvery/?branch=master)\n[![Version](https://img.shields.io/pypi/v/lamvery.svg)](https://pypi.python.org/pypi/lamvery)\n\n# Description\n\nUser-friendly deploy and management tool for AWS Lambda function.\n\n### Why user-friendly?\n\n#### The format of the configuration file is `YAML`(with `Jinja2`)\n\n- `YAML` is user-friendly than `JSON`\n- We can avoid some redundant contents by `Jinja2` template engine\n\n#### Additional features that are not in the standard Lambda functions\n\n- Passing the environment variables\n- Passing the confidential information use `KMS` encryption\n- Passing the confidential files use `KMS` encryption\n- And more\n\n#### More useful features for deploying and invoking our functions\n\n- We can build, configure, deploy, rollback and invoke with a single command\n- We can rollback **correctly** to the previous version of the alias\n- Deply(build) hooks\n- And more\n\n#### More useful features for using and managing the related services\n\n- API Gateway (Swagger)\n- CloudWatch Events\n- CloudWatch Logs\n- And more\n\n# Requirements\n\n- Python2.7\n- pip\n\n# Recommends\n\n- virtualenv  \n**Automatically collect the lightweighted and compiled libraries in the virtualenv environment.**\n\n# Installation\n\n## PyPI\n\n```sh\npip install lamvery\n```\n\n## Apt\n\n```sh\necho \"deb https://dl.bintray.com/willyworks/deb trusty main\" | sudo tee -a /etc/apt/sources.list\nsudo apt-get update\nsudo apt-get install lamvery\nexport PATH=/opt/lamvery/bin:$PATH\n```\n\n## Yum\n\n```sh\necho \"\n[bintraybintray-willyworks-rpm]\nname=bintray-willyworks-rpm\nbaseurl=https://dl.bintray.com/willyworks/rpm/centos/\\$releaserver/\\$basearch/\ngpgcheck=0\nenabled=1\n\" | sudo tee -a /etc/yum.repos.d/bintray-willyworks-rpm.repo\nsudo yum install lamvery\nexport PATH=/opt/lamvery/bin:$PATH\n```\n\n# Setup and configuration\n\nFirst,\n\n```sh\nlamvery init\n```\n\nAnd then edit your `.lamvery.yml` like so.  \nThe configuration is written in YAML syntax with `jinja2` template.  \nEnvironment variables are stored in the `env` variable.\n\n## General settings (default: `.lamvery.yml`)\n\n```yml\nprofile: private\nregion: us-east-1\nversioning: true\ndefault_alias: test\nclean_build: false\nconfiguration:\n  name: lamvery-test\n  runtime: python2.7\n  role: {{ env['AWS_LAMBDA_ROLE'] }}\n  handler: lambda_function.lambda_handler\n  description: This is sample lambda function.\n  timeout: 10\n  memory_size: 128\n  environment_variables:\n    MYENV: foobar\n  vpc_config:\n    subnets:\n    - subnet-cadf2993\n    security_groups:\n    - sg-4d095028\n```\n\n### profile\nThe name of a profile to use. If not given, it depends on `boto3`.\n\n### region\nThe region name of your environment.  \nIf you doesn't set this option, it depends on `boto3`.\n\n### versioning\nEnable the function versioning.\n\n### default_alias\nThe alias when it has not been specified in the `-a` or `--alias` option.\n\n### clean_build\nBuild the archive(zip) in the temporary area.\n\n### configuration\n\n- name  \nThe name of your function.\n\n- runtime  \nThe runtime environment for the Lambda function you are uploading.  \nCurrently, `lamvery` supports `python2.7` and `nodejs`.\n\n- role  \nThe Amazon Resource Name (ARN) of the IAM role for your function.\n\n- handler  \nThe function within your code that Lambda calls to begin execution.\n\n- description  \nThe description of your function.\n\n- timeout  \nThe function execution time(seconds) at which Lambda should terminate the function.\n\n- memory_size  \nThe amount of memory for your function environment.\n\n- environment_variables  \nEnvironment variables.\n\n- vpc_config  \nThe VPC configurations for the function to access resources in your VPC.  \n  - subnets  \n    The Subnet ids in your VPC.  \n  - security_groups  \n    The SecurityGroup ids in your VPC.  \n\n## CloudWatch Events settings (default: `.lamvery.event.yml`)\n\n```yml\nrules:\n- name: foo\n  description: bar\n  schedule: 'rate(5 minutes)'\n  targets:\n  - id: test-target-id\n    input:\n      this:\n      - is: a\n      - sample: input\n```\n\n### rules\nCloudWatch Event Rules.\n\n- NAME  \nThe name of CloudWatch Event Rule.\n\n- description  \nThe description of CloudWatch Event Rule.\n\n- schedule  \nThe schedule expression of CloudWatch Event Rule.\n\n- disabled  \nWhen this setting is true, change the state of CloudWatch Event Rule to `DISABLED`.  \ndefault: `false`\n\n- targets  \nThe targets of CloudWatch Event Rule.\n  - id  \n  The unique target assignment ID.\n  - input  \n  Arguments passed to the target.\n  - input_path  \n  The value of the JSONPath that is used for extracting part of the matched event when passing it to the target.\n\n*`input` and `input_path` are mutually-exclusive and optional parameters of a target.*\n\n## Secret informations (default: `.lamvery.secret.yml`)\n\n```yml\nkey_id: {{ env['AWS_KMS_KEY_ID'] }}\ncipher_texts:\n  foo: CiC4xW9lg7HaxaueeN+d9yJMyY1uw1i7tYVvQz9I8+e2UBKXAQEBAgB4uMVvZYOx2sWrnnjfnfciTMmNbsNYu7WFb0M/SPPntlAAAABuMGwGCSqGSIb3DQEHBqBfMF0CAQAwWAYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAzWTJWk/69T8NTBquoCARCAK2Hg2de71hzwjiMKkfMSG2G1Olj1EjxajS+3PsFVTPZ91Oi/AjR1aMqAI8U=\n```\n\n### key_id  \nThe ID of your encryption key on KMS.\n\n### cipher_texts  \nThe name and cipher texts to pass to the lambda function.\n\n### secret_files  \nThe filename and the encrypted contents to pass to the lambda function.\n\n## Excluded patterns from the archive (default: `.lamvery.exclude.yml`)\n\n```yml\n- ^\\.lamvery\\.yml$\n- ^\\.lamvery\\.event\\.yml$\n- ^\\.lamvery\\.secret\\.yml$\n- ^\\.lamvery\\.exclude\\.yml$\n```\n\nExclude files or directories using regular expression.\n\n## Action hooks (default: `.lamvery.hook.yml`)\n\n```yml\nbuild:\n  pre:\n  - pip install -r requirements.txt -t ./\n  post: []\n```\n\n### build\nThe hooks for `build`(and `deploy`)\n\n- pre  \nThe commands that run before building.\n\n- post  \nThe commands that run after building.\n\n## API Gateway integration (default: `.lamvery.api.yml`)\n\n```yml\napi_id: myipugal74\nstage: dev\ncors:\n  origin: '*'\n  methods:\n  - GET\n  - OPTION\n  headers:\n  - Content-Type\n  - X-Amz-Date\n  - Authorization\n  - X-Api-Key\nconfiguration:\n  swagger: '2.0'\n  info:\n    title: Sample API\n  schemes:\n  - https\n  paths:\n    /:\n      get:\n        produces:\n        - application/json\n        parameters:\n        - name: sample\n          in: query\n          required: false\n          type: string\n        responses:\n          '200':\n            description: 200 response\n            schema:\n              $ref: '#/definitions/Sample'\n  definitions:\n    Sample:\n      type: object\n```\n\n### api_id\nThe id of your REST API.  \nThis is written on automatically when you deployed your API with the `-w` option.\n\n### stage\nThe name of the stage in API Gateway.\n\n### cors\nCORS (Cross-Origin Resource Sharing) options.  \nIf you did not set the `x-amazon-apigateway-integration` option, these are set automatically.\n\n- origin  \nFor the response's header that named \"Access-Control-Allow-Origin\".\n- headers  \nFor the response's header that named \"Access-Control-Allow-Headers\".\n- methods  \nFor the response's header that named \"Access-Control-Allow-Methods\".\n\n### configuration\nThe settings of your APIs written in the `Swagger` format.  \nIf you did not set the `x-amazon-apigateway-integration` option, these are set automatically.\n\n# Commands\n\n### build\n\n- Build and archive your code and libraries to `\u003cyour-function-name\u003e.zip`\n- Store the secret informations to the archive\n\n```sh\nlamvery build [-e \u003cenv-name\u003e=\u003cenv-value\u003e]\n```\n\n### deploy\n\n- Build and deploy your code and libraries\n- Store the secret informations to the archive\n- Update configuration of the function\n- Set alias to a version of the function\n\n```sh\nlamvery deploy [-e \u003cenv-name\u003e=\u003cenv-value\u003e] [-a \u003calias\u003e]\n```\n\n### rollback\n\n- Rollback to the previous version of the function  \n\n**You must do one of the following to use this command.**\n\n- Deploy with `publish(-p,--publish)` and `alias(-a, --alias)` options.\n- Turn on(true) `versioning` and set a value to `default_alias` in the configuration file.\n\n```\nlamvery rollback [-a \u003calias\u003e]\n```\n\n### set-alias\n\n- Set alias to a version of the function\n\n```sh\nlamvery set-alias -a \u003calias\u003e -v \u003calias-version\u003e\n```\n\n### encrypt\n\n- Encrypt a text value using KMS\n\n```sh\nlamvery encrypt [-s] -n \u003csecret-name\u003e \u003csecret-value\u003e\n```\n\n### encrypt-file\n\n- Encrypt a file using KMS\n\n```sh\nlamvery encrypt [-s] -n \u003cfilename\u003e \u003clocal-file-path\u003e\n```\n\n### decrypt\n\n- Decrypt the secret information using KMS\n\n```sh\nlamvery decrypt -n \u003csecret-name\u003e\n```\n\n### events\n\n- Apply CloudWatch Events settings\n\n```sh\nlamvery events [-k] [-a \u003calias\u003e]\n```\n\n### invoke\n\n- Invoke the function and output result\n\n```sh\nlamvery invoke [-a \u003calias\u003e] [-v \u003cversion\u003e] '{\"foo\": \"bar\"}'\n```\nor\n```sh\nlamvery invoke [-a \u003calias\u003e] [-v \u003cversion\u003e] path/to/input.json\n```\n\n### logs\n\n- Watch the log events of the function\n\n```sh\nlamvery logs [-f] [-F \u003cfilter\u003e] [-s \u003cstart-time-string\u003e] [-i \u003cinterval-seconds\u003e]\n```\n\n### api\n\n- Manage your APIs\n\n```sh\nlamvery api [-n] [-r] [-s \u003cstage-name\u003e] [-w]\n```\n\n### generate\n\n- Generate skeleton files\n\n```sh\nlamvery generate -k \u003ckind-of-file\u003e\n```\n\n## Options\n\n### `-a` or `--alias`  \nThis option is needed by the `deploy`,`set-alias`,`invoke`,`rollback`,`events`,`api` commands.  \nAlias for a version of the function.\n\n### `-c` or `--conf-file`  \nThis option needed by all commands.  \nSpecify the configuration file.  \ndefault: `.lamvery.yml`\n\n### `-d` or `--dry-run`  \nThis option is needed by the `deploy`,`alias`,`rollback`,`events`,`api` commands.  \nOutput the difference of configuration and the alias without updating.\n\n### `-s` or `--single-file`  \nThis option is needed by the `archive` and `deploy` command.  \nArchive only the lambda function file, so you can inline edit in the AWS Management Console.\n\n### `-l` or `--no-libs`  \nThis option is needed by the `archive` and `deploy` command.  \nArchive without all libraries.\n\n### `-n` or `--secret-name`  \nThis option is needed by the `encrypt` and `decrypt` commands.  \nThe name of the secret value.\n\n### `-p` or `--publish`  \nThis option is only needed by the `deploy` command.\nPublish the version as an atomic operation.\n\n### `-k` or `--keep-empty-events`  \nThis option is only needed by the `events` command.\nKeep the empty CloudWatch Event Rule that does not have CloudWatch Event Target.\n\n### `-s` or `--store`  \nThis option is only needed by the `encrypt` command.  \nStore encripted value to configuration file (default: `.lamvery.yml`).  \nRequires the `-n` or `--secret-name` option.\n\n### `-v` or `--version`  \nThis option is needed by the `set-alias`,`invoke`,`rollback` commands.  \nVersion of the function.\n\n### `-f` or `--follow`  \nThis option is only needed by the `logs` command.  \nWatch the log events and updates the display (like `tail -f`).\n\n### `-F` or `--filter`  \nThis option is only needed by the `logs` command.  \nFiltering pattern for the log messages.\n\n### `-i` or `--interval`  \nThis option is only needed by the `logs` command.  \nIntervals(seconds) to watch the log events.\n\n### `-s` or `--start`  \nThis option is only needed by the `logs` command.  \nTime to start the log events watching.  \nExamples: `yesterday`,`\"-1 h\"`, `\"2016-01-01\"`, `\"2016-01-01 10:20:30\"`\n\n### `-t` or `--target`  \nThis option is only needed by the `set-alias` command.  \nThe alias of the version that is targeted for setting alias.\n\n### `-e` or `--env`\nThis option is needed by the `archive` and `deploy` commands.  \nEnvironment variables that pass to the function.  \n**This option can be used repeatedly to pass multiple variables.**  \nExamples: `FOO=BAR`\n\n### `-r` or `--remove`  \nThis option is only needed by the `api` command.  \nRemove your APIs.\n\n### `-s` or `--stage`  \nThis option is only needed by the `api` command.  \nThe name of the stage in API Gateway.\n\n### `-w` or `--write-id`\nThis option is only needed by the `api` command.  \nWrite the id of your API to the configuration file (default: `.lamvery.api.yml`)\n\n### `-n` or `--no-integrate`  \nThis option is only needed by the `api` command.  \nWithout automatic integration.\n\n### `-k` or `--kind`\nThis option is only needed by the `generate` command.  \nThe kind of the file.  \nAllowed values: `function`\n\n### `-n` or `--name`\nThis option is only needed by the `encrypt-file` command.  \nThe name of the secret file.\n\n# How to use the confidential information in the lambda function\n\n### 1. Create key on KMS  \nSee: https://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html\n\n### 2. Create IAM role for lambda function  \nPolicy example:  \n```json\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"kms:Decrypt\"\n            ],\n            \"Resource\": [\n                \"arn:aws:kms:us-east-1:\u003cyour-account-number\u003e:key/\u003cyour-key-id\u003e\"\n            ]\n        }\n    ]\n}\n```\n\n### 3. Set the key-id to your configuration file  \nConfiguration example:  \n\n- .lamvery.yml\n\n```yml\nprofile: default\nregion: us-east-1\nversioning: false\ndefault_alias: null\nconfiguration:\n  name: sample_lambda_function\n  runtime: python2.7 # or nodejs\n  role: arn:aws:iam::000000000000:role/lambda_basic_execution\n  handler: lambda_function.lambda_handler\n  description: This is sample lambda function.\n  timeout: 10\n  memory_size: 128\n```\n\n- .lamvery.secret.yml\n\n```yml\nkey_id: xxxx-yyyy-zzzz # \u003c-here!\ncipher_texts: {}\nsecret_files: {}\n```\n\n### 4. Encrypt and store the confidential information to your configuration file  \nCommand example:  \n```sh\nlamvery encrypt -s -n foo \"This is a secret\"\n```\n\n### 5. Write your function  \nGenerate the skeleton function by this command.\n```sh\nlamvery generate -k function\n```\n\nCode example:  \n\n- Python\n\n```py\n  import lamvery\n\n  def lambda_handler(event, context):\n      print(lamvery.secret.get('foo'))\n```\n\n- Node.js\n\n```js\nvar lamvery = require('./lamvery.js');\n\nexports.lambda_handler = function(event, context) {\n    lamvery.secret.get('foo', function(err, data) {\n        console.log(data);\n    });\n}\n```\n\n### 6. Deploy your function  \nCommand example:  \n```sh\nlamvery deploy\n```\n\n### 7. Invoke your function  \nCommand example:  \n```sh\nlamvery invoke {}\n```\n\nResult example:  \n```\nSTART RequestId: 13829c9c-9f13-11e5-921b-6f048cff3c2d Version: $LATEST\nThis is a secret\nEND RequestId: 13829c9c-9f13-11e5-921b-6f048cff3c2d\n```\n\n# How to use the confidential file in the lambda function\n\n### 1. Create key on KMS  \nSee: https://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html\n\n### 2. Create IAM role for lambda function  \nPolicy example:  \n```json\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"kms:Decrypt\"\n            ],\n            \"Resource\": [\n                \"arn:aws:kms:us-east-1:\u003cyour-account-number\u003e:key/\u003cyour-key-id\u003e\"\n            ]\n        }\n    ]\n}\n```\n\n### 3. Set the key-id to your configuration file  \nConfiguration example:  \n\n- .lamvery.yml\n\n```yml\nprofile: default\nregion: us-east-1\nversioning: false\ndefault_alias: null\nconfiguration:\n  name: sample_lambda_function\n  runtime: python2.7 # or nodejs\n  role: arn:aws:iam::000000000000:role/lambda_basic_execution\n  handler: lambda_function.lambda_handler\n  description: This is sample lambda function.\n  timeout: 10\n  memory_size: 128\n```\n\n- .lamvery.secret.yml\n\n```yml\nkey_id: xxxx-yyyy-zzzz # \u003c-here!\ncipher_texts: {}\nsecret_files: {}\n```\n\n### 4. Encrypt and store the confidential file to your configuration file  \nCommand example:  \n```sh\nlamvery encrypt-file -s -n foo.txt /path/to/local/confidential/file\n```\n\n### 5. Write your function  \nGenerate the skeleton function by this command.\n```sh\nlamvery generate -k function\n```\n\nCode example:  \n\n- Python\n\n```py\n  import lamvery\n\n  def lambda_handler(event, context):\n      print(open(lamvery.secret.file('foo.txt'), 'r').read())\n```\n\n- Node.js\n\n```js\nvar lamvery = require('./lamvery.js');\n\nexports.lambda_handler = function(event, context) {\n    lamvery.secret.file('foo.txt', function(err, path) {\n        fs.readFile(path, 'utf-8', function(err, txt) {\n            console.log(txt);\n        });\n    });\n}\n```\n\n### 6. Deploy your function  \nCommand example:  \n```sh\nlamvery deploy\n```\n\n### 7. Invoke your function  \nCommand example:  \n```sh\nlamvery invoke {}\n```\n\nResult example:  \n```\nSTART RequestId: 13829c9c-9f13-11e5-921b-6f048cff3c2d Version: $LATEST\nThis is a secret file\nEND RequestId: 13829c9c-9f13-11e5-921b-6f048cff3c2d\n```\n\nDevelopment\n-----------\n\n-   Source hosted at [GitHub](https://github.com/marcy-terui/lamvery)\n-   Report issues/questions/feature requests on [GitHub\n    Issues](https://github.com/marcy-terui/lamvery/issues)\n\nPull requests are very welcome! Make sure your patches are well tested.\nIdeally create a topic branch for every separate change you make. For\nexample:\n\n1.  Fork the repo\n2.  Create your feature branch (`git checkout -b my-new-feature`)\n3.  Commit your changes (`git commit -am 'Added some feature'`)\n4.  Push to the branch (`git push origin my-new-feature`)\n5.  Create new Pull Request\n\nAuthors\n-------\n\nCreated and maintained by [Masashi Terui](https://github.com/marcy-terui) (\u003cmarcy9114@gmail.com\u003e)\n\nLicense\n-------\n\nMIT License (see [LICENSE](https://github.com/marcy-terui/lamvery/blob/master/LICENSE))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcy-terui%2Flamvery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcy-terui%2Flamvery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcy-terui%2Flamvery/lists"}