Before you Begin
Ensure that the following points are considered.
The AWS CLI is configured.
The VPC is configured with at least two private subnets.
Terraform is installed.
kubectlis installed.
Configuring the Parameters
Configure the following parameters in the terraform.tfvars file available in the terraform directory.
| Name | Description | Type | Required |
|---|---|---|---|
vpc_id | Existing VPC ID. | string | Yes |
vpc_subnet_ids | List of private subnet IDs. | list(string) | Yes |
cluster_name | Name of the EKS cluster. Default set to "eks-terraform". | string | No |
aws_region | Region for the AWS deployment. Default set to "us-east-1". | string | No |
eks_cluster_role_arn | Existing IAM role for EKS control plane. Default set to null. | string | No |
eks_node_role_arn | Existing IAM role for node group. Default set to null. | string | No |
Deploying Terraform
Run the following script to deploy the application.
cd terraform
terraform init
terraform apply -auto-approve
Verifying the Installation
Run the following commands to verify the deployment.
terraform output
Sample output:
eks_cluster_name = "eks-terraform"
eks_cluster_endpoint = "<Endpoint URL>"
eks_cluster_region = "us-east-1"
eks_update_kubeconfig_command = "aws eks update-kubeconfig --region us-east-1 --name eks-terraform"
Run the following command to verify the cluster that was created.
kubectl get nodepools
Sample output:
NAME NODECLASS NODES READY AGE
general-purpose default 0 True ...
system default 0 True ...
Updating kubeconfig after Deployment
After deploying the cluster, update the local kubeconfig to interact with the cluster. The following commands links the kubeconfig command to the new EKS cluster.
$(terraform output -raw eks_update_kubeconfig_command)