This repository contains Terraform configuration files for setting up an Amazon EKS cluster along with a VPC, security groups, and necessary outputs. The following files are included:
eks-cluster.tf: Manages the EKS cluster and associated resources.outputs.tf: Defines the output values such as the cluster endpoint and security group ID.security-group.tf: Configures security groups for the EKS cluster.variables.tf: Declares variables used throughout the Terraform configuration.versions.tf: Specifies the required Terraform version and provider versions.vpc.tf: Configures the Virtual Private Cloud (VPC) and related networking resources.
Before you begin, ensure that you have:
- Terraform installed on your local machine.
- AWS CLI configured with appropriate access.
- An S3 bucket for storing Terraform state files.
git clone https://github.com/your-username/terraform-eks-setup.git
cd terraform-eks-setupRun the following command to initialize Terraform, which will download the necessary provider plugins.
terraform initReview the variables.tf file to adjust any variables specific to your environment, such as region, VPC CIDR, etc.
Generate an execution plan to preview the changes Terraform will apply:
terraform planApply the configuration to create the EKS cluster and related resources:
terraform applyOnce the cluster is created, you can access it using the Kubernetes CLI (kubectl). The cluster details can be found in the output values.
This screenshot demonstrates that Terraform has successfully generated an execution plan, detailing all the resources it will manage.
This screenshot confirms that the EKS cluster was successfully created, displaying the cluster name, status, and endpoint.
This shows the network infrastructure created by Terraform, including the VPC and subnets where the EKS cluster resides.
To destroy all resources created by Terraform, run the following command:
terraform destroy