Skip to main content

Hatch plugin for deploying to AWS with SAM

Project description

hatch-aws-publisher

PyPI - Version PyPI - Python Version Hatch project code style - black types - mypy imports - isort

AWS publisher plugin for Hatch 🥚🐍. Hatch is modern, extensible Python project manager.


Table of Contents

How to enable

Plugin must be installed in the same environment as Hatch itself.

python -m venv .venv
.venv/bin/pip install hatch-aws-publisher

How to use it

The publisher plugin name is called aws.

  1. Build you app with SAM. You can use my Hatch plugin hatch-aws.

  2. Put your SAM config to pyproject.toml (stack name is by default name of your project):

    [project]
    name = "my-app"
    
    [tool.hatch.publish.aws.sam]
    region = "us-west-1"
    confirm_changeset = false
    fail_on_empty_changeset = false
    force_upload = true
    capabilities = "CAPABILITY_IAM"
    s3_bucket = "my-bucket"
    parameter_overrides = ["stage=dev"]
    
    [tool.hatch.publish.aws.sam.tags]
    job = "batman"
    name = "bruce"
    
  3. Publish (deploy) your app.

    hatch publish -p aws
    

Options

section tool.hatch.publish.aws

This section allows to modify behavior of the plugin. Available options:

[tool.hatch.publish.aws]
stack_name_append_env = true
stack_name_prefix = "super-"
stack_name_suffix = "-man"
deploy = true

All above options can be overwritten using a CLI parameter

.venv/hatch/bin/hatch publish -p aws -o stack_name_prefix="bat-"
  • stack_name_prefix: adds a prefix to a stack name -> bat-my-app
  • stack_name_suffix: adds a suffix to a stack name -> bat-my-app-man
  • stack_name_append_env: adds a selected environment to a stack name -> bat-my-app-man-dev
  • deploy: if it's false, only sam config will be generated, but sam deploy will not be executed

section tool.hatch.publish.aws.sam

Default values for SAM. You can use any key:value pair available in SAM config.

Only difference is format of tags (they use separate section):

[tool.hatch.publish.aws.sam.tags]
job = "batman"
name = "bruce"

section tool.hatch.publish.aws.sam.env.<env-name>

You can define specific deployment environments. They inherit values from tool.hatch.publish.aws.sam.

Environment settings in pyproject.toml:

[tool.hatch.publish.aws.sam]
region = "us-west-1"
confirm_changeset = false
fail_on_empty_changeset = false
force_upload = true
capabilities = "CAPABILITY_IAM"

[tool.hatch.publish.aws.sam.env.dev]
region = "us-west-2"
s3_bucket = "dev-bucket"
parameter_overrides = ["stage=dev"]

[tool.hatch.publish.aws.sam.env.prd]
s3_bucket = "prd-bucket"
parameter_overrides = ["stage=prd"]
fail_on_empty_changeset = true

You need to specify an environment using a CLI parameter:

hatch publish -p aws -o env=dev

License

Plugin hatch-aws-publisher 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

hatch_aws_publisher-0.2.2.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

hatch_aws_publisher-0.2.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file hatch_aws_publisher-0.2.2.tar.gz.

File metadata

  • Download URL: hatch_aws_publisher-0.2.2.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.23.3

File hashes

Hashes for hatch_aws_publisher-0.2.2.tar.gz
Algorithm Hash digest
SHA256 c025de4f681353236c17ba819ebe7c78ee32143c9da07f05e161f5e141d358d0
MD5 232ca02a13f2a0a97de2c4ebcf948245
BLAKE2b-256 4a1f42c8d28a43212abbee9ae92c045ef27b848294685098bdade23576c92139

See more details on using hashes here.

File details

Details for the file hatch_aws_publisher-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for hatch_aws_publisher-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c33807f1f7135455dd5063094f0067d241925087a13c3326b8c0ae35f45c78a
MD5 9ef8d7d58603dba78b9c4a360f01a91d
BLAKE2b-256 f7535eeaf1c261f14c760e01895af59064251941f433c70e37b9240f96eb1d33

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page