From 91406f243910c720b3b0418890d33d0bde33f6c1 Mon Sep 17 00:00:00 2001 From: Stefano Date: Thu, 15 May 2025 11:38:53 -0500 Subject: [PATCH] Created updated scripts to deploy/destroy manually --- deploy.sh | 25 ++++++++++++++++++++++--- destroy.sh | 4 ++++ install.sh | 5 +++++ 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 destroy.sh create mode 100644 install.sh diff --git a/deploy.sh b/deploy.sh index 7c74086..c2eb516 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,4 +1,23 @@ #!/bin/bash -npm install -g aws-cdk -python3 -m pip install -r requirements.txt -cdk deploy \ No newline at end of file + +# 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" \ No newline at end of file diff --git a/destroy.sh b/destroy.sh new file mode 100644 index 0000000..bcf2ca0 --- /dev/null +++ b/destroy.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Destroy infrastructure +cdk destroy \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..b6afad9 --- /dev/null +++ b/install.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# Install dependencies and deploy infrastructure +npm install -g aws-cdk +python3 -m pip install -r requirements.txt \ No newline at end of file