Fix errors from usage of coalesce (#402) (#459)

* Replace coalesce() usage for locals with ternary operator. Fixes terraform errors during destroy when only empty strings were passed to coalesce().

* Update changelog.

* Fix formatting.
This commit is contained in:
Petri Kero
2019-08-06 19:05:54 +03:00
committed by Max Williams
parent ebac6c92bf
commit c9986f5e01
2 changed files with 5 additions and 21 deletions

View File

@@ -18,6 +18,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- Fixed errors sometimes happening during destroy due to usage of coalesce() in local.tf (by @petrikero)
- Write your awesome change here (by @you)
# History

View File

@@ -1,28 +1,11 @@
locals {
asg_tags = null_resource.tags_as_list_of_maps.*.triggers
# Followed recommendation http://67bricks.com/blog/?p=85
# to workaround terraform not supporting short circut evaluation
cluster_security_group_id = coalesce(
join("", aws_security_group.cluster.*.id),
var.cluster_security_group_id,
)
cluster_security_group_id = var.cluster_create_security_group ? aws_security_group.cluster[0].id : var.cluster_security_group_id
cluster_iam_role_name = var.manage_cluster_iam_resources ? aws_iam_role.cluster[0].name : var.cluster_iam_role_name
cluster_iam_role_arn = var.manage_cluster_iam_resources ? aws_iam_role.cluster[0].arn : data.aws_iam_role.custom_cluster_iam_role[0].arn
worker_security_group_id = var.worker_create_security_group ? aws_security_group.workers[0].id : var.worker_security_group_id
cluster_iam_role_name = coalesce(
join("", aws_iam_role.cluster.*.name),
var.cluster_iam_role_name,
"aws-eks"
)
cluster_iam_role_arn = coalesce(
join("", aws_iam_role.cluster.*.arn),
join("", data.aws_iam_role.custom_cluster_iam_role.*.arn),
"aws-eks"
)
worker_security_group_id = coalesce(
join("", aws_security_group.workers.*.id),
var.worker_security_group_id,
)
default_iam_role_id = concat(aws_iam_role.workers.*.id, [""])[0]
kubeconfig_name = var.kubeconfig_name == "" ? "eks_${var.cluster_name}" : var.kubeconfig_name