@@ -8,6 +8,7 @@ package provisioner
88import (
99 "context"
1010 "log"
11+ "time"
1112
1213 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1314 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -24,6 +25,11 @@ type (
2425 contextMethodKey struct {}
2526)
2627
28+ // Adding a wait time of 10sec after the create/update operation as the operation takes some time to complete and
29+ // there is no status field to rely on to check the completion of create/update operation.
30+ // NOTE: If the error still persists then the timeout have to tuned in accordingly.
31+ const waitTime = 10 * time .Second
32+
2733func ResourceProvisioner () * schema.Resource {
2834 return & schema.Resource {
2935 Schema : provisionerSchema ,
@@ -80,6 +86,9 @@ func resourceProvisionerCreate(ctx context.Context, d *schema.ResourceData, m in
8086
8187 d .SetId (provisionerResponse .Provisioner .Meta .UID )
8288
89+ log .Printf ("Wait for %d seconds after the create the operation before fetching the state" , waitTime )
90+ time .Sleep (waitTime )
91+
8392 return append (diags , resourceProvisionerRead (context .WithValue (ctx , contextMethodKey {}, helper .CreateState ), d , m )... )
8493}
8594
@@ -118,6 +127,9 @@ func resourceProvisionerInPlaceUpdate(ctx context.Context, d *schema.ResourceDat
118127 return diag .FromErr (errors .Wrapf (err , "Unable to update Tanzu Mission Control provisioner entry, name : %s" , model .FullName .Name ))
119128 }
120129
130+ log .Printf ("Wait for %d seconds after the update the operation before fetching the state" , waitTime )
131+ time .Sleep (waitTime )
132+
121133 return resourceProvisionerRead (ctx , d , m )
122134}
123135
0 commit comments