From a5dfc1b493fb6dcc0cf83ef6b3380d27db3369b4 Mon Sep 17 00:00:00 2001 From: Stefano Date: Fri, 16 May 2025 14:19:14 -0500 Subject: [PATCH] Added scripts to create and delete users. Moved all scripts to new scripts folder --- scripts/create_cognito_user.sh | 36 ++++++++++++++++++++++++++++++++ scripts/delete_cognito_user.sh | 18 ++++++++++++++++ deploy.sh => scripts/deploy.sh | 0 destroy.sh => scripts/destroy.sh | 0 4 files changed, 54 insertions(+) create mode 100755 scripts/create_cognito_user.sh create mode 100755 scripts/delete_cognito_user.sh rename deploy.sh => scripts/deploy.sh (100%) rename destroy.sh => scripts/destroy.sh (100%) diff --git a/scripts/create_cognito_user.sh b/scripts/create_cognito_user.sh new file mode 100755 index 0000000..9890fac --- /dev/null +++ b/scripts/create_cognito_user.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -e + +if [ "$#" -lt 3 ]; then + echo "Usage: $0 USER_POOL_ID USERNAME PASSWORD [--admin]" + exit 1 +fi + +USER_POOL_ID=$1 +USERNAME=$2 +PASSWORD=$3 +ADMIN_FLAG=${4:-""} + +# Create user with temporary password +CREATE_CMD="aws cognito-idp admin-create-user --no-cli-pager \ + --user-pool-id \"$USER_POOL_ID\" \ + --username \"$USERNAME\" \ + --temporary-password \"TempPass123!\" \ + --output json > /dev/null 2>&1" + +if [ "$ADMIN_FLAG" == "--admin" ]; then + CREATE_CMD+=" --user-attributes Name=zoneinfo,Value=admin" +fi + +eval "$CREATE_CMD" + +# Set permanent password +aws cognito-idp admin-set-user-password --no-cli-pager \ + --user-pool-id "$USER_POOL_ID" \ + --username "$USERNAME" \ + --password "$PASSWORD" \ + --permanent \ + --output json > /dev/null 2>&1 + +echo "User $USERNAME created successfully" \ No newline at end of file diff --git a/scripts/delete_cognito_user.sh b/scripts/delete_cognito_user.sh new file mode 100755 index 0000000..78ccc68 --- /dev/null +++ b/scripts/delete_cognito_user.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +if [ "$#" -ne 2 ]; then + echo "Usage: $0 USER_POOL_ID USERNAME" + exit 1 +fi + +USER_POOL_ID=$1 +USERNAME=$2 + +aws cognito-idp admin-delete-user --no-cli-pager \ + --user-pool-id "$USER_POOL_ID" \ + --username "$USERNAME" \ + --output json > /dev/null 2>&1 + +echo "User $USERNAME deleted successfully" \ No newline at end of file diff --git a/deploy.sh b/scripts/deploy.sh similarity index 100% rename from deploy.sh rename to scripts/deploy.sh diff --git a/destroy.sh b/scripts/destroy.sh similarity index 100% rename from destroy.sh rename to scripts/destroy.sh