From 7c3702e2313db0ef14c8d21d7ac0c3cec7de09ff Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Mon, 11 Dec 2023 16:56:01 -0600 Subject: [PATCH 1/3] Add forcenew field markings for instance --- ibm/service/power/resource_ibm_pi_instance.go | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index 610bf44813..f1e3a47649 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -83,20 +83,19 @@ func ResourceIBMPIInstance() *schema.Resource { Description: "Maximum memory size", }, helpers.PIInstanceVolumeIds: { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Set: schema.HashString, - DiffSuppressFunc: flex.ApplyOnce, - Description: "List of PI volumes", + Type: schema.TypeSet, + ForceNew: true, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Set: schema.HashString, + Description: "List of PI volumes", }, - helpers.PIInstanceUserData: { Type: schema.TypeString, + ForceNew: true, Optional: true, Description: "Base64 encoded data to be passed in for invoking a cloud init script", }, - helpers.PIInstanceStorageType: { Type: schema.TypeString, Optional: true, @@ -154,10 +153,10 @@ func ResourceIBMPIInstance() *schema.Resource { Description: "Indicates if all volumes attached to the server must reside in the same storage pool", }, PIInstanceNetwork: { - Type: schema.TypeList, - Required: true, - DiffSuppressFunc: flex.ApplyOnce, - Description: "List of one or more networks to attach to the instance", + Type: schema.TypeList, + ForceNew: true, + Required: true, + Description: "List of one or more networks to attach to the instance", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "ip_address": { @@ -190,13 +189,14 @@ func ResourceIBMPIInstance() *schema.Resource { }, helpers.PIPlacementGroupID: { Type: schema.TypeString, + ForceNew: true, Optional: true, Description: "Placement group ID", }, Arg_PIInstanceSharedProcessorPool: { Type: schema.TypeString, - Optional: true, ForceNew: true, + Optional: true, ConflictsWith: []string{PISAPInstanceProfileID}, Description: "Shared Processor Pool the instance is deployed on", }, @@ -221,10 +221,10 @@ func ResourceIBMPIInstance() *schema.Resource { Description: "PIN Policy of the Instance", }, helpers.PIInstanceImageId: { - Type: schema.TypeString, - Required: true, - Description: "PI instance image id", - DiffSuppressFunc: flex.ApplyOnce, + Type: schema.TypeString, + ForceNew: true, + Required: true, + Description: "PI instance image id", }, helpers.PIInstanceProcessors: { Type: schema.TypeFloat, @@ -247,10 +247,10 @@ func ResourceIBMPIInstance() *schema.Resource { Description: "Instance processor type", }, helpers.PIInstanceSSHKeyName: { - Type: schema.TypeString, - Optional: true, - DiffSuppressFunc: flex.ApplyOnce, - Description: "SSH key name", + Type: schema.TypeString, + ForceNew: true, + Optional: true, + Description: "SSH key name", }, helpers.PIInstanceMemory: { Type: schema.TypeFloat, @@ -261,22 +261,26 @@ func ResourceIBMPIInstance() *schema.Resource { }, PIInstanceDeploymentType: { Type: schema.TypeString, + ForceNew: true, Optional: true, Description: "Custom Deployment Type Information", }, PISAPInstanceProfileID: { Type: schema.TypeString, + ForceNew: true, Optional: true, ConflictsWith: []string{helpers.PIInstanceProcessors, helpers.PIInstanceMemory, helpers.PIInstanceProcType}, Description: "SAP Profile ID for the amount of cores and memory", }, PISAPInstanceDeploymentType: { Type: schema.TypeString, + ForceNew: true, Optional: true, Description: "Custom SAP Deployment Type Information", }, helpers.PIInstanceSystemType: { Type: schema.TypeString, + ForceNew: true, Optional: true, Computed: true, Description: "PI Instance system type", From fe53135b7fcf8545d16b0faa06972c774afa0380 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Wed, 13 Dec 2023 14:46:20 -0600 Subject: [PATCH 2/3] Update forcenew fields --- ibm/service/power/resource_ibm_pi_instance.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index f1e3a47649..ce0383d412 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -267,7 +267,6 @@ func ResourceIBMPIInstance() *schema.Resource { }, PISAPInstanceProfileID: { Type: schema.TypeString, - ForceNew: true, Optional: true, ConflictsWith: []string{helpers.PIInstanceProcessors, helpers.PIInstanceMemory, helpers.PIInstanceProcType}, Description: "SAP Profile ID for the amount of cores and memory", @@ -287,12 +286,14 @@ func ResourceIBMPIInstance() *schema.Resource { }, helpers.PIInstanceReplicants: { Type: schema.TypeInt, + ForceNew: true, Optional: true, Default: 1, Description: "PI Instance replicas count", }, helpers.PIInstanceReplicationPolicy: { Type: schema.TypeString, + ForceNew: true, Optional: true, ValidateFunc: validate.ValidateAllowedStringValues([]string{"affinity", "anti-affinity", "none"}), Default: "none", @@ -300,6 +301,7 @@ func ResourceIBMPIInstance() *schema.Resource { }, helpers.PIInstanceReplicationScheme: { Type: schema.TypeString, + ForceNew: true, Optional: true, ValidateFunc: validate.ValidateAllowedStringValues([]string{"prefix", "suffix"}), Default: "suffix", From a67d8308bf9139544aff8daa5b53867f4ace7f2f Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Wed, 13 Dec 2023 17:15:40 -0600 Subject: [PATCH 3/3] Revert imageid forcenew The image id you pass in does not match the image id of the instance created, so if you apply twice in row terraform thinks it has to remake the instance when that's not true. --- ibm/service/power/resource_ibm_pi_instance.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index ce0383d412..6c39638285 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -221,10 +221,10 @@ func ResourceIBMPIInstance() *schema.Resource { Description: "PIN Policy of the Instance", }, helpers.PIInstanceImageId: { - Type: schema.TypeString, - ForceNew: true, - Required: true, - Description: "PI instance image id", + Type: schema.TypeString, + Required: true, + Description: "PI instance image id", + DiffSuppressFunc: flex.ApplyOnce, }, helpers.PIInstanceProcessors: { Type: schema.TypeFloat,