diff --git a/splunk/resource_splunk_configs_conf.go b/splunk/resource_splunk_configs_conf.go index b24194e2..e37e4877 100644 --- a/splunk/resource_splunk_configs_conf.go +++ b/splunk/resource_splunk_configs_conf.go @@ -5,10 +5,12 @@ import ( "errors" "fmt" "io" + "log" "net/http" "regexp" "strconv" + "github.com/avast/retry-go/v4" "github.com/splunk/terraform-provider-splunk/client/models" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -65,7 +67,18 @@ func configsConfCreate(d *schema.ResourceData, meta interface{}) error { } if _, ok := d.GetOk("acl"); ok { conf, stanza := (*provider.Client).SplitConfStanza(name) - err := (*provider.Client).UpdateAcl(aclObject.Owner, aclObject.App, stanza, aclObject, "configs", "conf-"+conf) + // add retry as sometimes config object is not yet propagated and acl endpoint return 404 + err = retry.Do( + func() error { + err := (*provider.Client).UpdateAcl(aclObject.Owner, aclObject.App, stanza, aclObject, "configs", "conf-"+conf) + if err != nil { + return err + } + return nil + }, retry.Attempts(10), retry.OnRetry(func(n uint, err error) { + log.Printf("#%d: %s. Retrying...\n", n, err) + }), retry.DelayType(retry.BackOffDelay), + ) if err != nil { return err }