From 1eb2efdad6c773ffcb5b4d561e8a567e94b0f3c2 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Thu, 6 Nov 2025 07:38:40 +0000 Subject: [PATCH 1/2] Add CodeDeploy automation --- appspec.yml | 14 ++++++++++++++ scripts/after_install.sh | 6 ++++++ scripts/start_service.sh | 4 ++++ 3 files changed, 24 insertions(+) create mode 100644 appspec.yml create mode 100755 scripts/after_install.sh create mode 100755 scripts/start_service.sh diff --git a/appspec.yml b/appspec.yml new file mode 100644 index 0000000..922fe39 --- /dev/null +++ b/appspec.yml @@ -0,0 +1,14 @@ +version: 0.0 +os: linux +files: + - source: / + destination: /home/ec2-user/Personal-expense-Tracker +hooks: + AfterInstall: + - location: scripts/after_install.sh + timeout: 600 + runas: ec2-user + ApplicationStart: + - location: scripts/start_service.sh + timeout: 300 + runas: ec2-user diff --git a/scripts/after_install.sh b/scripts/after_install.sh new file mode 100755 index 0000000..e161b6a --- /dev/null +++ b/scripts/after_install.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +cd /home/ec2-user/Personal-expense-Tracker +sudo pip3 install -r requirements.txt +sudo systemctl daemon-reload +sudo systemctl enable expenseapp.service diff --git a/scripts/start_service.sh b/scripts/start_service.sh new file mode 100755 index 0000000..5c176cc --- /dev/null +++ b/scripts/start_service.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -e +sudo systemctl restart expenseapp.service +sudo systemctl status expenseapp.service --no-pager From 30d03f1adfb5a845103e4d133b4703222e68f417 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Thu, 6 Nov 2025 08:45:13 +0000 Subject: [PATCH 2/2] Fix: added overwrite to appspec for CodeDeploy --- appsepc.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 appsepc.yml diff --git a/appsepc.yml b/appsepc.yml new file mode 100644 index 0000000..3dc7155 --- /dev/null +++ b/appsepc.yml @@ -0,0 +1,15 @@ +version: 0.0 +os: linux +files: + - source: / + destination: /home/ec2-user/Personal-expense-Tracker + overwrite: true +hooks: + AfterInstall: + - location: scripts/after_install.sh + timeout: 300 + runas: ec2-user + ApplicationStart: + - location: scripts/start_service.sh + timeout: 300 + runas: ec2-user