Create an Amazon VPC for EKS

Provisioning Virtual Private Cloud for EKS using Terraform

The Wonderful EKSCtl Tool

The Tools Involved

Part 1: The VPC Module

Create Project Area

mkdir -p ~/my_vpc_project
export PROJECT=~/my_vpc_project

Create Structure and Files for the VPC Module

mkdir -p $PROJECT/vpc
touch $PROJECT/vpc/{locals,main,variables,versions}.tf

Versions

vpc/versions.tf

Variables

vpc/variables.tf

Locals

vpc/locals.tf

Main

vpc/main.tf

Part 2: Using the VPC Module

touch $PROJECT/{main,provider}.tf $PROJECT/terraform.tfvars

Provider

Main

External Variables

cat <<-EOF > terraform.tfvars
region = "us-east-2"
name = "acme-test-cluster"
EOF

Part 3: Create It

cd $PROJECT# download providers and modules
terraform init
# apply the infrastructure
terraform apply

Part 4: Destroy It

cd $PROJECT
terraform destroy

Resources

Blog Source Code

Terraform Modules

Next Article

Conclusion

Linux NinjaPants Automation Engineering Mutant — exploring DevOps, Kubernetes, CNI, IAC

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store