Skip to content

Commit 2d254ad

Browse files
authored
Merge pull request #9 from Snowflake-Labs/refactor-for-public
Refactor for public
2 parents debfcea + 99043b5 commit 2d254ad

File tree

14 files changed

+343
-49
lines changed

14 files changed

+343
-49
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# terraform-aws-eks-cluster
2-
Terraform AWS EKS cluster with eks managed node groups, security groups, ALB controller and external DNS using IRSA
2+
Terraform module to create AWS EKS cluster with EKS managed node groups, security groups, ALB controller and external DNS. The module enable IAM Roles for Service Accounts (IRSA) on the EKS cluster.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
aws_region = "us-west-2"
2+
kubernetes_version = "1.21"
3+
4+
env = "dev"
5+
module_prefix = "blue"
6+
7+
vpc_id = "vpc-XXXXX"
8+
private_subnet_ids = ["subnet-XXXXX", "subnet-XXXXX"]
9+
10+
allowed_cidr_blocks = ["IP CIDR BLOCK"]
11+
allowed_management_cidr_blocks = ["IP CIDR BLOCK"]
12+
13+
hosted_zone_subdomain = "kubenetes.example.com"
14+
aws_public_hosted_zone = "ROUTE53 PUBLIC HOSTED ZONE ID"
15+
aws_private_hosted_zone = "ROUTE53 PRIVATE HOSTED ZONE ID"
16+
17+
node_group_instance_sizes = ["t3.xlarge"]
18+
19+
eks_aws_auth_configmap_enable = true
20+
eks_aws_auth_configmap_roles = [
21+
{
22+
rolearn = "arn:aws:iam::XXXXX:role/eks-cluster-admin"
23+
username = "cluster-admin"
24+
groups = ["system:masters"]
25+
}
26+
]

examples/complete/main.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module "example_cluster" {
2+
source = "../../"
3+
4+
env = var.env
5+
aws_region = var.aws_region
6+
module_prefix = var.module_prefix
7+
kubernetes_version = var.kubernetes_version
8+
9+
allowed_cidr_blocks = var.allowed_cidr_blocks
10+
allowed_management_cidr_blocks = var.allowed_management_cidr_blocks
11+
12+
vpc_id = var.vpc_id
13+
private_subnet_ids = var.private_subnet_ids
14+
15+
aws_public_hosted_zone = var.aws_public_hosted_zone
16+
aws_private_hosted_zone = var.aws_private_hosted_zone
17+
18+
node_group_instance_sizes = var.node_group_instance_sizes
19+
20+
eks_aws_auth_configmap_enable = var.eks_aws_auth_configmap_enable
21+
eks_aws_auth_configmap_roles = var.eks_aws_auth_configmap_roles
22+
eks_aws_auth_configmap_users = var.eks_aws_auth_configmap_users
23+
}

examples/complete/outputs.tf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
output "eks_cluster_id" {
2+
value = module.example_cluster.eks_cluster_id
3+
}
4+
5+
output "cluster_endpoint" {
6+
description = "Endpoint for EKS control plane."
7+
value = module.example_cluster.cluster_endpoint
8+
}
9+
10+
output "cluster_primary_security_group_id" {
11+
description = "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. Referred to as 'Cluster security group' in the EKS console."
12+
value = module.example_cluster.cluster_primary_security_group_id
13+
}
14+
15+
output "cluster_security_group_id" {
16+
description = "Security group ids attached to the cluster control plane."
17+
value = module.example_cluster.cluster_security_group_id
18+
}
19+
20+
output "node_security_group_id" {
21+
description = "Security group ids attached to the worker nodes of the cluster."
22+
value = module.example_cluster.node_security_group_id
23+
}
24+
25+
output "cluster_iam_role_name" {
26+
description = "Cluster IAM role name."
27+
value = module.example_cluster.cluster_iam_role_name
28+
}
29+
30+
output "cluster_iam_role_arn" {
31+
description = "IAM role ARN of the EKS cluster."
32+
value = module.example_cluster.cluster_iam_role_arn
33+
}
34+
35+
output "aws_auth_configmap_yaml" {
36+
description = "Kubernetes configuration to authenticate to this EKS cluster."
37+
value = module.example_cluster.aws_auth_configmap_yaml
38+
}
39+
40+
output "eks_managed_node_groups" {
41+
description = "Outputs from node groups"
42+
value = module.example_cluster.eks_managed_node_groups
43+
}
44+

