-
Notifications
You must be signed in to change notification settings - Fork 0
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 #4 from zachrundle/eks
start eks module and fix tf fmt checker
- Loading branch information
Showing
9 changed files
with
227 additions
and
8 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
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
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
data "aws_iam_policy_document" "assume_role" { | ||
statement { | ||
effect = "Allow" | ||
|
||
principals { | ||
type = "Service" | ||
identifiers = ["eks.amazonaws.com"] | ||
} | ||
|
||
actions = ["sts:AssumeRole"] | ||
} | ||
} | ||
|
||
resource "aws_iam_role" "example" { | ||
name = "eks-cluster-example" | ||
assume_role_policy = data.aws_iam_policy_document.assume_role.json | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "example-AmazonEKSClusterPolicy" { | ||
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy" | ||
role = aws_iam_role.example.name | ||
} | ||
|
||
# Optionally, enable Security Groups for Pods | ||
# Reference: https://docs.aws.amazon.com/eks/latest/userguide/security-groups-for-pods.html | ||
resource "aws_iam_role_policy_attachment" "example-AmazonEKSVPCResourceController" { | ||
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSVPCResourceController" | ||
role = aws_iam_role.example.name | ||
} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
resource "aws_eks_cluster" "this" { | ||
name = var.cluster_name | ||
role_arn = aws_iam_role.example.arn | ||
count = var.create_eks ? 1 : 0 | ||
version = var.cluster_version | ||
|
||
vpc_config { | ||
subnet_ids = coalescelist(var.control_plane_subnet_ids, var.subnet_ids) | ||
} | ||
|
||
# Ensure that IAM Role permissions are created before and deleted after EKS Cluster handling. | ||
# Otherwise, EKS will not be able to properly delete EKS managed EC2 infrastructure such as Security Groups. | ||
depends_on = [ | ||
aws_iam_role_policy_attachment.example-AmazonEKSClusterPolicy, | ||
aws_iam_role_policy_attachment.example-AmazonEKSVPCResourceController, | ||
] | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# output "endpoint" { | ||
# value = aws_eks_cluster.this.endpoint | ||
# } | ||
|
||
# output "kubeconfig-certificate-authority-data" { | ||
# value = aws_eks_cluster.this.certificate_authority[0].data | ||
# } |
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
variable "create_eks" { | ||
type = bool | ||
default = false | ||
} | ||
|
||
variable "cluster_name" { | ||
description = "Name of the EKS cluster" | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "cluster_version" { | ||
description = "Kubernetes `<major>.<minor>` version to use for the EKS cluster (i.e.: `1.27`)" | ||
type = string | ||
default = null | ||
} | ||
|
||
# variable "authentication_mode" { | ||
# description = "The authentication mode for the cluster. Valid values are `CONFIG_MAP`, `API` or `API_AND_CONFIG_MAP`" | ||
# type = string | ||
# default = "API_AND_CONFIG_MAP" | ||
# } | ||
|
||
variable "control_plane_subnet_ids" { | ||
description = "A list of subnet IDs where the EKS cluster control plane (ENIs) will be provisioned. Used for expanding the pool of subnets used by nodes/node groups without replacing the EKS control plane" | ||
type = list(string) | ||
default = [] | ||
} | ||
|
||
variable "subnet_ids" { | ||
description = "A list of subnet IDs where the nodes/node groups will be provisioned. If `control_plane_subnet_ids` is not provided, the EKS cluster control plane (ENIs) will be provisioned in these subnets" | ||
type = list(string) | ||
default = [] | ||
} | ||
|
||
# variable "cluster_endpoint_private_access" { | ||
# description = "Indicates whether or not the Amazon EKS private API server endpoint is enabled" | ||
# type = bool | ||
# default = true | ||
# } | ||
|
||
# variable "cluster_endpoint_public_access" { | ||
# description = "Indicates whether or not the Amazon EKS public API server endpoint is enabled" | ||
# type = bool | ||
# default = false | ||
# } | ||
|
||
# variable "cluster_endpoint_public_access_cidrs" { | ||
# description = "List of CIDR blocks which can access the Amazon EKS public API server endpoint" | ||
# type = list(string) | ||
# default = ["0.0.0.0/0"] | ||
# } | ||
|
||
# variable "cluster_encryption_config" { | ||
# description = "Configuration block with encryption configuration for the cluster. To disable secret encryption, set this value to `{}`" | ||
# type = any | ||
# default = { | ||
# resources = ["secrets"] | ||
# } | ||
# } | ||
|
||
# variable "attach_cluster_encryption_policy" { | ||
# description = "Indicates whether or not to attach an additional policy for the cluster IAM role to utilize the encryption key provided" | ||
# type = bool | ||
# default = true | ||
# } | ||
|
||
# variable "cluster_tags" { | ||
# description = "A map of additional tags to add to the cluster" | ||
# type = map(string) | ||
# default = {} | ||
# } | ||
|
||
# variable "create_cluster_primary_security_group_tags" { | ||
# description = "Indicates whether or not to tag the cluster's primary security group. This security group is created by the EKS service, not the module, and therefore tagging is handled after cluster creation" | ||
# type = bool | ||
# default = true | ||
# } | ||
|
||
# variable "enable_cluster_creator_admin_permissions" { | ||
# description = "Indicates whether or not to add the cluster creator (the identity used by Terraform) as an administrator via access entry" | ||
# type = bool | ||
# default = true | ||
# } |
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
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,2 +1,3 @@ | ||
name = "playground" | ||
region = "us-west-2" | ||
name = "playground" | ||
region = "us-west-2" | ||
create_eks = true |
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