Skip to content

fix ssh and creds error #15

fix ssh and creds error

fix ssh and creds error #15

Workflow file for this run

name: Set up EKS With Terraform
on: push
jobs:
LogInToAWS:
runs-on: ubuntu-latest
steps:
- name: Configure credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
TerraformPlan:
runs-on: ubuntu-latest
needs: LogInToAWS
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Initialize Terraform
run: terraform init
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
- name: Plan Terraform
run: terraform plan
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
TerraformApply:
runs-on: ubuntu-latest
needs: TerraformPlan
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Initialize Terraform (Again, if needed)
run: terraform init
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
- name: Apply Terraform
run: terraform apply -auto-approve
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
- 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
needs: TerraformApply
steps:
- name: Install SSH Client
run: sudo apt-get update && sudo apt-get install -y sshpass
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
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

Check failure on line 81 in .github/workflows/eks-setup.yaml

View workflow run for this annotation

GitHub Actions / Set up EKS With Terraform

Invalid workflow file

The workflow is not valid. .github/workflows/eks-setup.yaml (Line: 81, Col: 14): Unexpected symbol: 'EC2_SSH}_PRIVATE_KEY'. Located at position 9 within expression: secrets.EC2_SSH}_PRIVATE_KEY
- name: SSH and Install AWS CLI and kubectl
run: |
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
sudo ./aws/install
curl -O "https://s3.us-west-2.amazonaws.com/amazon-eks/1.28.11/2024-07-12/bin/linux/amd64/kubectl"
chmod +x ./kubectl
mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$HOME/bin:$PATH
kubectl version --client
aws eks update-kubeconfig --region ${{ secrets.AWS_REGION }} --name ${{ env.EKS_CLUSTER_NAME }}
EOF
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}