diff --git a/.github/workflows/eks-setup.yaml b/.github/workflows/eks-setup.yaml index cbef0cc..96dd62d 100644 --- a/.github/workflows/eks-setup.yaml +++ b/.github/workflows/eks-setup.yaml @@ -57,4 +57,33 @@ jobs: 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)" + + InstallTools: + runs-on: ubuntu-latest + needs: TerraformApply + steps: + - name: Install SSH Client + run: sudo apt-get update && sudo apt-get install -y sshpass + + - name: SSH and Install AWS CLI and kubectl + run: | + sshpass -p "${{ secrets.EC2_SSH_PASSWORD }}" ssh -o StrictHostKeyChecking=no 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 + + + + diff --git a/main.tf b/main.tf index 66a4ff3..c867979 100644 --- a/main.tf +++ b/main.tf @@ -89,4 +89,12 @@ resource "aws_eks_node_group" "eks_node_group" { # OutPut Resources output "endpoint" { value = aws_eks_cluster.eks_cluster.endpoint +} + +output "ec2_public_ip" { + value = aws_instance.control_plane.public_ip +} + +output "eks_cluster_name" { + value = aws_eks_cluster.eks_cluster.name } \ No newline at end of file