{"id":13600083,"url":"https://github.com/aka-raccoon/hatch-aws","last_synced_at":"2025-04-10T21:31:04.365Z","repository":{"id":58287990,"uuid":"527438282","full_name":"aka-raccoon/hatch-aws","owner":"aka-raccoon","description":"Hatch plugin for building AWS Lambda functions with SAM","archived":false,"fork":false,"pushed_at":"2023-02-25T20:08:58.000Z","size":46,"stargazers_count":13,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T09:46:36.294Z","etag":null,"topics":["aws","hatch"],"latest_commit_sha":null,"homepage":"","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/aka-raccoon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-08-22T06:25:57.000Z","updated_at":"2024-09-29T10:13:18.000Z","dependencies_parsed_at":"2024-01-16T23:26:23.274Z","dependency_job_id":"9aa32780-d191-426b-9a72-2e2ef4dc0e44","html_url":"https://github.com/aka-raccoon/hatch-aws","commit_stats":{"total_commits":38,"total_committers":5,"mean_commits":7.6,"dds":0.2894736842105263,"last_synced_commit":"de575a14432fee96d06ee014c763dff166967dfa"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aka-raccoon%2Fhatch-aws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aka-raccoon%2Fhatch-aws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aka-raccoon%2Fhatch-aws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aka-raccoon%2Fhatch-aws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aka-raccoon","download_url":"https://codeload.github.com/aka-raccoon/hatch-aws/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248301336,"owners_count":21080875,"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","hatch"],"created_at":"2024-08-01T18:00:22.624Z","updated_at":"2025-04-10T21:31:04.098Z","avatar_url":"https://github.com/aka-raccoon.png","language":"Python","funding_links":[],"categories":["Plugins"],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable-file no-inline-html first-line-h1 --\u003e\n\u003cdiv align=\"center\"\u003e\n\n# hatch-aws\n\n[![PyPI - Version](https://img.shields.io/pypi/v/hatch-aws.svg)](https://pypi.org/project/hatch-aws) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hatch-aws.svg)](https://pypi.org/project/hatch-aws) [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![code style - black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![types - mypy](https://img.shields.io/badge/types-Mypy-blue.svg)](https://github.com/python/mypy) [![imports - isort](https://img.shields.io/badge/imports-isort-ef8336.svg)](https://github.com/pycqa/isort)\n\nAWS builder plugin for **[Hatch 🥚🐍](\u003chttps://hatch.pypa.io/latest/\u003e)**.\n*Hatch is modern, extensible Python project manager.*\n\n\u003c/div\u003e\n\n---\n\nCheckout my other plugin [hatch-aws-publisher](https://github.com/aka-raccoon/hatch-aws-publisher).\n\n## Table of Contents\n\n- [hatch-aws](#hatch-aws)\n    - [Table of Contents](#table-of-contents)\n    - [Global dependency](#global-dependency)\n    - [Builder](#builder)\n        - [How to use it](#how-to-use-it)\n        - [Options](#options)\n    - [License](#license)\n\n## Global dependency\n\nAdd `hatch-aws` within the `build-system.requires` field in your `pyproject.toml` file.\n\n```toml\n[build-system]\nrequires = [\"hatchling\", \"hatch-aws\"]\nbuild-backend = \"hatchling.build\"\n```\n\n## Builder\n\nThe [builder plugin](https://hatch.pypa.io/latest/plugins/builder/reference/) name is called `aws`.\n\nTo start build process, run `hatch build -t aws`:\n\n```bash\n❯ hatch build -t aws\n[aws]\nBuilding lambda functions ...\nMyAwsLambdaFunc ... success\nBuild successfull 🚀\n/path/to/build/.aws-sam/build\n```\n\n### How to use it\n\n1. Put your module and lambdas inside of `src` folder.\n\n   ```shell\n   .\n   ├── pyproject.toml\n   ├── src\n   │   └── my_app\n   │       ├── __init__.py\n   │       ├── common\n   │       │   ├── __init__.py\n   │       │   ├── config.py\n   │       │   └── models.py\n   │       └── lambdas\n   │           ├── lambda1\n   │           │   ├── __init__.py\n   │           │   └── main.py\n   │           └── lambda2\n   │               ├── __init__.py\n   │               └── main.py\n   └── template.yml\n   ```\n\n2. Specify common requirements for your project in `pyproject.toml` as dependencies.\n\n   ```toml\n   [project]\n   dependencies = [\"boto3\"]\n   ```\n\n3. Specify requirements for your lambda functions in `pyproject.toml` as optional dependencies. Use resource name from SAM template, but you have to adapt it to be compliant with [PEP standard](https://peps.python.org/pep-0503/#normalized-names\u003e) (transform to lower case and replace `_` with `-`). For example, if you function name in SAM template is `GetAll_Accounts`, use `getall-accounts`.\n\n   ```toml\n   [project.optional-dependencies]\n   lambda1 = [\"pyaml\"]\n   lambda2 = [\"request\", \"pydantic\"]\n   ```\n\n4. Specify additional paths(source/destination) you want to copy to the build folder. Destination is relative to a build directory (`.aws-sam/build` by default). You can use glob `*` to copy common to all lambda functions.\n\n   ```toml\n   [tool.hatch.build.force-include]\n   \"src/batman/common\" = \"*/batman/common\" # copy to all lambda functions\n   \".editorconfig\" = \".editorconfig.txt\"\n   \"CHANGELOG.md\" = \"../CH.txt\"\n   \"images/\" = \"*/images\"\n   ```\n\n5. Set the `CodeUri` and `Handler` parameter pointing to your lambdas in SAM template. Only resources with `Runtime: python{version}` are supported. The rest is ignored.\n\n   ```yaml\n   Resources:\n    Lambda1:\n      Type: AWS::Serverless::Function\n      Properties:\n        Runtime: python3.9\n        FunctionName: lambda1-function\n        CodeUri: src\n        Handler: my_app.lambdas.lambda1.main.app\n        ...\n\n    Lambda2:\n      Type: AWS::Serverless::Function\n      Properties:\n        Runtime: python3.9\n        FunctionName: lambda2-function\n        CodeUri: src\n        Handler: my_app.lambdas.lambda2.main.app\n        ...\n   ```\n\n### Options\n\nFollowing table contains available customization of builder behavior. You can find example of `pyproject.toml` in [tests/assets/pyproject.toml](https://github.com/aka-raccoon/hatch-aws/blob/main/tests/assets/pyproject.toml).\n\n| Option       | Type    | Default        | Description                                              |\n| ------------ | ------- | -------------- | -------------------------------------------------------- |\n| `template`   | `str`   | `template.yml` | SAM template filename.                                   |\n| `use-sam`    | `bool`  | `false`        | Use only `sam build` command without any custom actions. |\n| `sam-exec`   | `str`   | `sam`          | Path to `sam` executable. Env var: `HATCH_SAM_EXEC`.     |\n| `sam-params` | `array` |                | Additional `sam build` args.                             |\n\n## License\n\nPlugin `hatch-aws` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faka-raccoon%2Fhatch-aws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faka-raccoon%2Fhatch-aws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faka-raccoon%2Fhatch-aws/lists"}