vmware / terraform-provider-vra

Terraform Provider for VMware Aria Automation
https://registry.terraform.io/providers/vmware/vra/
Mozilla Public License 2.0
103 stars 90 forks source link

Regression with vra_catalog_item data source lookup in 0.6.0 #475

Closed rydss closed 1 year ago

rydss commented 1 year ago

Code of Conduct

This project has a Code of Conduct that all participants are expected to understand and follow:

vRA Version

vRA 8.9.1

Terraform Version

1.2.7

vRA Terraform Provider Version

0.6.0

Affected Resource(s)

vra_catalog_item

Terraform Configuration Files

data "vra_catalog_item" "this" {
  name = "RHEL8"
}

Expected Behavior

Only one catalog item should be found with the exact same name provided

Actual Behavior

All catalog items containing the name provided are returned with error message "more than one catalog item found with the same name, try to narrow filter by project_id"

It means that if you are using a Cloud Template name as part of any other CT name and you upgrade to 0.6.0, all your deployments are now broken, the impact is very serious.

Steps to Reproduce

References

This change can actually be found at line 123 of this commit : https://github.com/vmware/terraform-provider-vra/commit/f914ec7d584ac3e7a5d6678f341ac0c4ddda6bfa#diff-c76536a33ce33211d791477143c14b3233fd2285cf0b220a3a6fc7ae0f2cea57L123 where the condition to check if the catalog item name matches exactly one of the list returned has been removed and replace by an error message instead : https://github.com/vmware/terraform-provider-vra/commit/f914ec7d584ac3e7a5d6678f341ac0c4ddda6bfa#diff-c76536a33ce33211d791477143c14b3233fd2285cf0b220a3a6fc7ae0f2cea57R133

Community Note

frodenas commented 1 year ago

Thanks @rydss for opening this bug.

I see that the call to get catalog items is using the search parameter, which will filter catalog items that have the search string somewhere in their name or description, hence that in your example is returning multiple items.

I'll provide a fix ASAP.

rydss commented 1 year ago

Thank you @frodenas. FYI it looks like the blueprint lookup has the exact same issue : https://github.com/vmware/terraform-provider-vra/commit/ae071839cd597313eaf9c252d7ebfd0a648166da#diff-0dfffd55b9f51ebe1f0fb31fd5945607778f111d4faadad370a853baf9750071L214

frodenas commented 1 year ago

@rydss The Blueprint's API calls allow specifying a name (catalog item's API does not have support for specifying a name, so it's using the search paramater), so vra_blueprint datasource is not affected.

rydss commented 1 year ago

@frodenas Thank you for the fix. Do you know when is the next release planned?

frodenas commented 1 year ago

I will release a new version with the fix this week.