Hatch plugin for building AWS Lambda functions with SAM
Project description
hatch-aws
AWS builder plugin for Hatch ๐ฅ๐. Hatch is modern, extensible Python project manager.
Checkout my other plugin hatch-aws-publisher.
Table of Contents
Global dependency
Add hatch-aws
within the build-system.requires
field in your pyproject.toml
file.
[build-system]
requires = ["hatchling", "hatch-aws"]
build-backend = "hatchling.build"
Builder
The builder plugin name is called aws
.
To enable it, include following configuration in you config file:
-
pyproject.toml
[tool.hatch.build.targets.aws]
-
hatch.toml
[build.targets.aws]
How to use it
-
Put your module and lambdas inside of
src
folder.. โโโ pyproject.toml โโโ src โ โโโ my_app โ โโโ __init__.py โ โโโ common โ โ โโโ __init__.py โ โ โโโ config.py โ โ โโโ models.py โ โโโ lambdas โ โโโ lambda1 โ โ โโโ __init__.py โ โ โโโ main.py โ โโโ lambda2 โ โโโ __init__.py โ โโโ main.py โโโ template.yml
-
Specify common requirements for your project in
pyproject.toml
as dependencies.[project] dependencies = ["boto3"]
-
Specify requirements for your lambda functions in
pyproject.toml
as optional dependencies. Use module (folder) name.[project.optional-dependencies] lambda1 = ["pyaml"] lambda2 = ["request", "pydantic"]
-
Specify additional folders and files you want to copy to the build folder.
[tool.hatch.build.targets.aws] include = ["src/my_app/common"]
-
Set the
CodeUri
andHandler
parameter pointing to your lambdas in SAM template.Resources: Lambda1: Type: AWS::Serverless::Function Properties: FunctionName: lambda1-function CodeUri: src Handler: my_app.lambdas.lambda1.main.app ... Lambda2: Type: AWS::Serverless::Function Properties: FunctionName: lambda2-function CodeUri: src Handler: my_app.lambdas.lambda2.main.app ...
-
Run
hatch build
command.โฏ hatch build [aws] Building lambda functions ... Lambda1 ... success Lambda2 ... success Build successfull ๐ /path/to/projects/.aws-sam/build
Options
Following table contains available customization of builder behavior. You can find example of pyproject.toml
in tests/assets/pyproject.toml.
Option | Type | Default | Description |
---|---|---|---|
template |
str |
template.yml |
The filename of a SAM template. |
use-sam |
bool |
false |
Use only SAM for build. Do not run custom copy actions. |
sam-params |
array |
Pass additional options to a SAM build command |
License
Plugin hatch-aws
is distributed under the terms of the MIT license.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file hatch_aws-0.2.1.tar.gz
.
File metadata
- Download URL: hatch_aws-0.2.1.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.23.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d3ef00e99207e1c34c86b426b33c984a60de91b82524021a60cffe56fb51550 |
|
MD5 | 8c63dfabb01d7baa554c65ba59f09912 |
|
BLAKE2b-256 | 33d663e657ab9eae9abe0184d6125380ee118f465557c78617b218f292acbff0 |
File details
Details for the file hatch_aws-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: hatch_aws-0.2.1-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.23.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db0ef0c1d833686cfa734aacfbb316241c37ca0357837a912ca1d3d109d3d235 |
|
MD5 | 5847f2691628ca2cc35379f3b40f0535 |
|
BLAKE2b-256 | 29ae1cb74771b7b892396cc383ce256925b3c500783065b39e211de7a49ef515 |