Skip to content

Instantly share code, notes, and snippets.

@cam8001
Last active May 22, 2023 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cam8001/dbc2171170220c387b936de3025fcec3 to your computer and use it in GitHub Desktop.
Save cam8001/dbc2171170220c387b936de3025fcec3 to your computer and use it in GitHub Desktop.
`Failed to delete stack: Role <role> is invalid or cannot be assumed` Assume this role from the cli if your cloudformation stack can't delete

Create a role with a trust policy that can be assumed by Cloudformation. Trust policy looks like this:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "",
            "Effect": "Allow",
            "Principal": {
                "Service": "cloudformation.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        }
    ]
}

Create a role with AdmininstratorAccess or something and attach the above trust policy (or just use the gui wizard). Give it a meaningful name, eg CfnAdmin. Then, you can delete your stack like this:

aws cloudformation delete-stack --stack-name name-of-stack-to-delete --role-arn arn:aws:iam::111111111111:role/CfnAdmin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment