Skip to content

Commit

Permalink
Another apporach.
Browse files Browse the repository at this point in the history
  • Loading branch information
everaldorodrigo committed Nov 29, 2023
1 parent a396243 commit a4ef5bf
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions .github/workflows/deploy_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,30 @@ jobs:
echo "aws_secret_access_key = $AWS_SECRET_ACCESS_KEY" >> ~/.aws/credentials
echo "region = $AWS_REGION" >> ~/.aws/credentials
# - name: Fetch EC2 instances from Auto Scaling Group
# run: |
# INSTANCE_IDS=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $AWS_AUTO_SCALING_GROUP_NAME --query "AutoScalingGroups[0].Instances[*].InstanceId" --output json)
# echo "Fetched instances from Auto Scaling Group: $INSTANCE_IDS"

# # INSTANCE_ID_STRING=$(echo $INSTANCE_IDS | jq -r '. | join(" ")')
# # echo "Fetched instances from Auto Scaling Group: $INSTANCE_ID_STRING"

- name: Open SSH port to GitHub Actions IP
run: |
aws ec2 authorize-security-group-ingress --group-id $AWS_SECURITY_GROUP_ID --protocol tcp --port 22 --cidr $(curl -s https://api.ipify.org)/32
- name: Save the private key to a file
- name: Deploy to EC2
run: |
echo "$AWS_EC2_SSH_KEY" > ~/.aws/key.pem
chmod 400 ~/.aws/key.pem # Set proper permissions
ls -la ~/.aws/key.pem
- name: Fetch EC2 instances from Auto Scaling Group
run: |
# Fetch EC2 instances from Auto Scaling Group
INSTANCE_IDS=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $AWS_AUTO_SCALING_GROUP_NAME --query "AutoScalingGroups[0].Instances[*].InstanceId" --output text)
echo $INSTANCE_IDS
- name: Create array with list of instances
run: |
# Create array with list of instances
echo "START: Create array with list of instances"
echo $INSTANCE_IDS
INSTANCES=( $INSTANCE_IDS )
echo $INSTANCES
echo "END: Create array with list of instances"
- name: Iterate over the array
run: |
# Iterate over the array
for INSTANCE_ID in "${INSTANCES[@]}"
do
echo "Processing instance: $INSTANCE_ID"
Expand Down

0 comments on commit a4ef5bf

Please sign in to comment.