This repository contains the necessary code to deploy an infrastructure that supports a web application development lifecycle. The infrastructure includes the deployment of an EKS cluster, an ArgoCD instance for managing applications, and two applications to handle specific requests.
This solution is based on 3 terraform projects: eks, argocd, and applications.
-
eks: Provides the EKS cluster creation.
-
argocd: Installs ArgoCD.
-
applications: Sets up the ArgoCD applications.
It will provide only 2 ALB for each cluster:
- ArgoCD LoadBalancer
- Applications LoadBalancer (with prefixes /statics.html and /api)
To expedite the build of your environment, I haven't utilized an S3 backend for Terraform. However, it's important to emphasize that using an S3 backend is highly recommended.
The directory structure for this project is as follows:
-
main.tf: The main Terraform configuration file for the overall infrastructure setup. -
variables.tf: This file contains the variable declarations used in the main Terraform configuration file. -
outputs.tf: Defines the outputs that should be displayed after Terraform applies the configuration. -
modules: This directory contains sub-modules for each component of the infrastructure setup.-
eks: Terraform module for setting up the EKS cluster. -
argocd: Terraform module for deploying the ArgoCD instance. -
environments: This directory contains separate directories for each environment (production, stage, dev). -
Inside each environment directory, there are
.tfvarsfiles specific to that environment, which provide values for the variables declared invariables.tf. -
main.tfvarsfiles define the main configuration for each environment.
-
- Set up AWS credentials with appropriate permissions for Terraform.
- Update the necessary variables in the
main.tfandvariables.tffiles as per your requirements. - Customize the specific environment configurations by updating the
.tfvarsfiles in theenvironmentsdirectory.
Automatic apply & destroy:
IMPORTANT: The following scripts use -auto-approve Caution: Scripts use "-auto-approve". It automatically approves changes. Review carefully before running. Test and verify changes to avoid risks.
- Run
chmod +xandplan.shto check the plan changes. - Run
chmod +xandcreate.shand choose the environment you want to create. It will deploy the EKS Cluster and deploy the Argo CD instance and applications. - Run
chmod +xanddestroy.shand choose the environment you want to destroy.
If you prefer to execute it manually, please check create.sh and respect the execution order (eks, argocd, applications).
Related repos: argo-applications
Author: Andres Tarrio Date: July, 2023
Thanks for this opportunity!!