This action deletes all cloudformation xx/pr stacks in the provided region with the given name prefix when there's no corresponding branch.
The stage is transformed from the branch name (eg. #85-my-feature
> xx85
/ pr85
).
master
/main
stack is always ignored.
Make sure your CloudFormation Stacks are fully deletable (if autoDeleteBuckets=true also autoDeleteItems, etc.)
Required string
The github access token with scope repo
Required string
The prefix of the stack names to delete.
Optional JSON String Array
of stack identifiers to ignore. master
and main
stack is always ignored.
Optional boolean
default false. If true no stacks will be deleted. Only output the detected orphans.
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: 'arn:aws:iam::{ACCOUNT_ID}:role/{ROLE_NAME}'
aws-region: {AWS_REGION}
- name: Delete Orphan Stacks
uses: shiftcode/delete-orphan-cfn-stacks-action@v0.0.X
with:
githubToken: 'ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
stackNamePrefix: 'ch-website'
ignoreStacks: '["xx1"]'
- if there are stacks in multiple regions: use both actions two times with their corresponding region.
- if working with
assumedRoles
andaws-actions/configure-aws-credentials@v1
the policy statement for the static iam user needs to have the actions"sts:AssumeRole
ANDsts:TagSession
allowed on the role to assume. The Trust relationship of the assumed role needs to allow those actions for the assuming user.
To test the action locally: call index.js
with the env vars for the action inputs and repo name:
GITHUB_REPOSITORY="shiftcode/my-repo" INPUT_STACKNAMEPREFIX="ch-website" INPUT_GITHUBTOKEN="ghp_xxx"" INPUT_IGNORESTACKS="[]" node ./dist/index.js
- implement your changes
- commit with
npx commit
- set tag
git tag -a -m "my fancy release" v0.0.X
- push with tags
git push --follow-tags