Create EKS with an Existing VPC

Provision Amazon EKS cluster with Existing VPC using Eksctl

Previous Article

Tools

Method 1: The Labor Intensive Way

Part 1: Lovingly Handcraft the Config

Provision the Cluster

eksctl create cluster --config-file ./cluster_config.yaml

Method 2: Terraform Creates the Config

.
├── main.tf
├── provider.tf
├── terraform.tfvars
└── vpc
├── locals.tf
├── main.tf
├── variables.tf
└── versions.tf

Part 2.0: Create Config Module

mkdir eksctl_config
touch eksctl_config/{data,locals,main,variables}.tf
touch eksctl_config/cluster_config.yaml.tmpl
.
├── eksctl_config
│ ├── cluster_config.yaml.tmpl
│ ├── data.tf
│ ├── locals.tf
│ ├── main.tf
│ └── variables.tf

├── main.tf
├── provider.tf
└── vpc
├── locals.tf
├── main.tf
├── variables.tf
└── versions.tf

Part 2.1 Variables

Part 2.2 Main

Part 2.3 Data Sources

Part 2.4 Local Variables

Part 2.5 The Template File

Part 3: Add Output Variables from VPC Module

.
├── eksctl_config
│ ├── cluster_config.yaml.tmpl
│ ├── data.tf
│ ├── locals.tf
│ ├── main.tf
│ └── variables.tf
├── main.tf
├── provider.tf
├── terraform.tfvars
└── vpc
├── locals.tf
├── main.tf
├── output.tf
├── variables.tf
└── versions.tf

Part 4: Update Main Config

Part 5: Create the EKS Cluster

eksctl create cluster --config-file ./cluster_config.yaml

Method 2.1: But Wait There’s More

Variables

Data

eksctl_config/data.tf

Locals

# create cluster_config.yaml
terraform
apply
# provision using cluster_config.yaml
eksctl
create cluster --config-file ./cluster_config.yaml

Clean Up

Delete the Cluster

eksctl delete cluster --config-file ./cluster_config.yaml

Resources

Blog Source Code

Terraform

Terraform Bugs

Eksctl

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