Skip to content

Standardize Arg_CloudInstanceID argument across all data source and resource #6249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ibm/service/power/data_source_ibm_pi_datacenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ func DataSourceIBMPIDatacenter() *schema.Resource {
Schema: map[string]*schema.Schema{
// Arguments
Arg_CloudInstanceID: {
Description: "The GUID of the service instance associated with an account.",
Optional: true,
Type: schema.TypeString,
Description: "The GUID of the service instance associated with an account.",
Optional: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no zero value validation, then I think Required should have been set to true?

Copy link
Collaborator Author

@ismirlia ismirlia Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yussufsh This endpoint is a bit weird so I went through and double checked all the cases.

The SDK calls a slightly different endpoint depending on whether the zone targeted is off-prem or on-prem.

If the zone is off-prem (no satloc in the zone), the cloud_instance_id is not required, and doesn't do anything is set. Not required means it should be off and not set to "".

For off-prem this is valid and return the same thing:

data "ibm_pi_datacenter" "test" {
   pi_datacenter_zone = "dal12"
   pi_cloud_instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

data "ibm_pi_datacenter" "test" {
   pi_datacenter_zone = "dal12"
}

If the zone is on-prem, the cloud_instance_id is required and cannot be set to "".

So this is the only valid configuration for that case:

data "ibm_pi_datacenter" "test" {
   pi_datacenter_zone = "satloc_xxx_xxxxxxxxxxxxxxxxxxxx"
   pi_cloud_instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

And this is never a valid configuration:

data "ibm_pi_datacenter" "test" {
   pi_datacenter_zone = "dal12"
   pi_cloud_instance_id = ""
}

data "ibm_pi_datacenter" "test" {
    pi_datacenter_zone = "satloc_xxx_xxxxxxxxxxxxxxxxxxxx"
    pi_cloud_instance_id = ""
}

So that's what the code is trying to accomplish. Please let me know if you think there's a better way to go about it.

},
Arg_DatacenterZone: {
Description: "Datacenter zone you want to retrieve.",
Expand Down
8 changes: 5 additions & 3 deletions ibm/service/power/data_source_ibm_pi_datacenters.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

func DataSourceIBMPIDatacenters() *schema.Resource {
Expand All @@ -19,9 +20,10 @@ func DataSourceIBMPIDatacenters() *schema.Resource {
Schema: map[string]*schema.Schema{
// Arguments
Arg_CloudInstanceID: {
Description: "The GUID of the service instance associated with an account.",
Optional: true,
Type: schema.TypeString,
Description: "The GUID of the service instance associated with an account.",
Optional: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
},

// Attributes
Expand Down
2 changes: 0 additions & 2 deletions ibm/service/power/data_source_ibm_pi_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ func DataSourceIBMPIHost() *schema.Resource {
// Arguments
Arg_CloudInstanceID: {
Description: "The GUID of the service instance associated with an account.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
},
Arg_HostID: {
Description: "Host ID.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
Expand Down
1 change: 0 additions & 1 deletion ibm/service/power/data_source_ibm_pi_hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func DataSourceIBMPIHosts() *schema.Resource {
// Arguments
Arg_CloudInstanceID: {
Description: "The GUID of the service instance associated with an account.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
Expand Down
3 changes: 0 additions & 3 deletions ibm/service/power/data_source_ibm_pi_network_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,18 @@ func DataSourceIBMPINetworkInterface() *schema.Resource {
// Arguments
Arg_CloudInstanceID: {
Description: "The GUID of the service instance associated with an account.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
},
Arg_NetworkID: {
Description: "Network ID.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
},
Arg_NetworkInterfaceID: {
Description: "Network interface ID.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
Expand Down
2 changes: 0 additions & 2 deletions ibm/service/power/data_source_ibm_pi_network_interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ func DataSourceIBMPINetworkInterfaces() *schema.Resource {
// Arguments
Arg_CloudInstanceID: {
Description: "The GUID of the service instance associated with an account.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
},
Arg_NetworkID: {
Description: "Network ID.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func ResourceIBMPIInstanceConsoleLanguage() *schema.Resource {
// Arguments
Arg_CloudInstanceID: {
Description: "The GUID of the service instance associated with an account.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
Expand Down
1 change: 1 addition & 0 deletions ibm/service/power/resource_ibm_pi_instance_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func ResourceIBMPIInstanceSnapshot() *schema.Resource {
// Arguments
Arg_CloudInstanceID: {
Description: "The GUID of the service instance associated with an account.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
Expand Down
1 change: 1 addition & 0 deletions ibm/service/power/resource_ibm_pi_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func ResourceIBMPIKey() *schema.Resource {
// Arguments
Arg_CloudInstanceID: {
Description: "The GUID of the service instance associated with an account.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
Expand Down
1 change: 1 addition & 0 deletions ibm/service/power/resource_ibm_pi_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func ResourceIBMPINetwork() *schema.Resource {
},
Arg_CloudInstanceID: {
Description: "The GUID of the service instance associated with an account.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
Expand Down
1 change: 1 addition & 0 deletions ibm/service/power/resource_ibm_pi_placement_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func ResourceIBMPIPlacementGroup() *schema.Resource {
// Arguments
Arg_CloudInstanceID: {
Description: "The GUID of the service instance associated with an account.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
Expand Down
1 change: 1 addition & 0 deletions ibm/service/power/resource_ibm_pi_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func ResourceIBMPISnapshot() *schema.Resource {
// Arguments
Arg_CloudInstanceID: {
Description: "The GUID of the service instance associated with an account.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
Expand Down
1 change: 1 addition & 0 deletions ibm/service/power/resource_ibm_pi_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func ResourceIBMPIVolume() *schema.Resource {
},
Arg_CloudInstanceID: {
Description: "The GUID of the service instance associated with an account.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
Expand Down
1 change: 1 addition & 0 deletions ibm/service/power/resource_ibm_pi_volume_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func ResourceIBMPIVolumeGroup() *schema.Resource {
// Arguments
Arg_CloudInstanceID: {
Description: "The GUID of the service instance associated with an account.",
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
Expand Down
Loading