diff --git a/.github/scripts/run.sh b/.github/scripts/run.sh index 63b5a1a..41588fe 100644 --- a/.github/scripts/run.sh +++ b/.github/scripts/run.sh @@ -5,14 +5,15 @@ set -o pipefail # Exit if any command in a pipeline fails # Function to fetch a parameter and exit if it's empty fetch_parameter() { - local value - value=$(aws ssm get-parameter --name "$1" --with-decryption --query 'Parameter.Value' --output text | tr -d '\r\n') - if [ -z "$value" ]; then - echo "Error: SSM Parameter $1 is empty or could not be fetched." >&2 - exit 1 - fi - echo "$value" -} + local value + # Add the --region flag to the aws command + value=$(aws ssm get-parameter --name "$1" --with-decryption --query 'Parameter.Value' --output text --region "${AWS_REGION}" | tr -d '\r\n') + if [ -z "$value" ]; then + echo "Error: SSM Parameter $1 is empty or could not be fetched." >&2 + exit 1 + fi + echo "$value" + } # Fetch secrets from AWS SSM Parameter Store APP_BASE_URL=$(fetch_parameter "/unraveldocs/APP_BASE_URL") diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 653e394..7fc6f47 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -49,6 +49,8 @@ jobs: host: ${{ secrets.EC2_HOST }} username: ${{ secrets.EC2_USERNAME }} key: ${{ secrets.EC2_SSH_KEY }} + env: + AWS_REGION: ${{ env.AWS_REGION }} script: | # The EC2 instance role will be used for AWS commands # Log in to ECR using the instance role