CloudFormation management pattern using Jinja2
- awscli and credentials
- make
- python (python3 recommended)
.
├── .cache # put temporary files for diff
├── bin # put a python script to use jinja
├── dist # put files bundled by jinja
│ ├── ecr # `privileged-access` and `ecr` are example dir
│ └── privileged-access
└── src # write cfn templates by yaml
├── ecr
└── privileged-access
Install dependencies (cfn-lint, python-dotenv and jinja2).
make setup
At first, make a directory and edit template codes.
mkdir ./src/$YOUR_STACK_NAME
$EDITOR ./src/$YOUR_STACK_NAME/root.yaml.j2
Note: $YOUR_STACK_NAME
used to call make, as the target argument.
Well, bundle that into one template which putting ./dist/$YOUR_STACK_NAME
.
make bundle Target=privileged-access env=development
You can embedding variables by matching arguments at make bundle
, with the template embedded variable of jinja.
Also you lint it by aws cloudformation validate-template
and cfn-lint
.
make lint Target=privileged-access
make create/stack Target=privileged-access
make wait/stack-create Target=privileged-access
make create/change-set Target=privileged-access
make wait/change-set-create Target=privileged-access
make exec/change-set Target=privileged-access
make wait/stack-update Target=privileged-access
Get the notification from stderr when failed to create or update.
Waiter StackUpdateComplete failed: Waiter encountered a terminal failure state