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

Setting instance_count = 0 leads to error with Terrafrom 0.12 #104

Closed
dermyrddin opened this issue Jun 14, 2019 · 4 comments · Fixed by #110
Closed

Setting instance_count = 0 leads to error with Terrafrom 0.12 #104

dermyrddin opened this issue Jun 14, 2019 · 4 comments · Fixed by #110

Comments

@dermyrddin
Copy link

In my setup I have modules with instance_count = 0 for some environments.
Upgrading to Terraform 0.12 breaks this setup:

Error: Error in function call

  on .terraform/modules/file_rating_mongo_4/terraform-aws-modules-terraform-aws-ec2-instance-6557b76/outputs.tf line 10, in locals:
  10:   this_placement_group              = compact(concat(coalescelist(aws_instance.this.*.placement_group, aws_instance.this_t2.*.placement_group), [""]))
    |----------------
    | aws_instance.this is empty tuple
    | aws_instance.this_t2 is empty tuple

Call to function "coalescelist" failed: no non-null arguments.

This happens because behaviour of coalescelist function used in outputs.tf has been changed in Terraform 0.12: hashicorp/terraform#21370

@dermyrddin dermyrddin changed the title Setting instance_count = 0 module leads to error with Terrafrom 0.12 Setting instance_count = 0 leads to error with Terrafrom 0.12 Jun 14, 2019
@hieuhtr
Copy link

hieuhtr commented Jun 21, 2019

Hmm, this issue is unpredictable, as far as I know.
I'm facing the same issue when setting instance_count = "1" or instance_count = 1

I don't have any workaround here, but after some terraform plan, this issue is bypassed
You may try to not define instance_count in your module section.

@butson
Copy link

butson commented Jul 3, 2019

I don't understand why the setting of thisi_placement_group is different than the other variables.

Shouldn't

this_placement_group = compact(concat(coalescelist(aws_instance.this..placement_group, aws_instance.this_t2..placement_group), [""]))

be

this_placement_group = compact(coalescelist(aws_instance.this..placement_group, aws_instance.this_t2..placement_group, [""]))

or something similiar, that is add an a list of one empty string if others are null

@antonbabenko
Copy link
Member

Thanks for opening this issue. This has been just fixed and v2.5.0 has been released.

schollii added a commit to schollii/terraform-aws-tfstate-backend that referenced this issue Jun 25, 2020
See eg 
- hashicorp/terraform#21370
- terraform-aws-modules/terraform-aws-ec2-instance#104

I have not tested whether this breaks terraform 0.11 destroy, but based on what I read it should not.
Sebor pushed a commit to Sebor/terraform-aws-ec2-instance that referenced this issue Aug 6, 2020
@github-actions
Copy link

github-actions bot commented Nov 9, 2022

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 9, 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 a pull request may close this issue.

4 participants