This project provides a straightforward Terraform script to create an Amazon Elastic Kubernetes Service (EKS) cluster in AWS. Before running this script, ensure that you have the following prerequisites:
- AWS CLI Access: You must have an AWS CLI access key and secret with appropriate permissions to create an EKS cluster.
Follow these steps to set up and use the Terraform script:
-
Install Terraform: Download and install Terraform from the official website - Terraform Downloads.
-
Install AWS CLI: Install the AWS CLI on your system by following the instructions in the AWS documentation - AWS CLI Installation Guide.
-
Configure AWS CLI: Once the AWS CLI is installed, configure it with your credentials by running the command
aws configure
in your terminal. This will prompt you to enter your access key, secret key, default region, and default output format.
-
Clone this Repository: Clone this GitHub repository containing the Terraform script and other required files.
git clone https://github.com/sunil-9/terraform-aws-eks
cd terraform-aws-eks
-
Update Your Credentials: Open the
variables.tf
file in the repository and update it with your AWS credentials and other required variables. -
Initialize Terraform: Run the following command to initialize Terraform in the project directory.
terraform init
- Plan Terraform Execution: Before applying the changes, it's a good practice to preview what Terraform will do. Run the following command:
terraform plan
This will display the changes that Terraform will apply to your AWS environment.
- Create the EKS Cluster: If the plan looks good, you can proceed to create the EKS cluster by running the following command:
terraform apply
Terraform will prompt you to confirm the changes. Type yes
and hit Enter to create the EKS cluster.
If you want to remove the EKS cluster and associated resources, you can easily do so using Terraform. Follow these steps:
-
In your terminal, navigate to the project directory where the Terraform script is located.
-
Run the following command to plan the destruction and see what resources will be deleted:
terraform plan -destroy
- If the plan looks good, proceed to destroy the EKS cluster by running:
terraform destroy
Terraform will ask for confirmation before deleting the resources. Type yes
and hit Enter to proceed with the deletion.
Please exercise caution while using the terraform destroy
command as it will permanently remove all the resources associated with the EKS cluster.
By following these steps, you can easily create and manage an EKS cluster using Terraform. Happy Kubernetes-ing! 🚀