From 7ff7342d08387148e10b0ac41a5e6d7b2cc0feb0 Mon Sep 17 00:00:00 2001 From: Oloruntobi Olurombi Date: Tue, 27 Aug 2024 13:56:56 +0100 Subject: [PATCH] fix ssh and creds error --- .github/workflows/eks-setup.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/eks-setup.yaml b/.github/workflows/eks-setup.yaml index 16dad30..b181426 100644 --- a/.github/workflows/eks-setup.yaml +++ b/.github/workflows/eks-setup.yaml @@ -61,6 +61,10 @@ jobs: - name: Get EC2 Public IP id: get_public_ip run: echo "EC2_PUBLIC_IP=$(terraform output -raw ec2_public_ip)" >> $GITHUB_ENV + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.AWS_REGION }} InstallTools: runs-on: ubuntu-latest @@ -73,9 +77,12 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_REGION: ${{ secrets.AWS_REGION }} + - name: Setup SSH Key + run: echo "${{ secrets.EC2_SSH}_PRIVATE_KEY }}" > /tmp/private_key && chmod 600 /tmp/private_key + - name: SSH and Install AWS CLI and kubectl run: | - ssh -o StrictHostKeyChecking=no -i ${{ secrets.EC2_SSH_PRIVATE_KEY }} ec2-user@${{ env.EC2_PUBLIC_IP }} << EOF + ssh -o StrictHostKeyChecking=no -i /tmp/private_key ec2-user@${{ env.EC2_PUBLIC_IP }} << EOF sudo yum install -y unzip curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip