1
0
mirror of https://github.com/terraform-aws-modules/terraform-aws-eks.git synced 2025-09-09 19:32:58 +08:00

Update changelog

Fix cluster count
This commit is contained in:
syst0m
2019-10-31 16:51:40 +00:00
committed by Tomislav Tomasic
parent c89da3772e
commit 75248e97df
7 changed files with 34 additions and 34 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
### Added ### Added
- Write your awesome addition here (by @you) - Added destroy-time flag (by @syst0m)
### Changed ### Changed
+2 -2
View File
@@ -1,11 +1,11 @@
resource "local_file" "config_map_aws_auth" { resource "local_file" "config_map_aws_auth" {
count = var.write_aws_auth_config && local.enabled ? 1 : 0 count = var.write_aws_auth_config && var.enabled ? 1 : 0
content = data.template_file.config_map_aws_auth.rendered content = data.template_file.config_map_aws_auth.rendered
filename = "${var.config_output_path}config-map-aws-auth_${var.cluster_name}.yaml" filename = "${var.config_output_path}config-map-aws-auth_${var.cluster_name}.yaml"
} }
resource "null_resource" "update_config_map_aws_auth" { resource "null_resource" "update_config_map_aws_auth" {
count = var.manage_aws_auth && local.enabled ? 1 : 0 count = var.manage_aws_auth && var.enabled ? 1 : 0
depends_on = [aws_eks_cluster.this] depends_on = [aws_eks_cluster.this]
provisioner "local-exec" { provisioner "local-exec" {
+8 -8
View File
@@ -1,5 +1,5 @@
resource "aws_cloudwatch_log_group" "this" { resource "aws_cloudwatch_log_group" "this" {
count = length(var.cluster_enabled_log_types) > 0 && local.enabled ? 1 : 0 count = length(var.cluster_enabled_log_types) > 0 && var.enabled ? 1 : 0
name = "/aws/eks/${var.cluster_name}/cluster" name = "/aws/eks/${var.cluster_name}/cluster"
retention_in_days = var.cluster_log_retention_in_days retention_in_days = var.cluster_log_retention_in_days
kms_key_id = var.cluster_log_kms_key_id kms_key_id = var.cluster_log_kms_key_id
@@ -7,7 +7,7 @@ resource "aws_cloudwatch_log_group" "this" {
} }
resource "aws_eks_cluster" "this" { resource "aws_eks_cluster" "this" {
count = local.enabled count = var.enabled ? 1 : 0
name = var.cluster_name name = var.cluster_name
enabled_cluster_log_types = var.cluster_enabled_log_types enabled_cluster_log_types = var.cluster_enabled_log_types
role_arn = local.cluster_iam_role_arn role_arn = local.cluster_iam_role_arn
@@ -34,7 +34,7 @@ resource "aws_eks_cluster" "this" {
} }
resource "aws_security_group" "cluster" { resource "aws_security_group" "cluster" {
count = var.cluster_create_security_group && local.enabled ? 1 : 0 count = var.cluster_create_security_group && var.enabled ? 1 : 0
name_prefix = var.cluster_name name_prefix = var.cluster_name
description = "EKS cluster security group." description = "EKS cluster security group."
vpc_id = var.vpc_id vpc_id = var.vpc_id
@@ -47,7 +47,7 @@ resource "aws_security_group" "cluster" {
} }
resource "aws_security_group_rule" "cluster_egress_internet" { resource "aws_security_group_rule" "cluster_egress_internet" {
count = var.cluster_create_security_group && local.enabled ? 1 : 0 count = var.cluster_create_security_group && var.enabled ? 1 : 0
description = "Allow cluster egress access to the Internet." description = "Allow cluster egress access to the Internet."
protocol = "-1" protocol = "-1"
security_group_id = local.cluster_security_group_id security_group_id = local.cluster_security_group_id
@@ -58,7 +58,7 @@ resource "aws_security_group_rule" "cluster_egress_internet" {
} }
resource "aws_security_group_rule" "cluster_https_worker_ingress" { resource "aws_security_group_rule" "cluster_https_worker_ingress" {
count = var.cluster_create_security_group && local.enabled ? 1 : 0 count = var.cluster_create_security_group && var.enabled ? 1 : 0
description = "Allow pods to communicate with the EKS cluster API." description = "Allow pods to communicate with the EKS cluster API."
protocol = "tcp" protocol = "tcp"
security_group_id = local.cluster_security_group_id security_group_id = local.cluster_security_group_id
@@ -69,7 +69,7 @@ resource "aws_security_group_rule" "cluster_https_worker_ingress" {
} }
resource "aws_iam_role" "cluster" { resource "aws_iam_role" "cluster" {
count = var.manage_cluster_iam_resources && local.enabled ? 1 : 0 count = var.manage_cluster_iam_resources && var.enabled ? 1 : 0
name_prefix = var.cluster_name name_prefix = var.cluster_name
assume_role_policy = data.aws_iam_policy_document.cluster_assume_role_policy.json assume_role_policy = data.aws_iam_policy_document.cluster_assume_role_policy.json
permissions_boundary = var.permissions_boundary permissions_boundary = var.permissions_boundary
@@ -79,13 +79,13 @@ resource "aws_iam_role" "cluster" {
} }
resource "aws_iam_role_policy_attachment" "cluster_AmazonEKSClusterPolicy" { resource "aws_iam_role_policy_attachment" "cluster_AmazonEKSClusterPolicy" {
count = var.manage_cluster_iam_resources && local.enabled ? 1 : 0 count = var.manage_cluster_iam_resources && var.enabled ? 1 : 0
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy" policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
role = local.cluster_iam_role_name role = local.cluster_iam_role_name
} }
resource "aws_iam_role_policy_attachment" "cluster_AmazonEKSServicePolicy" { resource "aws_iam_role_policy_attachment" "cluster_AmazonEKSServicePolicy" {
count = var.manage_cluster_iam_resources && local.enabled ? 1 : 0 count = var.manage_cluster_iam_resources && var.enabled ? 1 : 0
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSServicePolicy" policy_arn = "arn:aws:iam::aws:policy/AmazonEKSServicePolicy"
role = local.cluster_iam_role_name role = local.cluster_iam_role_name
} }
+1 -1
View File
@@ -1,5 +1,5 @@
resource "local_file" "kubeconfig" { resource "local_file" "kubeconfig" {
count = var.write_kubeconfig && local.enabled ? 1 : 0 count = var.write_kubeconfig && var.enabled ? 1 : 0
content = data.template_file.kubeconfig.rendered content = data.template_file.kubeconfig.rendered
filename = "${substr(var.config_output_path, -1, 1) == "/" ? "${var.config_output_path}kubeconfig_${var.cluster_name}" : var.config_output_path}" filename = "${substr(var.config_output_path, -1, 1) == "/" ? "${var.config_output_path}kubeconfig_${var.cluster_name}" : var.config_output_path}"
} }
+1 -1
View File
@@ -295,7 +295,7 @@ variable "attach_worker_cni_policy" {
} }
variable "enabled" { variable "enabled" {
description = "Destroy-time flag. If set to "false", the count will be set to "0" on all resources." description = "Destroy-time flag. If set to `false`, the count will be set to `0` on all resources."
type = bool type = bool
default = true default = true
} }
+17 -17
View File
@@ -1,7 +1,7 @@
# Worker Groups using Launch Configurations # Worker Groups using Launch Configurations
resource "aws_autoscaling_group" "workers" { resource "aws_autoscaling_group" "workers" {
count = (local.worker_group_count * local.enabled) count = var.enabled ? local.worker_group_count : 0
name_prefix = join( name_prefix = join(
"-", "-",
compact( compact(
@@ -143,7 +143,7 @@ resource "aws_autoscaling_group" "workers" {
} }
resource "aws_launch_configuration" "workers" { resource "aws_launch_configuration" "workers" {
count = (local.worker_group_count * local.enabled) count = var.enabled ? local.worker_group_count : 0
name_prefix = "${aws_eks_cluster.this.name}-${lookup(var.worker_groups[count.index], "name", count.index)}" name_prefix = "${aws_eks_cluster.this.name}-${lookup(var.worker_groups[count.index], "name", count.index)}"
associate_public_ip_address = lookup( associate_public_ip_address = lookup(
var.worker_groups[count.index], var.worker_groups[count.index],
@@ -232,7 +232,7 @@ resource "aws_launch_configuration" "workers" {
} }
resource "random_pet" "workers" { resource "random_pet" "workers" {
count = (local.worker_group_count * local.enabled) count = var.enabled ? local.worker_group_count : 0
separator = "-" separator = "-"
length = 2 length = 2
@@ -243,7 +243,7 @@ resource "random_pet" "workers" {
} }
resource "aws_security_group" "workers" { resource "aws_security_group" "workers" {
count = var.worker_create_security_group && local.enabled ? 1 : 0 count = var.worker_create_security_group && var.enabled ? 1 : 0
name_prefix = aws_eks_cluster.this.name name_prefix = aws_eks_cluster.this.name
description = "Security group for all nodes in the cluster." description = "Security group for all nodes in the cluster."
vpc_id = var.vpc_id vpc_id = var.vpc_id
@@ -257,7 +257,7 @@ resource "aws_security_group" "workers" {
} }
resource "aws_security_group_rule" "workers_egress_internet" { resource "aws_security_group_rule" "workers_egress_internet" {
count = var.worker_create_security_group && local.enabled ? 1 : 0 count = var.worker_create_security_group && var.enabled ? 1 : 0
description = "Allow nodes all egress to the Internet." description = "Allow nodes all egress to the Internet."
protocol = "-1" protocol = "-1"
security_group_id = local.worker_security_group_id security_group_id = local.worker_security_group_id
@@ -268,7 +268,7 @@ resource "aws_security_group_rule" "workers_egress_internet" {
} }
resource "aws_security_group_rule" "workers_ingress_self" { resource "aws_security_group_rule" "workers_ingress_self" {
count = var.worker_create_security_group && local.enabled ? 1 : 0 count = var.worker_create_security_group && var.enabled ? 1 : 0
description = "Allow node to communicate with each other." description = "Allow node to communicate with each other."
protocol = "-1" protocol = "-1"
security_group_id = local.worker_security_group_id security_group_id = local.worker_security_group_id
@@ -279,7 +279,7 @@ resource "aws_security_group_rule" "workers_ingress_self" {
} }
resource "aws_security_group_rule" "workers_ingress_cluster" { resource "aws_security_group_rule" "workers_ingress_cluster" {
count = var.worker_create_security_group && local.enabled ? 1 : 0 count = var.worker_create_security_group && var.enabled ? 1 : 0
description = "Allow workers pods to receive communication from the cluster control plane." description = "Allow workers pods to receive communication from the cluster control plane."
protocol = "tcp" protocol = "tcp"
security_group_id = local.worker_security_group_id security_group_id = local.worker_security_group_id
@@ -290,7 +290,7 @@ resource "aws_security_group_rule" "workers_ingress_cluster" {
} }
resource "aws_security_group_rule" "workers_ingress_cluster_kubelet" { resource "aws_security_group_rule" "workers_ingress_cluster_kubelet" {
count = var.worker_create_security_group && local.enabled ? var.worker_sg_ingress_from_port > 10250 ? 1 : 0 : 0 count = var.worker_create_security_group && var.enabled ? var.worker_sg_ingress_from_port > 10250 ? 1 : 0 : 0
description = "Allow workers Kubelets to receive communication from the cluster control plane." description = "Allow workers Kubelets to receive communication from the cluster control plane."
protocol = "tcp" protocol = "tcp"
security_group_id = local.worker_security_group_id security_group_id = local.worker_security_group_id
@@ -301,7 +301,7 @@ resource "aws_security_group_rule" "workers_ingress_cluster_kubelet" {
} }
resource "aws_security_group_rule" "workers_ingress_cluster_https" { resource "aws_security_group_rule" "workers_ingress_cluster_https" {
count = var.worker_create_security_group && local.enabled ? 1 : 0 count = var.worker_create_security_group && var.enabled ? 1 : 0
description = "Allow pods running extension API servers on port 443 to receive communication from cluster control plane." description = "Allow pods running extension API servers on port 443 to receive communication from cluster control plane."
protocol = "tcp" protocol = "tcp"
security_group_id = local.worker_security_group_id security_group_id = local.worker_security_group_id
@@ -312,7 +312,7 @@ resource "aws_security_group_rule" "workers_ingress_cluster_https" {
} }
resource "aws_iam_role" "workers" { resource "aws_iam_role" "workers" {
count = var.manage_worker_iam_resources && local.enabled ? 1 : 0 count = var.manage_worker_iam_resources && var.enabled ? 1 : 0
name_prefix = var.workers_role_name != "" ? null : aws_eks_cluster.this.name name_prefix = var.workers_role_name != "" ? null : aws_eks_cluster.this.name
name = var.workers_role_name != "" ? var.workers_role_name : null name = var.workers_role_name != "" ? var.workers_role_name : null
assume_role_policy = data.aws_iam_policy_document.workers_assume_role_policy.json assume_role_policy = data.aws_iam_policy_document.workers_assume_role_policy.json
@@ -323,7 +323,7 @@ resource "aws_iam_role" "workers" {
} }
resource "aws_iam_instance_profile" "workers" { resource "aws_iam_instance_profile" "workers" {
count = var.manage_worker_iam_resources && local.enabled ? local.worker_group_count : 0 count = var.manage_worker_iam_resources && var.enabled ? local.worker_group_count : 0
name_prefix = aws_eks_cluster.this.name name_prefix = aws_eks_cluster.this.name
role = lookup( role = lookup(
var.worker_groups[count.index], var.worker_groups[count.index],
@@ -335,37 +335,37 @@ resource "aws_iam_instance_profile" "workers" {
} }
resource "aws_iam_role_policy_attachment" "workers_AmazonEKSWorkerNodePolicy" { resource "aws_iam_role_policy_attachment" "workers_AmazonEKSWorkerNodePolicy" {
count = var.manage_worker_iam_resources && local.enabled ? 1 : 0 count = var.manage_worker_iam_resources && var.enabled ? 1 : 0
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy" policy_arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy"
role = aws_iam_role.workers[0].name role = aws_iam_role.workers[0].name
} }
resource "aws_iam_role_policy_attachment" "workers_AmazonEKS_CNI_Policy" { resource "aws_iam_role_policy_attachment" "workers_AmazonEKS_CNI_Policy" {
count = var.manage_worker_iam_resources && var.attach_worker_cni_policy && local.enabled ? 1 : 0 count = var.manage_worker_iam_resources && var.attach_worker_cni_policy && var.enabled ? 1 : 0
policy_arn = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy" policy_arn = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
role = aws_iam_role.workers[0].name role = aws_iam_role.workers[0].name
} }
resource "aws_iam_role_policy_attachment" "workers_AmazonEC2ContainerRegistryReadOnly" { resource "aws_iam_role_policy_attachment" "workers_AmazonEC2ContainerRegistryReadOnly" {
count = var.manage_worker_iam_resources && local.enabled ? 1 : 0 count = var.manage_worker_iam_resources && var.enabled ? 1 : 0
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly" policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
role = aws_iam_role.workers[0].name role = aws_iam_role.workers[0].name
} }
resource "aws_iam_role_policy_attachment" "workers_additional_policies" { resource "aws_iam_role_policy_attachment" "workers_additional_policies" {
count = var.manage_worker_iam_resources && local.enabled ? length(var.workers_additional_policies) : 0 count = var.manage_worker_iam_resources && var.enabled ? length(var.workers_additional_policies) : 0
role = aws_iam_role.workers[0].name role = aws_iam_role.workers[0].name
policy_arn = var.workers_additional_policies[count.index] policy_arn = var.workers_additional_policies[count.index]
} }
resource "aws_iam_role_policy_attachment" "workers_autoscaling" { resource "aws_iam_role_policy_attachment" "workers_autoscaling" {
count = var.manage_worker_iam_resources && var.manage_worker_autoscaling_policy && var.attach_worker_autoscaling_policy && local.enabled ? 1 : 0 count = var.manage_worker_iam_resources && var.manage_worker_autoscaling_policy && var.attach_worker_autoscaling_policy && var.enabled ? 1 : 0
policy_arn = aws_iam_policy.worker_autoscaling[0].arn policy_arn = aws_iam_policy.worker_autoscaling[0].arn
role = aws_iam_role.workers[0].name role = aws_iam_role.workers[0].name
} }
resource "aws_iam_policy" "worker_autoscaling" { resource "aws_iam_policy" "worker_autoscaling" {
count = var.manage_worker_iam_resources && var.manage_worker_autoscaling_policy && local.enabled ? 1 : 0 count = var.manage_worker_iam_resources && var.manage_worker_autoscaling_policy && var.enabled ? 1 : 0
name_prefix = "eks-worker-autoscaling-${aws_eks_cluster.this.name}" name_prefix = "eks-worker-autoscaling-${aws_eks_cluster.this.name}"
description = "EKS worker node autoscaling policy for cluster ${aws_eks_cluster.this.name}" description = "EKS worker node autoscaling policy for cluster ${aws_eks_cluster.this.name}"
policy = data.aws_iam_policy_document.worker_autoscaling.json policy = data.aws_iam_policy_document.worker_autoscaling.json
+4 -4
View File
@@ -1,7 +1,7 @@
# Worker Groups using Launch Templates # Worker Groups using Launch Templates
resource "aws_autoscaling_group" "workers_launch_template" { resource "aws_autoscaling_group" "workers_launch_template" {
count = (local.worker_group_launch_template_count * local.enabled) count = (local.worker_group_launch_template_count * var.enabled)
name_prefix = join( name_prefix = join(
"-", "-",
compact( compact(
@@ -218,7 +218,7 @@ resource "aws_autoscaling_group" "workers_launch_template" {
} }
resource "aws_launch_template" "workers_launch_template" { resource "aws_launch_template" "workers_launch_template" {
count = (local.worker_group_launch_template_count * local.enabled) count = (local.worker_group_launch_template_count * var.enabled)
name_prefix = "${aws_eks_cluster.this.name}-${lookup( name_prefix = "${aws_eks_cluster.this.name}-${lookup(
var.worker_groups_launch_template[count.index], var.worker_groups_launch_template[count.index],
"name", "name",
@@ -382,7 +382,7 @@ resource "aws_launch_template" "workers_launch_template" {
} }
resource "random_pet" "workers_launch_template" { resource "random_pet" "workers_launch_template" {
count = (local.worker_group_launch_template_count * && local.enabled) count = (local.worker_group_launch_template_count * var.enabled)
separator = "-" separator = "-"
length = 2 length = 2
@@ -401,7 +401,7 @@ resource "random_pet" "workers_launch_template" {
} }
resource "aws_iam_instance_profile" "workers_launch_template" { resource "aws_iam_instance_profile" "workers_launch_template" {
count = var.manage_worker_iam_resources ? (local.worker_group_launch_template_count * local.enabled) : 0 count = var.manage_worker_iam_resources ? (local.worker_group_launch_template_count * var.enabled) : 0
name_prefix = aws_eks_cluster.this.name name_prefix = aws_eks_cluster.this.name
role = lookup( role = lookup(
var.worker_groups_launch_template[count.index], var.worker_groups_launch_template[count.index],