Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

coalesce cannot be used with an empty tuple #248

Closed
jac4g09 opened this issue Nov 30, 2022 · 3 comments · Fixed by #249
Closed

coalesce cannot be used with an empty tuple #248

jac4g09 opened this issue Nov 30, 2022 · 3 comments · Fixed by #249
Assignees
Labels
bug Something isn't working

Comments

@jac4g09
Copy link

jac4g09 commented Nov 30, 2022

Describe the bug

When vmseries_ami_id is specified in the asg module the plan errors out.

Expected behavior

If vmseries_ami_id is specified data.aws_ami.this[0].id should be ignored.

Current behavior

│ Error: Invalid index
│ 
│   on .terraform/modules/vm_series_asg/modules/asg/main.tf line 28, in resource "aws_launch_template" "this":
│   28:   image_id      = coalesce(var.vmseries_ami_id, data.aws_ami.this[0].id)
│     ├────────────────
│     │ data.aws_ami.this is empty tuple
│ 
│ The given key does not identify an element in this collection value: the
│ collection has no elements.


Possible solution

same solution as
Issue
PR

coalesce(var.vmseries_ami_id, try(data.aws_ami.this[0].id, null) )

@jac4g09 jac4g09 added the bug Something isn't working label Nov 30, 2022
@welcome-to-palo-alto-networks

🎉 Thanks for opening your first issue here! Welcome to the community!

@pimielowski pimielowski self-assigned this Nov 30, 2022
@pimielowski
Copy link
Contributor

@jac4g09 thanks for the info!
You are right, I test it and the problem exists there.

@pimielowski pimielowski mentioned this issue Nov 30, 2022
4 tasks
@pimielowski pimielowski linked a pull request Nov 30, 2022 that will close this issue
4 tasks
@jac4g09
Copy link
Author

jac4g09 commented Nov 30, 2022

Thanks for the quick response 😀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants