Skip to content

Commit

Permalink
adding more steps to get EC2 IP
Browse files Browse the repository at this point in the history
  • Loading branch information
Oloruntobi Olurombi committed Aug 29, 2024
1 parent 1a2f5ae commit 67c9ed9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/eks-setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,27 @@ jobs:
- name: Apply Terraform
run: terraform apply -auto-approve

- name: Verify EC2 Instance State
run: |
aws ec2 describe-instances --instance-ids $(terraform output -raw ec2_instance_id) --query 'Reservations[*].Instances[*].State.Name' --output text
- name: Ensure EC2 Public IP is Not Empty
if: ${{ env.EC2_PUBLIC_IP == '' }}
run: |
echo "Error: EC2 Public IP is empty. Exiting."
exit 1
- name: Get EC2 Public IP
id: get_public_ip
run: |
#echo "EC2_PUBLIC_IP=$(terraform output -raw ec2_public_ip)" >> $GITHUB_ENV
#echo "EC2_PUBLIC_IP"=${{ env.EC2_PUBLIC_IP }}
terraform output -json > tf_output.json
EC2_PUBLIC_IP=$(jq -r '.ec2_public_ip.value' tf_output.json)
if [ -z "$EC2_PUBLIC_IP" ]; then
echo "Error: EC2 Public IP is empty."
exit 1
fi
echo "EC2_PUBLIC_IP=$EC2_PUBLIC_IP" >> $GITHUB_ENV
echo "Captured EC2 Public IP: $EC2_PUBLIC_IP"
InstallTools:
runs-on: ubuntu-latest
Expand Down

0 comments on commit 67c9ed9

Please sign in to comment.