I would suggest changing input variable powervs_resource_group_name to powervs_resource_group_id and removing the data lookups from your code.
Why? Because data lookups are executed at the plan phase. And if you are executing this module as part of a higher module which also creates a resource group, the data lookup occurs on a resource group that does not yet exist because the the resource group name is not computed - it is known before the resource is even provisioned.
Here is an example. The below code creates a new resource group, and calls the power infrastructure module as part of the same terraform execution....
Current workaround is to add a depends_on = [ibm_resource_group.resourceGroup] when calling the power infrastrcuture module, but adding explicit depends_on is not a good practise and can lead to issues later on (see more here)
I would suggest changing input variable
powervs_resource_group_name
topowervs_resource_group_id
and removing the data lookups from your code. Why? Because data lookups are executed at the plan phase. And if you are executing this module as part of a higher module which also creates a resource group, the data lookup occurs on a resource group that does not yet exist because the the resource group name is not computed - it is known before the resource is even provisioned. Here is an example. The below code creates a new resource group, and calls the power infrastructure module as part of the same terraform execution....The problem with this code is that terraform plan fails with the error:
Current workaround is to add a
depends_on = [ibm_resource_group.resourceGroup]
when calling the power infrastrcuture module, but adding explicitdepends_on
is not a good practise and can lead to issues later on (see more here)