-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from bryantbiggs/refactor/v18-upgrade
refactor: Upgrade to v18 of EKS module
- Loading branch information
Showing
11 changed files
with
132 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Learn Terraform - Provision an EKS Cluster | ||
|
||
This repo is a companion repo to the [Provision an EKS Cluster learn guide](https://learn.hashicorp.com/terraform/kubernetes/provision-eks-cluster), containing | ||
Terraform configuration files to provision an EKS cluster on AWS. | ||
Terraform configuration files to provision an EKS cluster on AWS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,59 @@ | ||
module "eks" { | ||
source = "terraform-aws-modules/eks/aws" | ||
version = "17.24.0" | ||
source = "terraform-aws-modules/eks/aws" | ||
version = "18.26.3" | ||
|
||
cluster_name = local.cluster_name | ||
cluster_version = "1.20" | ||
subnets = module.vpc.private_subnets | ||
cluster_version = "1.22" | ||
|
||
vpc_id = module.vpc.vpc_id | ||
subnet_ids = module.vpc.private_subnets | ||
|
||
manage_aws_auth_configmap = true | ||
|
||
eks_managed_node_group_defaults = { | ||
ami_type = "AL2_x86_64" | ||
|
||
vpc_id = module.vpc.vpc_id | ||
attach_cluster_primary_security_group = true | ||
|
||
workers_group_defaults = { | ||
root_volume_type = "gp2" | ||
# Disabling and using externally provided security groups | ||
create_security_group = false | ||
} | ||
|
||
worker_groups = [ | ||
{ | ||
name = "worker-group-1" | ||
instance_type = "t2.small" | ||
additional_userdata = "echo foo bar" | ||
additional_security_group_ids = [aws_security_group.worker_group_mgmt_one.id] | ||
asg_desired_capacity = 2 | ||
}, | ||
{ | ||
name = "worker-group-2" | ||
instance_type = "t2.medium" | ||
additional_userdata = "echo foo bar" | ||
additional_security_group_ids = [aws_security_group.worker_group_mgmt_two.id] | ||
asg_desired_capacity = 1 | ||
}, | ||
] | ||
} | ||
eks_managed_node_groups = { | ||
one = { | ||
name = "node-group-1" | ||
|
||
data "aws_eks_cluster" "cluster" { | ||
name = module.eks.cluster_id | ||
} | ||
instance_types = ["t3.small"] | ||
|
||
min_size = 1 | ||
max_size = 3 | ||
desired_size = 2 | ||
|
||
data "aws_eks_cluster_auth" "cluster" { | ||
name = module.eks.cluster_id | ||
pre_bootstrap_user_data = <<-EOT | ||
echo 'foo bar' | ||
EOT | ||
|
||
vpc_security_group_ids = [ | ||
aws_security_group.node_group_one.id | ||
] | ||
} | ||
|
||
two = { | ||
name = "node-group-2" | ||
|
||
instance_types = ["t3.medium"] | ||
|
||
min_size = 1 | ||
max_size = 2 | ||
desired_size = 1 | ||
|
||
pre_bootstrap_user_data = <<-EOT | ||
echo 'foo bar' | ||
EOT | ||
|
||
vpc_security_group_ids = [ | ||
aws_security_group.node_group_two.id | ||
] | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,31 @@ | ||
# Kubernetes provider | ||
# https://learn.hashicorp.com/terraform/kubernetes/provision-eks-cluster#optional-configure-terraform-kubernetes-provider | ||
# To learn how to schedule deployments and services using the provider, go here: https://learn.hashicorp.com/terraform/kubernetes/deploy-nginx-kubernetes | ||
|
||
# The Kubernetes provider is included in this file so the EKS module can complete successfully. Otherwise, it throws an error when creating `kubernetes_config_map.aws_auth`. | ||
# You should **not** schedule deployments and services in this workspace. This keeps workspaces modular (one for provision EKS, another for scheduling Kubernetes resources) as per best practices. | ||
|
||
provider "kubernetes" { | ||
host = data.aws_eks_cluster.cluster.endpoint | ||
token = data.aws_eks_cluster_auth.cluster.token | ||
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data) | ||
host = module.eks.cluster_endpoint | ||
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data) | ||
|
||
exec { | ||
api_version = "client.authentication.k8s.io/v1beta1" | ||
command = "aws" | ||
# This requires the awscli to be available locally where Terraform is executed | ||
args = ["eks", "get-token", "--cluster-name", module.eks.cluster_id] | ||
} | ||
} | ||
|
||
provider "aws" { | ||
region = var.region | ||
} | ||
|
||
data "aws_availability_zones" "available" {} | ||
|
||
locals { | ||
cluster_name = "education-eks-${random_string.suffix.result}" | ||
} | ||
|
||
resource "random_string" "suffix" { | ||
length = 8 | ||
special = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.