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

Error: element() may not be used with an empty list when create_lc = false #43

Closed
oonisim opened this issue Aug 12, 2018 · 4 comments · Fixed by #45
Closed

Error: element() may not be used with an empty list when create_lc = false #43

oonisim opened this issue Aug 12, 2018 · 4 comments · Fixed by #45

Comments

@oonisim
Copy link

oonisim commented Aug 12, 2018

Error

aws_autoscaling_group.this: element: element() may not be used with an empty list in:
${var.create_lc ? element(aws_launch_configuration.this.*.name, 0) : var.launch_configuration}

Cause

It appears that element() cannot be used for launch_configuration { count = 0 } for create_lc == false.

launch_configuration = "${var.create_lc ? element(aws_launch_configuration.this.*.name, 0) : var.launch_configuration}"

Workaround

35c35
<   launch_configuration = "${var.create_lc ? element(aws_launch_configuration.this.*.name, 0) : var.launch_configuration}"
---
>   launch_configuration = "${var.create_lc ?  element(concat(aws_launch_configuration.this.*.name, list("")), 0) : var.launch_configuration}"
77c77
<     lc_name = "${var.create_lc ? element(aws_launch_configuration.this.*.name, 0) : var.launch_configuration}"
---
>     lc_name = "${var.create_lc ? element(concat(aws_launch_configuration.this.*.name, list("")), 0) : var.launch_configuration}"
@oonisim
Copy link
Author

oonisim commented Aug 12, 2018

Kindly provide an example code for the use case of create_lc == false. For cases where create_lc == true, there are two examples provided.

@antonbabenko
Copy link
Member

Example code added. Thanks @oonisim !

v2.8.0 has been released.

@oonisim
Copy link
Author

oonisim commented Aug 19, 2018

Thanks a lot!

@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 Oct 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants