HewlettPackard / terraform-provider-oneview

Automates the provisioning of physical infrastructure from a private cloud using templates from HPE OneView with Terraform
Apache License 2.0
49 stars 30 forks source link

tf 6.3.1-13 error with ignore_changes #406

Closed rismoney closed 3 years ago

rismoney commented 3 years ago

code

  lifecycle {
    ignore_changes = [
      local_storage[0].controller[0].logical_drives[0].name,
    ]
  }
Error: Cannot index a set value

  on ..\modules\sp_standard\main.tf line 113, in resource "oneview_server_profile" "default":
 113:       local_storage[0].controller[0].logical_drives[0].name,

Block type "controller" is represented by a set of objects, and set elements
do not have addressable keys. To find elements matching specific criteria, use
a "for" expression with an "if" clause.

I was able to work around it for now by excluding just local_storage. This worked on previous versions of the provider.

Why am I doing this? I imported 100+ profiles, their local storage RAID's, and those disks come in as "Logical Disk 1" and settings may be slightly different. In new profile creation I my module they are named "OS". So I have a descrepancy. I can, and may, change the name in the call to the module. So this is a very minor issue for me.

However, this is more of a heads up, that the elements don't behave the way they did previously. Not sure if this is a bug or supposed to be this way now. Just figured I'd mention it.

AsisBagga commented 3 years ago

Hi @rismoney This is supposed to be this way. You shall not be able to access them through indexing like before (as earlier they were of type TypeList) because controllers and logical_drives attributes have been changed to type TypeSet. These changes were done to achieve a better use-case along with idempotency, and, therefore, as the error suggests, you might need to do some changes to your local configurations.

Error Block type "controller" is represented by a set of objects, and set elements do not have addressable keys. To find elements matching specific criteria, use a "for" expression with an "if" clause.

I believe this means that for you to access them would be to iterate and add conditionals for fetching the required one.

AsisBagga commented 3 years ago

hi @rismoney I'll proceed with closing this issue for now as we have not received any response from you yet. Let me know if you have any further questions, we would be glad to assist you. Thank you.