Scope
This module creates a simple EKS cluster with basic requirements as in the AWS documentation using infrastructure as a code tool Terraform
To know more please visit my article on dev.io I explaned how to ceate a public eks cluster in more details
Getting started
There are two ways to use this module
The first way:
1- git clone https://github.com/Noura98Houssien/simple-EKS-cluster.git
2- cd simple-EKS-cluster
3- create a file with name terraform.tfvars and copy past the values as in terraform.tfvars.tmpl in example folder
vpc_name = "my-VPC1"
vpc_cidr = "10.0.0.0/16"
cluster_name = "my-EKS1"
desired_size = 2
max_size = 2
min_size = 1
instance_types = ["t3.medium"]
3- terraform init
4- terraform plan
5- terraform apply
The second way:
You need to replace vx.x.x with a required version and include that call in your code as simple-eks-cluster.tf at example folder.
module "public_eks_cluster" {
# note update the source link with the required version
source = "git::https://github.com/Noura98Houssien/simple-EKS-cluster.git?ref=vx.x.x"
vpc_name = "my-VPC1"
cluster_name = "my-EKS1"
desired_size = 2
max_size = 2
min_size = 1
instance_types = ["t3.medium"]
}
Requirements
Name | Version |
---|---|
terraform | >= 0.13.1 |
aws | >= 3.73 |
Providers
Name | Version |
---|---|
aws | 4.34.0 |
Modules
Name | Source | Version |
---|---|---|
vpc | git::https://github.com/terraform-aws-modules/terraform-aws-vpc.git | v3.16.0 |
Resources
Name | Type |
---|---|
aws_eks_cluster.this | resource |
aws_eks_node_group.this | resource |
aws_iam_role.eksClusterRole | resource |
aws_iam_role.eksWorkerNodeRole | resource |
aws_iam_role_policy_attachment.AmazonEC2ContainerRegistryReadOnly | resource |
aws_iam_role_policy_attachment.AmazonEKSClusterPolicy | resource |
aws_iam_role_policy_attachment.AmazonEKSVPCResourceController | resource |
aws_iam_role_policy_attachment.AmazonEKSWorkerNodePolicy | resource |
aws_iam_role_policy_attachment.AmazonEKS_CNI_Policy | resource |
aws_region.current | data source |
Inputs
Name | Description | Type | Default | Required |
---|---|---|---|---|
cluster_name | Name of the EKS Cluster. Must be between 1-100 characters in length. Must begin with an alphanumeric character, and must only contain alphanumeric characters, dashes and underscores (^[0-9A-Za-z][A-Za-z0-9-_]+$). | string |
n/a | yes |
desired_size | Desired size of the worker node, the default value is 2 | number |
2 |
no |
instance_types | List of instance types associated with the EKS Node Group. the default vaule is ["t3.medium"]. Terraform will only perform drift detection if a configuration value is provided. | list(string) |
[ |
no |
max_size | Maximum size of the worker node, the default value is 2 | number |
2 |
no |
min_size | Minimum size of the worker node, the default value is 1 | number |
1 |
no |
vpc_cidr | The Cidr of VPC where cluster will be created on, the default value is "10.0.0.0/16" | string |
"10.0.0.0/16" |
no |
vpc_name | Name of VPC where cluster will be created on | string |
n/a | yes |
Outputs
Name | Description |
---|---|
arn | EKS Cluster ARN |
cert | Certificate authority |
cluster_security_group_id | Cluster security group that was created by Amazon EKS for the cluster. Managed node groups use this security group for control-plane-to-data-plane communication. |
host | Endpoint for your Kubernetes API server. |
id | Name of the cluster. |
identity | Attribute block containing identity provider information for your cluster |
vpc_id | ID of the VPC associated with your cluster. |