Added scripts to create and delete users. Moved all scripts to new scripts folder
All checks were successful
AWS Deploy on Push / build (push) Successful in 4m21s
All checks were successful
AWS Deploy on Push / build (push) Successful in 4m21s
This commit is contained in:
36
scripts/create_cognito_user.sh
Executable file
36
scripts/create_cognito_user.sh
Executable file
@@ -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"
|
||||
18
scripts/delete_cognito_user.sh
Executable file
18
scripts/delete_cognito_user.sh
Executable file
@@ -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"
|
||||
23
scripts/deploy.sh
Executable file
23
scripts/deploy.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Deploy infrastructure
|
||||
cdk deploy
|
||||
|
||||
# Update application on running instances
|
||||
INSTANCE_IDS=$(aws ec2 describe-instances \
|
||||
--filters "Name=tag:Name,Values=IptvUpdater/IptvUpdaterInstance" \
|
||||
"Name=instance-state-name,Values=running" \
|
||||
--query "Reservations[].Instances[].InstanceId" \
|
||||
--output text)
|
||||
|
||||
for INSTANCE_ID in $INSTANCE_IDS; do
|
||||
echo "Updating application on instance: $INSTANCE_ID"
|
||||
aws ssm send-command \
|
||||
--instance-ids "$INSTANCE_ID" \
|
||||
--document-name "AWS-RunShellScript" \
|
||||
--parameters '{"commands":["cd /home/ec2-user/iptv-updater-aws && git pull && pip3 install -r requirements.txt && sudo systemctl restart iptv-updater"]}' \
|
||||
--no-cli-pager \
|
||||
--no-paginate
|
||||
done
|
||||
|
||||
echo "Deployment and instance update complete"
|
||||
4
scripts/destroy.sh
Executable file
4
scripts/destroy.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Destroy infrastructure
|
||||
cdk destroy --force
|
||||
Reference in New Issue
Block a user