From 3fc044e0e38bcf5ff14b090a059671f07f31689b Mon Sep 17 00:00:00 2001 From: Oloruntobi Olurombi Date: Thu, 29 Aug 2024 16:31:36 +0100 Subject: [PATCH] adjust workflow --- .github/workflows/eks-setup.yaml | 13 +++++++++---- main.tf | 4 ++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/eks-setup.yaml b/.github/workflows/eks-setup.yaml index e31e606..439a327 100644 --- a/.github/workflows/eks-setup.yaml +++ b/.github/workflows/eks-setup.yaml @@ -44,10 +44,6 @@ 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: | @@ -66,6 +62,15 @@ jobs: echo "EC2_PUBLIC_IP=$EC2_PUBLIC_IP" >> $GITHUB_ENV echo "Captured EC2 Public IP: $EC2_PUBLIC_IP" + - name: Verify EC2 Instance State + run: | + INSTANCE_STATE=$(aws ec2 describe-instances --instance-ids $(terraform output -raw ec2_instance_id) --query 'Reservations[*].Instances[*].State.Name' --output text) + echo "EC2 Instance State: $INSTANCE_STATE" + if [[ "$INSTANCE_STATE" != "running" ]]; then + echo "Error: EC2 instance is not running." + exit 1 + fi + InstallTools: runs-on: ubuntu-latest needs: TerraformApply diff --git a/main.tf b/main.tf index c867979..366b43c 100644 --- a/main.tf +++ b/main.tf @@ -95,6 +95,10 @@ output "ec2_public_ip" { value = aws_instance.control_plane.public_ip } +output "ec2_instance_id" { + value = aws_instance.control_plane.id +} + output "eks_cluster_name" { value = aws_eks_cluster.eks_cluster.name } \ No newline at end of file