examples/complete/variables.tf

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Required
2+
variable "env" {
3+
description = "Deployment environment."
4+
type = string
5+
}
6+
7+
variable "aws_region" {
8+
description = "AWS Region."
9+
type = string
10+
}
11+
12+
variable "kubernetes_version" {
13+
description = "The version of the EKS cluster to create for sentry."
14+
type = string
15+
}
16+
17+
variable "vpc_id" {
18+
description = "VPC ID where the EKS cluster will be created."
19+
type = string
20+
}
21+
22+
variable "private_subnet_ids" {
23+
description = "Private subnet IDs to add kubernetes cluster on."
24+
type = list(string)
25+
default = []
26+
}
27+
28+
variable "hosted_zone_subdomain" {
29+
description = "Hosted zone subdomain."
30+
type = string
31+
}
32+
33+
variable "module_prefix" {
34+
description = "String to prefix resource names."
35+
type = string
36+
}
37+
38+
39+
# Optional
40+
variable "allowed_cidr_blocks" {
41+
description = "List of cidr to allow inbound traffic to the EKS cluster."
42+
type = list(string)
43+
default = []
44+
}
45+
46+
variable "allowed_management_cidr_blocks" {
47+
description = "List of cidr to allow inbound traffic to the EKS management API."
48+
type = list(string)
49+
default = []
50+
}
51+
52+
variable "aws_public_hosted_zone" {
53+
description = "Public Route53 hosted zone domain."
54+
type = string
55+
default = null
56+
}
57+
58+
variable "aws_private_hosted_zone" {
59+
description = "Private Route53 hosted zone subdomain."
60+
type = string
61+
default = null
62+
}
63+
64+
variable "node_group_instance_sizes" {
65+
description = "Node group instance sizes as a list of strings."
66+
type = list(string)
67+
default = ["t3.xlarge"]
68+
}
69+
70+
variable "eks_aws_auth_configmap_enable" {
71+
description = "Determines whether to manage the aws-auth configmap"
72+
type = bool
73+
default = false
74+
}
75+
76+
variable "eks_aws_auth_configmap_roles" {
77+
description = "List of role maps to add to the EKS cluster aws-auth configmap, require eks_aws_auth_configmap_enable to be true"
78+
type = list(any)
79+
default = []
80+
}
81+
82+
variable "eks_aws_auth_configmap_users" {
83+
description = "List of user maps to add to the EKS cluster aws-auth configmap, require eks_aws_auth_configmap_enable to be true"
84+
type = list(any)
85+
default = []
86+
}
87+
88+
locals {
89+
eks_cluster_name = "${var.module_prefix}-cluster"
90+
}

examples/complete/versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = "~> 1.4.6"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = "~> 4.38.0"
8+
}
9+
}
10+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
aws_region = "us-west-2"
2+
kubernetes_version = "1.21"
3+
4+
env = "dev"
5+
module_prefix = "blue"
6+
7+
vpc_id = "vpc-XXXXX"
8+
private_subnet_ids = ["subnet-XXXXX", "subnet-XXXXX"]
9+
10+
hosted_zone_subdomain = "kubenetes.example.com"
11+
aws_private_hosted_zone = "ROUTE53 PRIVATE HOSTED ZONE ID"

examples/simple/main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module "example_cluster" {
2+
source = "../../"
3+
4+
env = var.env
5+
aws_region = var.aws_region
6+
module_prefix = var.module_prefix
7+
kubernetes_version = var.kubernetes_version
8+
9+
vpc_id = var.vpc_id
10+
private_subnet_ids = var.private_subnet_ids
11+
12+
aws_private_hosted_zone = var.aws_private_hosted_zone
13+
}

examples/simple/outputs.tf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
output "eks_cluster_id" {
2+
value = module.example_cluster.eks_cluster_id
3+
}
4+
5+
output "cluster_endpoint" {
6+
description = "Endpoint for EKS control plane."
7+
value = module.example_cluster.cluster_endpoint
8+
}
9+
10+
output "cluster_primary_security_group_id" {
11+
description = "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. Referred to as 'Cluster security group' in the EKS console."
12+
value = module.example_cluster.cluster_primary_security_group_id
13+
}
14+
15+
output "cluster_security_group_id" {
16+
description = "Security group ids attached to the cluster control plane."
17+
value = module.example_cluster.cluster_security_group_id
18+
}
19+
20+
output "node_security_group_id" {
21+
description = "Security group ids attached to the worker nodes of the cluster."
22+
value = module.example_cluster.node_security_group_id
23+
}
24+
25+
output "cluster_iam_role_name" {
26+
description = "Cluster IAM role name."
27+
value = module.example_cluster.cluster_iam_role_name
28+
}
29+
30+
output "cluster_iam_role_arn" {
31+
description = "IAM role ARN of the EKS cluster."
32+
value = module.example_cluster.cluster_iam_role_arn
33+
}
34+
35+
output "aws_auth_configmap_yaml" {
36+
description = "Kubernetes configuration to authenticate to this EKS cluster."
37+
value = module.example_cluster.aws_auth_configmap_yaml
38+
}
39+
40+
output "eks_managed_node_groups" {
41+
description = "Outputs from node groups"
42+
value = module.example_cluster.eks_managed_node_groups
43+
}
44+

examples/simple/variables.tf

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
variable "env" {
2+
description = "Deployment environment."
3+
type = string
4+
}
5+
6+
variable "aws_region" {
7+
description = "AWS Region."
8+
type = string
9+
}
10+
11+
variable "kubernetes_version" {
12+
description = "The version of the EKS cluster to create for sentry."
13+
type = string
14+
}
15+
16+
variable "vpc_id" {
17+
description = "VPC ID where the EKS cluster will be created."
18+
type = string
19+
}
20+
21+
variable "private_subnet_ids" {
22+
description = "Private subnet IDs to add kubernetes cluster on."
23+
type = list(string)
24+
default = []
25+
}
26+
27+
variable "hosted_zone_subdomain" {
28+
description = "Hosted zone subdomain."
29+
type = string
30+
}
31+
32+
variable "aws_private_hosted_zone" {
33+
description = "Private Route53 hosted zone subdomain."
34+
type = string
35+
default = null
36+
}
37+
38+
variable "module_prefix" {
39+
description = "String to prefix resource names."
40+
type = string
41+
}
42+
43+
locals {
44+
eks_cluster_name = "${var.module_prefix}-cluster"
45+
}

0 commit comments

Comments
 (0)