AWS publisher plugin for Hatch 🥚🐍. Hatch is modern, extensible Python project manager.
Plugin must be installed in the same environment as Hatch
itself.
python -m venv .venv
.venv/bin/pip install hatch-aws-publisher
The publisher plugin name is called aws
.
-
Build you app with SAM. You can use my Hatch plugin hatch-aws.
-
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"
-
Publish (deploy) your app.
hatch publish -p 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, butsam deploy
will not be executed
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"
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
Plugin hatch-aws-publisher
is distributed under the terms of the MIT license.