How do you deploy to AWS EKS from GitHub Actions securely?
IntermediateProductionGitHub Actions and GitLab CI in Production
Answer
Assume an IAM role via OIDC, update kubeconfig, and deploy with Helm, or better, commit the new image tag to a GitOps repo so Argo CD deploys it and the workflow never needs cluster access. If you do push directly, map the IAM role to a Kubernetes RBAC role with access to only the target namespace via EKS access entries.
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::123456789012:role/gha-eks-deploy
aws-region: ap-south-1
- run: |
aws eks update-kubeconfig --name prod-cluster --region ap-south-1
helm upgrade --install shop-api ./chart -n shop --atomic --set image.tag=${{ github.sha }}
More on GitHub Actions and GitLab CI in Production
How do you organise reusable workflows for an organisation on GitHub?IntermediateHow do you reduce GitHub Actions minutes cost on private repos?IntermediateHow do you secure self-hosted runners?AdvancedHow do you design the GitHub Actions OIDC trust policy for AWS safely?AdvancedHow do you handle approvals and deployments across environments in GitHub Actions?IntermediateHow do you handle required checks when workflows use path filters or matrices?Advanced