##################
AWS Lambda CI
##################
Continuous integration pipeline for aws lambda function
.. image:: https://github.com/obytes/aws-lambda-ci/raw/main/docs/images/demo_code_changed_deps_changed.gif
*********
Features
*********
✅ Supports the two famous lambda runtimes python and nodejs.
✅ Supports installing custom packages that does not exist in lambda runtime passed to CI process as a
package's descriptor file path in git repository.
✅ Supports installing custom pip/npm dependencies that does not exist in lambda runtime and passed to CI process as a
package's descriptor file path, `packages.json` or `requirements.txt`.
✅ The integration/deployment process is fast thanks to code and dependencies caching.
✅ The lambda dependencies packages are built in a sandboxed local environment that replicates the live AWS Lambda
environment almost identically – including installed software and libraries.
✅ The pipeline does not break the currently published version and traffic shifting between the current and new
deployment is seamless.
************
Requirements
************
IAM Permissions
===============
The user/role that call this pipeline should have these permissions attached to it.
.. code-block:: json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::artifacts-bucket-name/*",
"arn:aws:s3:::artifacts-bucket-name"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::artifacts-bucket-name/lambda-ci/function-name/*",
"arn:aws:s3:::artifacts-bucket-name/lambda-ci/function-name"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": [
"lambda:UpdateFunctionConfiguration",
"lambda:UpdateFunctionCode",
"lambda:UpdateAlias",
"lambda:PublishVersion",
"lambda:GetFunction"
],
"Resource": "arn:aws:lambda:us-east-1:YOUR_ACCOUNT_ID:function:function-name"
},
{
"Sid": "",
"Effect": "Allow",
"Action": [
"lambda:PublishLayerVersion",
"Lambda:ListLayerVersions"
],
"Resource": "arn:aws:lambda:us-east-1:YOUR_ACCOUNT_ID:layer:function-layer-name"
},
{
"Sid": "",
"Effect": "Allow",
"Action": "lambda:GetLayerVersion",
"Resource": "arn:aws:lambda:us-east-1:YOUR_ACCOUNT_ID:layer:function-layer-name:*"
}
]
}
Packages
========
- ``python3``
- ``docker``
*****
Usage
*****
Installation
============
.. code-block:: bash
pip3 install aws-lambda-ci
Arguments
=========
These are the available arguments:
+--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| ARG | USAGE |
+================================+============================================================================================================================================+
| --app-s3-bucket | The s3 bucket name that will hold the application code and dependencies |
| +----------+--------------------------------------+------------------------------------------------------------------------------------------+
| | Required | Default: None | Allowed: existing S3 bucket name |
+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+
| --function-name | AWS lambda function name |
| +----------+--------------------------------------+------------------------------------------------------------------------------------------+
| | Required | Default: None | Allowed: existing lambda function name |
+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+
| --function-runtime | AWS lambda function runtime (eg: python3.7) |
| +----------+--------------------------------------+------------------------------------------------------------------------------------------+
| | Optional | Default: ``python3.8`` | Allowed: ``pythonX.x``|``nodejsX.x`` |
+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+
| --function-alias-name | AWS Lambda alias name (eg: latest) |
| +----------+--------------------------------------+------------------------------------------------------------------------------------------+
| | Optional | Default: ``latest`` | Allowed: version tag (eg: ``latest``, ``qa``, ``prod`` ...) |
+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+
| --function-layer-name | AWS Lambda layer name (eg: demo-lambda-dependencies) |
| +----------+--------------------------------------+------------------------------------------------------------------------------------------+
| | Optional | Default: ``{function-name}-deps`` | Allowed: a valid layer name |
+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+
| --app-src-path | Lambda function sources directory that will be archived (eg: demo-lambda/src) |
| +----------+--------------------------------------+------------------------------------------------------------------------------------------+
| | Optional | Default: current directory | Allowed: an existing directory with source code |
+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+
| | Packages descriptor path (eg: demo-lambda/requirements.txt) |
| --app-packages-descriptor-path +----------+--------------------------------------+------------------------------------------------------------------------------------------+
| | Optional | Default: ``requirements.txt`` | Allowed: an existing and valid ``requirements.txt`` or ``package.json`` |
+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+
| --source-version | The unique revision id (eg: github commit sha, or SemVer tag) |
| +----------+--------------------------------------+------------------------------------------------------------------------------------------+
| | Optional | Default: Random hash | Allowed: ``commit`` hash | ``tag`` ver |
+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+
| --aws-profile-name | AWS profile name (if not provided, will use default aws env variables) |
| +----------+--------------------------------------+------------------------------------------------------------------------------------------+
| | Optional | Default: None | Allowed: existing aws profile name |
+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+
| --watch-log-stream | Watch lambda log stream in realtime after publishing the function |
| +----------+--------------------------------------+------------------------------------------------------------------------------------------+
| | Optional | Default: True | Allowed: Boolean |
+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+
| --build-docker-repo | Use custom build docker repository (other than lambci/lambda) |
| +----------+--------------------------------------+------------------------------------------------------------------------------------------+
| | Optional | Default: lambci/lambda | Allowed: a valid docker repo without image tag part |
+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+
| --build-docker-image | Custom build docker image tag (if not provided, will use build-{[python|node][runtime-version]}) lambci/lambda repo |
| +----------+--------------------------------------+------------------------------------------------------------------------------------------+
| | Optional | Default: None | Allowed: an existing docker image tag |
+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+
Example
========
.. code-block:: bash
aws-lambda-ci \
--app-s3-bucket "kodhive-prd-useast1-ippan-core-artifacts" \
--function-name "useast1-mimoto-api-v1-codeless" \
--function-runtime "python3.11" \
--function-alias-name "latest" \
--function-layer-name "useast1-mimoto-api-v1-codeless-deps" \
--app-src-path "app/api/src" \
--app-packages-descriptor-path "app/api/src/requirements/lambda.txt" \
--source-version "1.0.1" \
--aws-profile-name "kodhive_prd" \
--watch-log-stream \
--build-docker-repo public.ecr.aws/sam/build-python3.11 \
--build-docker-image latest
Demos
======
Code and dependencies changes
-----------------------------
If both code and dependencies changed, the pipeline will publish both changes.
.. image:: https://github.com/obytes/aws-lambda-ci/raw/main/docs/images/demo_code_changed_deps_changed.gif
Just code changed
-----------------
If code changed but not dependencies, the pipeline with publish new code and the dependencies will be left intact.
.. image:: https://github.com/obytes/aws-lambda-ci/raw/main/docs/images/demo_just_code_changed.gif
Nothing changed
---------------
If both code and dependencies not changed, the pipeline will not publish anything.
.. image:: https://github.com/obytes/aws-lambda-ci/raw/main/docs/images/demo_nothing_changed.gif
Raw data
{
"_id": null,
"home_page": "https://github.com/kodless/aws-lambda-ci",
"name": "aws-lambda-ci",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "aws, lambda, ci, cd, serverless",
"author": "Hamza Adami",
"author_email": "me@adamihamza.com",
"download_url": "https://files.pythonhosted.org/packages/a5/cb/d75698d4c444f5763e5a6bf8cabf776f22a12d702e527ef70d947df36f4f/aws_lambda_ci-0.0.8.tar.gz",
"platform": "any",
"description": "##################\nAWS Lambda CI\n##################\n\nContinuous integration pipeline for aws lambda function\n\n.. image:: https://github.com/obytes/aws-lambda-ci/raw/main/docs/images/demo_code_changed_deps_changed.gif\n\n*********\nFeatures\n*********\n\n\u2705 Supports the two famous lambda runtimes python and nodejs.\n\n\u2705 Supports installing custom packages that does not exist in lambda runtime passed to CI process as a\npackage's descriptor file path in git repository.\n\n\u2705 Supports installing custom pip/npm dependencies that does not exist in lambda runtime and passed to CI process as a\npackage's descriptor file path, `packages.json` or `requirements.txt`.\n\n\u2705 The integration/deployment process is fast thanks to code and dependencies caching.\n\n\u2705 The lambda dependencies packages are built in a sandboxed local environment that replicates the live AWS Lambda\nenvironment almost identically \u2013 including installed software and libraries.\n\n\u2705 The pipeline does not break the currently published version and traffic shifting between the current and new \ndeployment is seamless.\n\n************\nRequirements\n************\n\n\nIAM Permissions\n===============\n\nThe user/role that call this pipeline should have these permissions attached to it.\n\n.. code-block:: json\n\n {\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"s3:ListBucket\",\n \"s3:GetObject\"\n ],\n \"Resource\": [\n \"arn:aws:s3:::artifacts-bucket-name/*\",\n \"arn:aws:s3:::artifacts-bucket-name\"\n ]\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"s3:PutObject\",\n \"s3:GetObject\"\n ],\n \"Resource\": [\n \"arn:aws:s3:::artifacts-bucket-name/lambda-ci/function-name/*\",\n \"arn:aws:s3:::artifacts-bucket-name/lambda-ci/function-name\"\n ]\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"lambda:UpdateFunctionConfiguration\",\n \"lambda:UpdateFunctionCode\",\n \"lambda:UpdateAlias\",\n \"lambda:PublishVersion\",\n \"lambda:GetFunction\"\n ],\n \"Resource\": \"arn:aws:lambda:us-east-1:YOUR_ACCOUNT_ID:function:function-name\"\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"lambda:PublishLayerVersion\",\n \"Lambda:ListLayerVersions\"\n ],\n \"Resource\": \"arn:aws:lambda:us-east-1:YOUR_ACCOUNT_ID:layer:function-layer-name\"\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"lambda:GetLayerVersion\",\n \"Resource\": \"arn:aws:lambda:us-east-1:YOUR_ACCOUNT_ID:layer:function-layer-name:*\"\n }\n ]\n }\n\nPackages\n========\n\n- ``python3``\n- ``docker``\n\n\n*****\nUsage\n*****\n\nInstallation\n============\n\n.. code-block:: bash\n\n pip3 install aws-lambda-ci\n\n\nArguments\n=========\n\nThese are the available arguments:\n\n+--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+\n| ARG | USAGE |\n+================================+============================================================================================================================================+\n| --app-s3-bucket | The s3 bucket name that will hold the application code and dependencies |\n| +----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| | Required | Default: None | Allowed: existing S3 bucket name |\n+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| --function-name | AWS lambda function name |\n| +----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| | Required | Default: None | Allowed: existing lambda function name |\n+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| --function-runtime | AWS lambda function runtime (eg: python3.7) |\n| +----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| | Optional | Default: ``python3.8`` | Allowed: ``pythonX.x``|``nodejsX.x`` |\n+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| --function-alias-name | AWS Lambda alias name (eg: latest) |\n| +----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| | Optional | Default: ``latest`` | Allowed: version tag (eg: ``latest``, ``qa``, ``prod`` ...) |\n+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| --function-layer-name | AWS Lambda layer name (eg: demo-lambda-dependencies) |\n| +----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| | Optional | Default: ``{function-name}-deps`` | Allowed: a valid layer name |\n+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| --app-src-path | Lambda function sources directory that will be archived (eg: demo-lambda/src) |\n| +----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| | Optional | Default: current directory | Allowed: an existing directory with source code |\n+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| | Packages descriptor path (eg: demo-lambda/requirements.txt) |\n| --app-packages-descriptor-path +----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| | Optional | Default: ``requirements.txt`` | Allowed: an existing and valid ``requirements.txt`` or ``package.json`` |\n+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| --source-version | The unique revision id (eg: github commit sha, or SemVer tag) |\n| +----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| | Optional | Default: Random hash | Allowed: ``commit`` hash | ``tag`` ver |\n+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| --aws-profile-name | AWS profile name (if not provided, will use default aws env variables) |\n| +----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| | Optional | Default: None | Allowed: existing aws profile name |\n+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| --watch-log-stream | Watch lambda log stream in realtime after publishing the function |\n| +----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| | Optional | Default: True | Allowed: Boolean |\n+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| --build-docker-repo | Use custom build docker repository (other than lambci/lambda) |\n| +----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| | Optional | Default: lambci/lambda | Allowed: a valid docker repo without image tag part |\n+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| --build-docker-image | Custom build docker image tag (if not provided, will use build-{[python|node][runtime-version]}) lambci/lambda repo |\n| +----------+--------------------------------------+------------------------------------------------------------------------------------------+\n| | Optional | Default: None | Allowed: an existing docker image tag |\n+--------------------------------+----------+--------------------------------------+------------------------------------------------------------------------------------------+\n\n\nExample\n========\n\n.. code-block:: bash\n\n aws-lambda-ci \\\n --app-s3-bucket \"kodhive-prd-useast1-ippan-core-artifacts\" \\\n --function-name \"useast1-mimoto-api-v1-codeless\" \\\n --function-runtime \"python3.11\" \\\n --function-alias-name \"latest\" \\\n --function-layer-name \"useast1-mimoto-api-v1-codeless-deps\" \\\n --app-src-path \"app/api/src\" \\\n --app-packages-descriptor-path \"app/api/src/requirements/lambda.txt\" \\\n --source-version \"1.0.1\" \\\n --aws-profile-name \"kodhive_prd\" \\\n --watch-log-stream \\\n --build-docker-repo public.ecr.aws/sam/build-python3.11 \\\n --build-docker-image latest\n\nDemos\n======\n\nCode and dependencies changes\n-----------------------------\n\nIf both code and dependencies changed, the pipeline will publish both changes.\n\n.. image:: https://github.com/obytes/aws-lambda-ci/raw/main/docs/images/demo_code_changed_deps_changed.gif\n\n\nJust code changed\n-----------------\n\nIf code changed but not dependencies, the pipeline with publish new code and the dependencies will be left intact.\n\n.. image:: https://github.com/obytes/aws-lambda-ci/raw/main/docs/images/demo_just_code_changed.gif\n\n\nNothing changed\n---------------\n\nIf both code and dependencies not changed, the pipeline will not publish anything.\n\n.. image:: https://github.com/obytes/aws-lambda-ci/raw/main/docs/images/demo_nothing_changed.gif\n\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "Continuous integration pipeline for aws lambda function",
"version": "0.0.8",
"project_urls": {
"Homepage": "https://github.com/kodless/aws-lambda-ci"
},
"split_keywords": [
"aws",
" lambda",
" ci",
" cd",
" serverless"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ac8ff2fe0bb0def36ae936d591d6b74b7f6b015f823b938e20bb778a836e6106",
"md5": "7c65837b635db494667c4bc576ec09b0",
"sha256": "10fc9ca132cbd35a816d765650b6dbb5affc8d60f823bebf537662b0b38c9df3"
},
"downloads": -1,
"filename": "aws_lambda_ci-0.0.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7c65837b635db494667c4bc576ec09b0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 13002,
"upload_time": "2024-09-26T11:08:08",
"upload_time_iso_8601": "2024-09-26T11:08:08.750549Z",
"url": "https://files.pythonhosted.org/packages/ac/8f/f2fe0bb0def36ae936d591d6b74b7f6b015f823b938e20bb778a836e6106/aws_lambda_ci-0.0.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a5cbd75698d4c444f5763e5a6bf8cabf776f22a12d702e527ef70d947df36f4f",
"md5": "dc353d645e6a6824486a87276c932753",
"sha256": "9d21b81ead75630cf0b4696266b0cd503762fb8911b12f2a263daf60a7f0f425"
},
"downloads": -1,
"filename": "aws_lambda_ci-0.0.8.tar.gz",
"has_sig": false,
"md5_digest": "dc353d645e6a6824486a87276c932753",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 12715,
"upload_time": "2024-09-26T11:08:10",
"upload_time_iso_8601": "2024-09-26T11:08:10.145033Z",
"url": "https://files.pythonhosted.org/packages/a5/cb/d75698d4c444f5763e5a6bf8cabf776f22a12d702e527ef70d947df36f4f/aws_lambda_ci-0.0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-26 11:08:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kodless",
"github_project": "aws-lambda-ci",
"github_not_found": true,
"lcname": "aws-lambda-ci"
}