Edit by Mateus Paulo - Based on the HashiCorp tutorial https://learn.hashicorp.com/terraform/kubernetes/provision-eks-cluster#optional-configure-terraform-kubernetes-provider
Prerequisites The tutorial assumes some basic familiarity with Kubernetes and kubectl but does not assume any pre-existing deployment.
For this tutorial, you will need:
an AWS account the AWS CLI, installed and configured AWS IAM Authenticator the Kubernetes CLI, also known as kubectl »Set up and initialize your Terraform workspace In your terminal, clone the following repository. It contains the example configuration used in this tutorial.
$ git clone https://github.com/mateuspaulo/aws-eks-terraform.git
Change into the repository directory.
$ cd aws-eks-terraform
This example repository contains configuration to provision a VPC, security groups, and an EKS cluster. The diagram below shows the architecture this configuration defines:
The configuration is organized across multiple files:
versions.tf: sets the Terraform version to at least 1.3. It also sets versions for the providers used by the configuration.
variables.tf: contains a region variable that controls where to create the EKS cluster
vpc.tf: provisions a VPC, subnets, and availability zones using the AWS VPC Module. The module creates a new VPC for this tutorial so it doesn't impact your existing cloud environment and resources.
security-groups.tf: provisions the security groups the EKS cluster will use
eks-cluster.tf: uses the AWS EKS Module to provision an EKS Cluster and other required resources, including Auto Scaling Groups, Security Groups, IAM Roles, and IAM Policies.
Initialize your configuration.
terraform init
Run terraform apply
to create your cluster and other necessary resources. Confirm the operation with a yes.
This process should take approximately 10 minutes. Upon completion, Terraform will print your configuration's outputs.
Destroy any resources you create when you are done with this tutorial. Run terraform destroy
and confirm with yes in your terminal.
Enjoy!