EKS Deployment with ArgoCD with Terraform
Check this GitOps with ArgoCD, EKS and GitLab CI using Terraform) for detailed explanation.
These Environment Variables are needed for the pipeline when runnig Terraform commands.
AWS_ROLE ARN- AWS Role Arn to used by the pipeline to get temporary credentialsAWS_DEFAULT_REGION- AWS region where the S3 bucket is located
These Environment Variables are needed for the pipeline when runnig Terraform commands.
-
AWS_DEFAULT_REGION- AWS region to create the resources -
AWS_ACCESS_KEY_ID- Access Key ID to be used by the pipeline to authenticate with your AWS Account -
AWS_SECRET_ACCESS_KEY- Secret Access Key to authenticate with your AWS Account
You need to do these bootstrapping bits.
- Create an
S3 BucketandAmazon DynamoDBfor you to store terraform remote state and state locking. You can work with local state but... - Create a
Hosted zoneinRoute53with a public domain
Check backend.tfvars file in each folders (eks and argocd) and update accordingly.
Check sample.tfvars file in eks directory and update accordingly especially dns_hosted_zone, admin_users and developer_users.
You need to first apply the eks before applying argocd.
Check into the folder
cd eks# Initialize Terraform
terraform init -backend-config=backend.tfvars
# Generate Plan
terraform plan -out=eks.tfplan -var-file=sample.tfvars
# Apply the Plan
terraform apply eks.tfplanCheck into the folder
cd argocd# Initialize Terraform
terraform init -backend-config=backend.tfvars
# Generate Plan
terraform plan -out=argocd.tfplan
# Apply the Plan
terraform apply argocd.tfplanYou can create a docker compose file with this content.
This assumes you have configured MFA for your AWS IAM User you are using locally.
version: '3.7'
services:
terraform:
image: hashicorp/terraform:1.3.7
volumes:
- .:/infra
working_dir: /infra
environment:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}docker-compose -f docker-compose.yaml run --rm terraform init -backend-config=backend.tfvarsCheck this GitOps with ArgoCD, EKS and GitLab CI using Terraform) for detailed explanation.
See the LICENSE file for more info