Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #568 Terraform destroy fails when state is empty #1020

Closed
wants to merge 2 commits into from
Closed

fix: #568 Terraform destroy fails when state is empty #1020

wants to merge 2 commits into from

Conversation

ageekymonk
Copy link

@ageekymonk ageekymonk commented Sep 22, 2020

Terraform destroy fails when state is empty

Description

The terraform destroy fails on any incomplete run because there is reference of name everywhere. Replacing the name with user provided one. Fixes #568

Checklist

@ageekymonk
Copy link
Author

I am not sure why Lint/Docs is failing. Please let me know what should i do to fix it.

@barryib
Copy link
Member

barryib commented Oct 4, 2020

I am not sure why Lint/Docs is failing. Please let me know what should i do to fix it.

You need to rebase your branch from master

Copy link
Member

@barryib barryib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ageekymonk for your PR. Please can you use splat syntax instead of ternary operation.

@@ -144,10 +144,10 @@ locals {

kubeconfig = var.create_eks ? templatefile("${path.module}/templates/kubeconfig.tpl", {
kubeconfig_name = local.kubeconfig_name
endpoint = aws_eks_cluster.this[0].endpoint
cluster_auth_base64 = aws_eks_cluster.this[0].certificate_authority[0].data
endpoint = length(aws_eks_cluster.this) > 0 ? aws_eks_cluster.this[0].endpoint : ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the splat syntax instead.

coalescelist(aws_eks_cluster.this[*]. endpoint, [""])[0] This will return "" if the state is empty.

aws_authenticator_command = var.kubeconfig_aws_authenticator_command
aws_authenticator_command_args = length(var.kubeconfig_aws_authenticator_command_args) > 0 ? var.kubeconfig_aws_authenticator_command_args : ["token", "-i", aws_eks_cluster.this[0].name]
aws_authenticator_command_args = length(var.kubeconfig_aws_authenticator_command_args) > 0 ? var.kubeconfig_aws_authenticator_command_args : ["token", "-i", var.cluster_name]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coalescelist(aws_eks_cluster.this[*].name, [""])[0] This is true for all your change.

@@ -6,7 +6,7 @@ resource "aws_autoscaling_group" "workers" {
"-",
compact(
[
aws_eks_cluster.this[0].name,
var.cluster_name,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the splat syntax instead : coalescelist(aws_eks_cluster.this[*].name, [""])[0] This is true for all your change.

@barryib
Copy link
Member

barryib commented Oct 6, 2020

Thanks @ageekymonk for your work. I'm closing this in favor of #1041

@barryib barryib closed this Oct 6, 2020
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terraform destroy fails when state is empty
2 participants