Created
June 11, 2022 09:44
-
-
Save orihomie/e36205c50fe9a5ed98bcfad30cc79a57 to your computer and use it in GitHub Desktop.
Removes terraform s3 backend along with user and DynamoDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BUCKET_NAME=terraform-your_company_name-remote-store | |
BUCKET_REGION=eu-central-1 | |
USER_NAME=terraform-deployer | |
AWS_PROFILE=your_company_name | |
aws s3api delete-bucket \ | |
--profile $AWS_PROFILE \ | |
--bucket $BUCKET_NAME \ | |
--region $BUCKET_REGION | |
echo "Bucket has been deleted" | |
aws iam detach-user-policy --profile $AWS_PROFILE --user-name $USER_NAME --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess | |
aws iam detach-user-policy --profile $AWS_PROFILE --user-name $USER_NAME --policy-arn arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess | |
aws iam delete-user --profile $AWS_PROFILE --user-name $USER_NAME | |
echo "User has been deleted" | |
aws dynamodb delete-table \ | |
--profile $AWS_PROFILE \ | |
--table-name terraform-state-lock 1> /dev/null | |
echo "Dynamo DB has been deleted" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment