Provision Amazon EKS Cluster in one Click with Custom VPC  using  CloudFormation Template

Provision Amazon EKS Cluster in one Click with Custom VPC using CloudFormation Template

This article provides a comprehensive guide on deploying an Amazon EKS cluster using an AWS CloudFormation template eks_with_vpc.yaml. The template not only sets up the EKS cluster but also provisions the necessary VPC infrastructure through nested stacks. By following this guide, you will be able to streamline the deployment process, ensuring that all required resources are correctly configured and integrated


The CloudFormation template provisions the following resources

  • Amazon EKS Cluster: Sets up an EKS cluster with the specified name and Kubernetes version.

  • IAM Roles

    • EksRole: IAM role for the EKS cluster with permissions to manage the cluster.

    • EksNodeRole: IAM role for worker nodes within the EKS cluster, granting necessary permissions.

  • WorkerNodes: you can update the size and machine type of the worker node using the parameters section of the file.

  • VPC: it will create custom VPC with public and private subnets in multiple AZs,


To deploy this CloudFormation template, follow these steps

  1. Clone the Repository

     git clone
     cd eks-cluster-cloudformation

this repository has two yml one for creating VPC VPC.yaml and another eks_with_vpc.yaml which has the reference of vpc.yaml file in the template URL section of the VPC Resource

Note: The VPC configuration is handled by a nested CloudFormation stack (VpcStack), so the VPC.yaml file should be placed in an S3 for example (

then update the eks_with_vpc.yam TemplateURL in VPCstack block resource

Deploy the Stack: Use the AWS CloudFormation CLI or AWS Management Console to deploy the eks_with_vpc.yaml template. Ensure you have the necessary IAM permissions.

Example CLI command

aws cloudformation create-stack \
  --region REGION \
  --stack-name my-eks-cluster \
  --capabilities CAPABILITY_NAMED_IAM \
  --template-body file://eks_with_vpc.yaml

We can also do it with the console of Cloudformation by clicking Create Stack and then uploading the eks_with_vpc.yaml file, also make sure you have added the templateURL for VPC,


The template supports the following parameters

  • ClusterName: The name for your EKS cluster.

  • NumberOfWorkerNodes: The number of worker nodes in the EKS node group.

  • WorkerNodesInstanceType: The EC2 instance type for the worker nodes.

  • KubernetesVersion: The version of Kubernetes to use for the EKS cluster.

you can also modify other settings using parameters option in template YAML


Ensure that the AWS IAM user executing this CloudFormation template has permission to create the required resources (EKS cluster, IAM roles, networking resources, EC2).

Did you find this article valuable?

Support Muhammad Usama by becoming a sponsor. Any amount is appreciated!