mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-03-18 07:23:45 +01:00
Upgrade to terraform 0.12 (#394)
* run terraform upgrade tool * fix post upgrade TODOs * use strict typing for variables * upgrade examples, point them at VPC module tf 0.12 PR * remove unnecessary `coalesce()` calls coalesce(lookup(map, key, ""), default) -> lookup(map, key, default) * Fix autoscaling_enabled broken (#1) * always set a value for tags, fix coalescelist calls * always set a value for these tags * fix tag value * fix tag value * default element available * added default value * added a general default without this default - TF is throwing an error when running a destroy * Fix CI * Change vpc module back to `terraform-aws-modules/vpc/aws` in example * Update CHANGELOG.md * Change type of variable `cluster_log_retention_in_days` to number * Remove `xx_count` variables * Actual lists instead of strings with commas * Remove `xx_count` variable from docs * Replace element with list indexing * Change variable `worker_group_tags` to a attribute of worker_group * Fix workers_launch_template_mixed tags * Change override_instance_type_x variables to list. * Update CHANGELOG.md
This commit is contained in:
74
cluster.tf
74
cluster.tf
@@ -1,48 +1,53 @@
|
||||
resource "aws_cloudwatch_log_group" "this" {
|
||||
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
|
||||
|
||||
count = "${length(var.cluster_enabled_log_types) > 0 ? 1 : 0}"
|
||||
count = length(var.cluster_enabled_log_types) > 0 ? 1 : 0
|
||||
}
|
||||
|
||||
resource "aws_eks_cluster" "this" {
|
||||
name = "${var.cluster_name}"
|
||||
enabled_cluster_log_types = "${var.cluster_enabled_log_types}"
|
||||
role_arn = "${local.cluster_iam_role_arn}"
|
||||
version = "${var.cluster_version}"
|
||||
name = var.cluster_name
|
||||
enabled_cluster_log_types = var.cluster_enabled_log_types
|
||||
role_arn = local.cluster_iam_role_arn
|
||||
version = var.cluster_version
|
||||
|
||||
vpc_config {
|
||||
security_group_ids = ["${local.cluster_security_group_id}"]
|
||||
subnet_ids = ["${var.subnets}"]
|
||||
endpoint_private_access = "${var.cluster_endpoint_private_access}"
|
||||
endpoint_public_access = "${var.cluster_endpoint_public_access}"
|
||||
security_group_ids = [local.cluster_security_group_id]
|
||||
subnet_ids = var.subnets
|
||||
endpoint_private_access = var.cluster_endpoint_private_access
|
||||
endpoint_public_access = var.cluster_endpoint_public_access
|
||||
}
|
||||
|
||||
timeouts {
|
||||
create = "${var.cluster_create_timeout}"
|
||||
delete = "${var.cluster_delete_timeout}"
|
||||
create = var.cluster_create_timeout
|
||||
delete = var.cluster_delete_timeout
|
||||
}
|
||||
|
||||
depends_on = [
|
||||
"aws_iam_role_policy_attachment.cluster_AmazonEKSClusterPolicy",
|
||||
"aws_iam_role_policy_attachment.cluster_AmazonEKSServicePolicy",
|
||||
"aws_cloudwatch_log_group.this",
|
||||
aws_iam_role_policy_attachment.cluster_AmazonEKSClusterPolicy,
|
||||
aws_iam_role_policy_attachment.cluster_AmazonEKSServicePolicy,
|
||||
aws_cloudwatch_log_group.this
|
||||
]
|
||||
}
|
||||
|
||||
resource "aws_security_group" "cluster" {
|
||||
count = "${var.cluster_create_security_group ? 1 : 0}"
|
||||
name_prefix = "${var.cluster_name}"
|
||||
count = var.cluster_create_security_group ? 1 : 0
|
||||
name_prefix = var.cluster_name
|
||||
description = "EKS cluster security group."
|
||||
vpc_id = "${var.vpc_id}"
|
||||
tags = "${merge(var.tags, map("Name", "${var.cluster_name}-eks_cluster_sg"))}"
|
||||
vpc_id = var.vpc_id
|
||||
tags = merge(
|
||||
var.tags,
|
||||
{
|
||||
"Name" = "${var.cluster_name}-eks_cluster_sg"
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
resource "aws_security_group_rule" "cluster_egress_internet" {
|
||||
count = "${var.cluster_create_security_group ? 1 : 0}"
|
||||
count = var.cluster_create_security_group ? 1 : 0
|
||||
description = "Allow cluster egress access to the Internet."
|
||||
protocol = "-1"
|
||||
security_group_id = "${aws_security_group.cluster.id}"
|
||||
security_group_id = aws_security_group.cluster[0].id
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
@@ -50,34 +55,35 @@ resource "aws_security_group_rule" "cluster_egress_internet" {
|
||||
}
|
||||
|
||||
resource "aws_security_group_rule" "cluster_https_worker_ingress" {
|
||||
count = "${var.cluster_create_security_group ? 1 : 0}"
|
||||
count = var.cluster_create_security_group ? 1 : 0
|
||||
description = "Allow pods to communicate with the EKS cluster API."
|
||||
protocol = "tcp"
|
||||
security_group_id = "${aws_security_group.cluster.id}"
|
||||
source_security_group_id = "${local.worker_security_group_id}"
|
||||
security_group_id = aws_security_group.cluster[0].id
|
||||
source_security_group_id = local.worker_security_group_id
|
||||
from_port = 443
|
||||
to_port = 443
|
||||
type = "ingress"
|
||||
}
|
||||
|
||||
resource "aws_iam_role" "cluster" {
|
||||
count = "${var.manage_cluster_iam_resources ? 1 : 0}"
|
||||
name_prefix = "${var.cluster_name}"
|
||||
assume_role_policy = "${data.aws_iam_policy_document.cluster_assume_role_policy.json}"
|
||||
permissions_boundary = "${var.permissions_boundary}"
|
||||
path = "${var.iam_path}"
|
||||
count = var.manage_cluster_iam_resources ? 1 : 0
|
||||
name_prefix = var.cluster_name
|
||||
assume_role_policy = data.aws_iam_policy_document.cluster_assume_role_policy.json
|
||||
permissions_boundary = var.permissions_boundary
|
||||
path = var.iam_path
|
||||
force_detach_policies = true
|
||||
tags = "${var.tags}"
|
||||
tags = var.tags
|
||||
}
|
||||
|
||||
resource "aws_iam_role_policy_attachment" "cluster_AmazonEKSClusterPolicy" {
|
||||
count = "${var.manage_cluster_iam_resources ? 1 : 0}"
|
||||
count = var.manage_cluster_iam_resources ? 1 : 0
|
||||
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
|
||||
role = "${aws_iam_role.cluster.name}"
|
||||
role = aws_iam_role.cluster[0].name
|
||||
}
|
||||
|
||||
resource "aws_iam_role_policy_attachment" "cluster_AmazonEKSServicePolicy" {
|
||||
count = "${var.manage_cluster_iam_resources ? 1 : 0}"
|
||||
count = var.manage_cluster_iam_resources ? 1 : 0
|
||||
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSServicePolicy"
|
||||
role = "${aws_iam_role.cluster.name}"
|
||||
role = aws_iam_role.cluster[0].name
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user