{ "info": { "author": "Nicolas Bases", "author_email": "nmbases@protonmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# Lambada (Alpha)\nA simple way to work with AWS Lambda projects in Python. Heavily inspired and copied from https://github.com/nficano/python-lambda\n\n# Installation\n```\n$ pip install lambada-again\n```\n\n# Basic Usage\nA basic lambda without dependencies.\n\n``` \n$ tree\n\n\u251c\u2500\u2500 config.base.yaml # Base configuration file\n\u2514\u2500\u2500 config.py # Handler\n\u2514\u2500\u2500 service.py # Handler\n```\n\n### Init\n```\n$ lambada init\n```\n\n### Run\n```\n$ lambada run \n$ lambada run -n lambda-name\n```\n\nIf there is more than one `lambda` it shows options from where to chose.\n\n### Invoke remotely\n```\n$ lambada invoke\n$ lambada invoke -n lambda-name\n```\n\n### Deploy lambdas and layers\n```\n$ lambada deploy (deploy all)\n$ lambada deploy -n name\n$ lambada deploy -c config.qa.yaml\n$ lambada deploy -c config.prod.yaml\n```\n\nIf there is a layer associated to the lambda in the `config.yaml` without a version specified it will update it with the last one.\n\n### Update lambda configuration\n```\n$ lambada update-config\n$ lambada update-config -c config.qa.yaml\n$ lambada update-config -c config.prod.yaml\n```\nIf there is a layer associated to the lambda in the `config.yaml` without a version specified it will update it with the last one.\n\n### Build\n```\n$ lambada build\n```\nIt will create a zip file in the `./dist` directory\n\n\n## File structure\nWe need to have a configuration file and a main file to call.\n\n### With multiples configuration files\n``` \n$ tree\n\n\u251c\u2500\u2500 config.yaml\n\u251c\u2500\u2500 config.qa.yaml\n\u251c\u2500\u2500 config.prod.yaml\n\u251c\u2500\u2500 requirements.txt\n\u2514\u2500\u2500 service.py\n```\n\n### We can have parent-child configurations\nThe configuration files needs to have the same name. It will build only the `requirements.txt` at the lambda directory.\n\n``` \n$ tree\n\n\u251c\u2500\u2500 requirements.txt\n\u251c\u2500\u2500 lambda-A\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 README.md\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 requirements.txt\n\u2502 \u2514\u2500\u2500 service.py\n\u251c\u2500\u2500 lambda-B\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 README.md\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 requirements.txt\n\u2502 \u2514\u2500\u2500 service.py\n\u251c\u2500\u2500 config.yaml\n\u251c\u2500\u2500 config.prod.yaml\n\u251c\u2500\u2500 requirements.txt\n\u2514\u2500\u2500 README.md\n```\n\nAnd we need to execute the commands in the parent directory and specify the name of the lambda with `-n`.\n```\n$ lambada run -n lambda-A\n$ lambada deploy -n lambda-A -c config.prod.yaml\n$ lambada invoke -n lambda-A -c config.prod.yaml\n```\n\n## How to use it\n\n### Run locally\n```\n$ lambada run [-n lambda name] [-c configuration file]\n$ lambada run\n$ lambada run -n lambda-name\n```\n\n#### Configuration\n\n##### Event test file (optional)\nYou can test the lambda locally passing an event input defined in the configuration file as:\n\n```\n# path to file.property\ntest_event: event.input\n```\n\nThis will look for the `event.py` file in the lambda directory and get the `input` property from it.\n```\nlambda-directory$ cat event.py\ninput = {'test': 'test'}\n```\n\n##### Layers (optional)\nIf we define a local module as a layer it will load the layer so we can call it from our lambda.\n\n```\nlayers:\n - layer-name\n```\nWe need to have the dependencies installed in our local virtual environment.\n\n#### Environment vars\nYou can pass and override environment variables in the config.yaml using the `-e` option.\n```\n$ lambada run -e var1=value1 -e var2=value2\n```\n\n### Invoke remotly\n```\n$ lambada invoke [-n lambda name] [-c configuration file]\n$ lambada invoke\n$ lambada invoke -n lambda-name\n```\n\n### Build\nIt will bundle all the dependencies and create a `dist` directory with the zip file.\n\n```\n$ lambada build [-n lambda name] [-c configuration file]\n$ lambada build\n$ lambada build -n lambda-name\n```\n\n#### Configuration\n\n##### Requirements (optional)\nIf there is a requirements file specified it will install the packages locally\n```\nrequirements: requirements.txt\n```\n\n##### Directories (optional)\nBy default it will add only the directories specified in the `directories` section.\n```\ndirectories \n - src\n```\n\n##### Files (optional) (default= all files + main file - directories)\nBy default it will add all the files. You can specify which ones in the `files` section.\n```\nfiles: # Files we want to include in the root directoy \n - config.py\n```\n\n#### Symlink\nIt will copy the `symlink` into the bundle.\n\n### Deploy\nIt will create or update the Lambda and deploy the `zipfile` created in the `build` step into AWS.\n```\n$ lambada deploy [-n name] [-c configuration file]\n```\n\nDeploy all\n```\n$ lambada deploy\n```\n\nDeploy one lambda/layer\n```\n$ lambada deploy -n name\n```\n\nChoose configuration file\n```\n$ lambada deploy -c config.file.yaml\n```\n\n### Configuration\nThese values are required in the configuration file\n\n```\nname: lambda-function-name\ndescription: Description\nregion: us-east-1\nmain_file: service.py\nhandler: handler\nruntime: python3.6\nrole: lambda_basic_execution\n\naws_access_key_id: access_key_id\naws_secret_access_key: secret_access_key\n```\n\n#### Default values\n```\nmain_file: service.py\nhandler: handler\nruntime: python3.6\nrole: lambda_basic_execution\n```\n\n#### Environment variables\n```\nenvironment_variables:\n DB: 'postgresql://postgres:@localhost:5432/template'\n```\n\n#### Security groups and Subnets\n```\nsecurity_group_ids:\n - sg-123456789\n\nsubnet_ids:\n - subnet-a123456789\n - subnet-b123456789\n```\n\n#### Alias\n```\nalias: dev\n```\n\n#### Layers\n```\nlayers:\n - ../lib/config.yaml\n - name-of-the-layer\n```\n\n## Info\nIt will print the lambda information\n\n```\n$ lambada info [-n lambda name] [-c configuration file]\n$ lambada info\n$ lambada info -n lambda-name\n```\n\n## Update configuration\nIt will update the lambda configuration. Useful if we did only configuration changes.\n\n```\n$ lambada update_config [-n lambda name] [-c configuration file]\n$ lambada update_config\n$ lambada update_config -n lambda-name\n```\n\n### Configuration file example\n```\n$ cat config.base.yaml\nlambdas:\n base:\n abstract: True\n region: us-east-1\n runtime: python3.6\n role: lambda-role\n main_file: service.py\n handler: handler\n # path to file.property\n test_event: event.input\n\n security_group_ids:\n - sg-12345\n\n subnet_ids:\n - subnet-1\n - subnet-2\n\n lambda-test:\n parent: base\n name: function name test\n description: function description\n path: './lambda-test'\n\n environment_variables:\n DB: 'postgresql://postgres:@localhost:5432/template'\n TEST: 'test'\n\n directories # Directories we want to deploy\n - src\n\n files: # Files we want to include that are in the root directoy \n - config.py\n\n # We can specify a local layer or a remote layer\n layers:\n - layer-1\n\nlayers:\n layer-1:\n name: layer-1\n runtime: python3.6\n description: Layer-1\n requirements: requirements.txt\n path: layer\n```\n```\n$ cat config.yaml\naws_access_key_id: access_key_id\naws_secret_access_key: secret_access_key\n\nparent: config.base.yaml\n```\n\n## Layers\nWe can also `build`, `deploy`, `update` and get `info` on layers.\n\n### Lambda\nWe can define a layer dependency inside a lambda in two ways.\n\nWe can specify the name of the layer:\n```\nlayers:\n - name-of-the-layer\n```\n\nBy default it will set up the last version of the layer.\n\nYou can specify a different like this:\n```\nlayers:\n - name-of-the-layer,3\n```\n\n### Configuration file example\nThe main difference is the `is_layer` propertiy is set to `true`.\n\n```\nname: layer_name\ndescription: Description\nis_layer: true\nregion: us-east-1\nmain_file: service.py\nhandler: handler\nruntime: python3.6\n\nrequirements: requirements.txt\nfiles:\n - utils.py\n\ndirectories: \n - lib\n\naws_access_key_id: access_key_id\naws_secret_access_key: secret_access_key\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/rustico/lambada", "keywords": "lambada", "license": "MIT license", "maintainer": "", "maintainer_email": "", "name": "lambada-again", "package_url": "https://pypi.org/project/lambada-again/", "platform": "", "project_url": "https://pypi.org/project/lambada-again/", "project_urls": { "Homepage": "https://github.com/rustico/lambada" }, "release_url": "https://pypi.org/project/lambada-again/0.2.6/", "requires_dist": [ "Click (>=7)", "PyYAML (>=5)", "boto3 (>=1.9)" ], "requires_python": ">=3.6", "summary": "A simple way to create AWS Lambda projects in Python heavily inspired and copied from https://github.com/nficano/python-lambda", "version": "0.2.6" }, "last_serial": 5989790, "releases": { "0.2.6": [ { "comment_text": "", "digests": { "md5": "b0230540bc31541ce8241c81da52f60e", "sha256": "706aa053d8e5cbc453a412c04cef07575b15cd0583603cde700ce52ebe56c2f6" }, "downloads": -1, "filename": "lambada_again-0.2.6-py3-none-any.whl", "has_sig": false, "md5_digest": "b0230540bc31541ce8241c81da52f60e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 11070, "upload_time": "2019-10-17T13:34:02", "url": "https://files.pythonhosted.org/packages/41/c5/15a3519b87b1ea9ae8af31e6e2bee0a7d258e0d96e1b7c5c201a08d7eb4d/lambada_again-0.2.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a7682de5cbfce5f396d1509260d631ba", "sha256": "cd1b30e43421c0d256f7a6eb01ec6efb822c8988d3c27559d9636cea056be6c6" }, "downloads": -1, "filename": "lambada-again-0.2.6.tar.gz", "has_sig": false, "md5_digest": "a7682de5cbfce5f396d1509260d631ba", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 12465, "upload_time": "2019-10-17T13:34:07", "url": "https://files.pythonhosted.org/packages/1e/fc/f4e90a445b5c9f7b7bda0a8413a50d201d93e3996bd8c7d9a996a56195f8/lambada-again-0.2.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b0230540bc31541ce8241c81da52f60e", "sha256": "706aa053d8e5cbc453a412c04cef07575b15cd0583603cde700ce52ebe56c2f6" }, "downloads": -1, "filename": "lambada_again-0.2.6-py3-none-any.whl", "has_sig": false, "md5_digest": "b0230540bc31541ce8241c81da52f60e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 11070, "upload_time": "2019-10-17T13:34:02", "url": "https://files.pythonhosted.org/packages/41/c5/15a3519b87b1ea9ae8af31e6e2bee0a7d258e0d96e1b7c5c201a08d7eb4d/lambada_again-0.2.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a7682de5cbfce5f396d1509260d631ba", "sha256": "cd1b30e43421c0d256f7a6eb01ec6efb822c8988d3c27559d9636cea056be6c6" }, "downloads": -1, "filename": "lambada-again-0.2.6.tar.gz", "has_sig": false, "md5_digest": "a7682de5cbfce5f396d1509260d631ba", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 12465, "upload_time": "2019-10-17T13:34:07", "url": "https://files.pythonhosted.org/packages/1e/fc/f4e90a445b5c9f7b7bda0a8413a50d201d93e3996bd8c7d9a996a56195f8/lambada-again-0.2.6.tar.gz" } ] }