mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-03-26 03:11:06 +01:00
fix: Use splat syntax to avoid errors during destroy with an empty state (#1041)
This commit is contained in:
committed by
GitHub
parent
c75fbb0164
commit
d97edde9cd
15
workers.tf
15
workers.tf
@@ -6,7 +6,7 @@ resource "aws_autoscaling_group" "workers" {
|
||||
"-",
|
||||
compact(
|
||||
[
|
||||
aws_eks_cluster.this[0].name,
|
||||
coalescelist(aws_eks_cluster.this[*].name, [""])[0],
|
||||
lookup(var.worker_groups[count.index], "name", count.index),
|
||||
lookup(var.worker_groups[count.index], "asg_recreate_on_change", local.workers_group_defaults["asg_recreate_on_change"]) ? random_pet.workers[count.index].id : ""
|
||||
]
|
||||
@@ -112,16 +112,16 @@ resource "aws_autoscaling_group" "workers" {
|
||||
[
|
||||
{
|
||||
"key" = "Name"
|
||||
"value" = "${aws_eks_cluster.this[0].name}-${lookup(var.worker_groups[count.index], "name", count.index)}-eks_asg"
|
||||
"value" = "${coalescelist(aws_eks_cluster.this[*].name, [""])[0]}-${lookup(var.worker_groups[count.index], "name", count.index)}-eks_asg"
|
||||
"propagate_at_launch" = true
|
||||
},
|
||||
{
|
||||
"key" = "kubernetes.io/cluster/${aws_eks_cluster.this[0].name}"
|
||||
"key" = "kubernetes.io/cluster/${coalescelist(aws_eks_cluster.this[*].name, [""])[0]}"
|
||||
"value" = "owned"
|
||||
"propagate_at_launch" = true
|
||||
},
|
||||
{
|
||||
"key" = "k8s.io/cluster/${aws_eks_cluster.this[0].name}"
|
||||
"key" = "k8s.io/cluster/${coalescelist(aws_eks_cluster.this[*].name, [""])[0]}"
|
||||
"value" = "owned"
|
||||
"propagate_at_launch" = true
|
||||
},
|
||||
@@ -148,7 +148,7 @@ resource "aws_autoscaling_group" "workers" {
|
||||
|
||||
resource "aws_launch_configuration" "workers" {
|
||||
count = var.create_eks ? local.worker_group_count : 0
|
||||
name_prefix = "${aws_eks_cluster.this[0].name}-${lookup(var.worker_groups[count.index], "name", count.index)}"
|
||||
name_prefix = "${coalescelist(aws_eks_cluster.this[*].name, [""])[0]}-${lookup(var.worker_groups[count.index], "name", count.index)}"
|
||||
associate_public_ip_address = lookup(
|
||||
var.worker_groups[count.index],
|
||||
"public_ip",
|
||||
@@ -262,7 +262,6 @@ resource "aws_launch_configuration" "workers" {
|
||||
)
|
||||
delete_on_termination = lookup(ebs_block_device.value, "delete_on_termination", true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
@@ -394,7 +393,7 @@ resource "aws_security_group_rule" "cluster_primary_ingress_workers" {
|
||||
|
||||
resource "aws_iam_role" "workers" {
|
||||
count = var.manage_worker_iam_resources && var.create_eks ? 1 : 0
|
||||
name_prefix = var.workers_role_name != "" ? null : aws_eks_cluster.this[0].name
|
||||
name_prefix = var.workers_role_name != "" ? null : coalescelist(aws_eks_cluster.this[*].name, [""])[0]
|
||||
name = var.workers_role_name != "" ? var.workers_role_name : null
|
||||
assume_role_policy = data.aws_iam_policy_document.workers_assume_role_policy.json
|
||||
permissions_boundary = var.permissions_boundary
|
||||
@@ -405,7 +404,7 @@ resource "aws_iam_role" "workers" {
|
||||
|
||||
resource "aws_iam_instance_profile" "workers" {
|
||||
count = var.manage_worker_iam_resources && var.create_eks ? local.worker_group_count : 0
|
||||
name_prefix = aws_eks_cluster.this[0].name
|
||||
name_prefix = coalescelist(aws_eks_cluster.this[*].name, [""])[0]
|
||||
role = lookup(
|
||||
var.worker_groups[count.index],
|
||||
"iam_role_id",
|
||||
|
||||
Reference in New Issue
Block a user