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

Instance Refresh Example: The "count" value depends on resource attributes that cannot be determined #1393

Closed
jaimehrubiks opened this issue May 25, 2021 · 3 comments

Comments

@jaimehrubiks
Copy link
Contributor

jaimehrubiks commented May 25, 2021

Description

Add instance refresh code to my existing cluster. The "aws_autoscaling_lifecycle_hook" code piece is failing.

Related to
#1373 (comment)

⚠️ Note

Already tried deleting .terraform, init and plan/apply

Versions

  • Terraform: v0.13.6
  • Provider(s):
    ❯ terraform providers --version
    Terraform v0.13.6
+ provider registry.terraform.io/hashicorp/aws v3.37.0
+ provider registry.terraform.io/hashicorp/cloudinit v2.2.0
+ provider registry.terraform.io/hashicorp/helm v2.1.2
+ provider registry.terraform.io/hashicorp/kubernetes v1.11.4
+ provider registry.terraform.io/hashicorp/local v1.4.0
+ provider registry.terraform.io/hashicorp/null v2.1.2
+ provider registry.terraform.io/hashicorp/random v2.3.1
+ provider registry.terraform.io/hashicorp/template v2.2.0
+ provider registry.terraform.io/terraform-aws-modules/http v2.4.1
  • Module: latest (16.2.0)

Reproduction

Steps to reproduce the behavior:

Add

resource "aws_autoscaling_lifecycle_hook" "aws_node_termination_handler" {
  count                  = length(module.eks.workers_asg_names)
  name                   = "aws-node-termination-handler"
  autoscaling_group_name = module.eks.workers_asg_names[count.index]
  lifecycle_transition   = "autoscaling:EC2_INSTANCE_TERMINATING"
  heartbeat_timeout      = 300
  default_result         = "CONTINUE"
}

Actual behavior

Terminal Output Screenshot(s)

Error: Invalid count argument

  on platform.tf line 25, in resource "aws_autoscaling_lifecycle_hook" "aws_node_termination_handler":
  25:   count                  = length(module.eks.workers_asg_names)

The "count" value depends on resource attributes that cannot be determined
until apply, so Terraform cannot predict how many instances will be created.
To work around this, use the -target argument to first apply only the
resources that the count depends on.
@jaimehrubiks
Copy link
Contributor Author

jaimehrubiks commented May 25, 2021

I realized what could be the issue here.

I recently migrated from terraform 0.12 to terraform 0.13, and I think there is an issue with terraform 0.13. I realized that:

terraform plan -refresh=false

doesn't show any error, and I think reason is that they changed the refresh behavior in 0.13

I'm starting to think that terraform 0.12 was much more consistent than 0.13.

Terraform 0.14 seems to have fixed this issue, so I will try 0.14 today/tomorrow and comment back.

@jaimehrubiks
Copy link
Contributor Author

Okey, it seems like terraform 0.13 was the culprit. 0.14 works fine. Hope this issue helps someone else.

@github-actions
Copy link

I'm going to lock this issue 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 similar to this, 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 21, 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

No branches or pull requests

1 participant