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

Invalid count argument #52

Open
romanharen1 opened this issue Nov 17, 2024 · 4 comments
Open

Invalid count argument #52

romanharen1 opened this issue Nov 17, 2024 · 4 comments
Labels

Comments

@romanharen1
Copy link

romanharen1 commented Nov 17, 2024

Ao tentar executar o tofu plan/apply os erros abaixo foram apresentados.

Error: Invalid count argument
on loadbalancer/loadbalancer.tf line 43, in resource "oci_network_load_balancer_backend" "nlb_backend_http":
43:   count                    = length(data.oci_containerengine_node_pool.oke_node_pool.nodes)
The "count" value depends on resource attributes that cannot be determined until apply, so OpenTofu cannot predict how many instances will be created.

Error: Invalid count argument
on loadbalancer/loadbalancer.tf line 52, in resource "oci_network_load_balancer_backend" "nlb_backend_https":
52:   count                    = length(data.oci_containerengine_node_pool.oke_node_pool.nodes)
The "count" value depends on resource attributes that cannot be determined until apply, so OpenTofu cannot predict how many instances will be created.
@Rapha-Borges
Copy link
Owner

Você pode testar o código na branch fix/loadbalancer-backend para ver se o erro persiste?

  • A abordagem anterior utilizava count, que causava erros devido à dependência de atributos de recursos que não podiam ser determinados até a aplicação. A solução foi substituir count por for_each, permitindo que o Terraform gerencie de forma mais eficaz a natureza dinâmica do pool de nós.

@romanharen1
Copy link
Author

Acabei de testar, infelizmente não funcionou, dê uma olhada abaixo no retorno.

Error: Invalid for_each argument
on loadbalancer/loadbalancer.tf line 39, in resource "oci_network_load_balancer_backend" "nlb_backend_http":
39:   for_each                 = { for idx, node in data.oci_containerengine_node_pool.oke_node_pool.nodes : idx => node }
data.oci_containerengine_node_pool.oke_node_pool.nodes is a list of object, known only after apply

The "for_each" map includes keys derived from resource attributes that cannot be determined until apply, and so OpenTofu cannot determine the full set of keys that will identify the instances of this resource.

Error: Invalid for_each argument
on loadbalancer/loadbalancer.tf line 48, in resource "oci_network_load_balancer_backend" "nlb_backend_https":
48:   for_each                 = { for idx, node in data.oci_containerengine_node_pool.oke_node_pool.nodes : idx => node }
data.oci_containerengine_node_pool.oke_node_pool.nodes is a list of object, known only after apply

The "for_each" map includes keys derived from resource attributes that cannot be determined until apply, and so OpenTofu cannot determine the full set of keys that will identify the instances of this resource.

@Rapha-Borges
Copy link
Owner

Obrigado por validar. Vou precisar de mais tempo para analisar e refatorar o código. Enquanto isso, você pode utilizar a branch revert-51-fix/network-load-balancer-backends, que contém o código antigo.

Copy link

This issue has been automatically marked as stale because it has not had activity in the 30 days. It will be closed in 14 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!

@github-actions github-actions bot added the stale label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants