terraform-provider-ibm icon indicating copy to clipboard operation
terraform-provider-ibm copied to clipboard

Resource Group Data Source Should Return Null Values When No Group Found

Open daniel-butler-irl opened this issue 2 years ago • 1 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

The resource group data source should return null values if the group does not exist. This would allow automation flows to automatically provision a new resource group if needed.

I don't think this will affect existing consumers as the error would just get pushed to the next component that tries to consume the null value.

New or Affected Resource(s)

  • data source ibm_resource_group

Potential Terraform Configuration

# No changes to the configuration 
# Atributes all get set to null if the resource group does not exist

References

daniel-butler-irl avatar Aug 10 '22 07:08 daniel-butler-irl

Hi, @hkantare Thanks for the feedback on the PR. I understand and I have closed and I'll move the discussion back to this issue.

Quote @hkantare:

This approach of setting to empty state when we don't find the result is not according to Hashicorp guidelines . A data source is evaluated at plan time itself . If we return an empty results without error all the dependent resources will be failed only during Terraform apply stage. Terraform plan itself should be able to evaluate and provide the plan

I know many people looking for the ability to use a resource group and create one if it does not exist. We have built this module https://github.com/terraform-ibm-modules/terraform-ibm-resource-group but the need for two separate variables is not ideal. We would like a single input and have the module figure it out, any ideas on how we can achieve this? I could use the rest_api provider or a null resource to look up the resource group with the IBM Cloud APIs but this is a hack for something I feel should be part of the provider.

daniel-butler-irl avatar Aug 16 '22 08:08 daniel-butler-irl