You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 5, 2020. It is now read-only.
There seems to be an issue with the chef provisioner when generating resources using "for_each" (new in terraform 0.12.6). Whenever the "each" variable is used within the chef provisioner block of the resource to dynamically fill out attributes (eg. "node_name") terraform fails during the apply phase (after the vm instance is created but not yet provisioned) with the following error:
Error: 2 problems:
- Reference to "each" in context without for_each: The "each" object can be used only in "resource" blocks, and only when the "for_each" argument is set.
- Reference to "each" in context without for_each: The "each" object can be used only in "resource" blocks, and only when the "for_each" argument is set.
Terraform Version
Terraform v0.12.6
provider.chef v0.2.0
Affected Resource(s)
azurerm_virtual_machine
Terraform Configuration Files
# Provisioner block from the azurerm_virtual_machine# A list of server variables (name, size, etc.) are provided as a map to the "for_each" attribute# Creating VM resources without the provisioner block works correctlyprovisioner"chef" {
node_name=each.keyserver_url="https://chef.XXX.io/organizations/XXX/"user_key=var.chef_provisioner_private_keyuser_name=var.chef_admin_usernamechannel="stable"version="15.1.36"client_options=["chef_license 'accept'"]
attributes_json=jsonencode({"cache_db_name" = join("_", ["pgcache", each.value.region, each.value.tenant])})
recreate_client=truesecret_key=var.chef_provisioner_databag_keyssl_verify_mode=":verify_none"connection {
host=azurerm_public_ip.pgsqlcache-ip[each.key].fqdnprivate_key=var.ssh_admin_private_keytype="ssh"user=var.ssh_admin_username
}
run_list=["postgresql"]
}
Expected Behavior
1 or more VM's should be created and provisioning applied to all of them using the "each" variable to provide individual VM details.
Actual Behavior
The "apply" is run and VM instances created but no provisioning occurs. The apply run ends with:
Error: 2 problems:
- Reference to "each" in context without for_each: The "each" object can be used only in "resource" blocks, and only when the "for_each" argument is set.
- Reference to "each" in context without for_each: The "each" object can be used only in "resource" blocks, and only when the "for_each" argument is set.
Hi @kszlachcikowski! Thanks for the report! There are known issues with for_each in provisioners (hashicorp/terraform#22289) and this fix will go out in 0.12.7, which hopefully changes your issue's status :)
Hi,
There seems to be an issue with the chef provisioner when generating resources using "for_each" (new in terraform 0.12.6). Whenever the "each" variable is used within the chef provisioner block of the resource to dynamically fill out attributes (eg. "node_name") terraform fails during the apply phase (after the vm instance is created but not yet provisioned) with the following error:
Terraform Version
Terraform v0.12.6
Affected Resource(s)
azurerm_virtual_machine
Terraform Configuration Files
Expected Behavior
1 or more VM's should be created and provisioning applied to all of them using the "each" variable to provide individual VM details.
Actual Behavior
The "apply" is run and VM instances created but no provisioning occurs. The apply run ends with:
Steps to Reproduce
terraform apply
References
hashicorp/terraform#17179
The text was updated successfully, but these errors were encountered: