Files
query-orchestration/cmd/auth_related/mfa/creation.script.examples/delete.all.sh
T

40 lines
1.0 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# this script is untested
AWS_REGION="us-east-2"
AWS_PROFILE="aarete"
# set the domain prefix to delete here
DOMAIN_PREFIX="aarete-mfa-test"
USER_POOL_ID=$(aws cognito-idp describe-user-pool-domain \
--region "$AWS_REGION" \
--profile "$AWS_PROFILE" \
--domain "$DOMAIN_PREFIX" \
--query 'DomainDescription.UserPoolId' \
--output text)
if [ -z "$USER_POOL_ID" ]; then
echo "User pool not found for domain $DOMAIN_PREFIX. Exiting."
exit 1
fi
echo "User pool id to delete is $USER_POOL_ID."
echo "Deleting domain $DOMAIN_PREFIX from user pool $USER_POOL_ID..."
aws cognito-idp delete-user-pool-domain \
--region "$AWS_REGION" \
--profile "$AWS_PROFILE" \
--user-pool-id "$USER_POOL_ID" \
--domain "$DOMAIN_PREFIX"
echo "Waiting 30 seconds for domain deletion..."
sleep 30
echo "Deleting user pool $USER_POOL_ID..."
aws cognito-idp delete-user-pool \
--region "$AWS_REGION" \
--profile "$AWS_PROFILE" \
--user-pool-id "$USER_POOL_ID"
echo "Deletion complete. All resources cleaned up."