Skip to content

Commit 3017813

Browse files
committed
r/aws_elasticsearch_domain_policy: handle domain update propagation delays
This change adds logic to retry ValidationExceptions which indicate a domain change is in-progress. When a domain policy change immediately follows domain creation or modification, delays in propagation of the ACTIVE status can cause intermittent ValidationExceptions. These errors are now retried for a short interval (2 minutes), which should allow configurations pairing domain and domain policy resources to complete successfully on the first apply. ```console % make testacc PKG=elasticsearch TESTS=TestAccElasticsearchDomainPolicy_ ==> Checking that code complies with gofmt requirements... TF_ACC=1 go1.21.8 test ./internal/service/elasticsearch/... -v -count 1 -parallel 20 -run='TestAccElasticsearchDomainPolicy_' -timeout 360m --- PASS: TestAccElasticsearchDomainPolicy_basic (1956.43s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/service/elasticsearch 1962.012s ```
1 parent e705bad commit 3017813

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

internal/service/elasticsearch/domain_policy.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,16 @@ func resourceDomainPolicyUpsert(ctx context.Context, d *schema.ResourceData, met
9191
return sdkdiag.AppendErrorf(diags, "policy (%s) is invalid JSON: %s", policy, err)
9292
}
9393

94-
_, err = conn.UpdateElasticsearchDomainConfigWithContext(ctx, &elasticsearch.UpdateElasticsearchDomainConfigInput{
95-
DomainName: aws.String(domainName),
96-
AccessPolicies: aws.String(policy),
97-
})
94+
_, err = tfresource.RetryWhenAWSErrMessageContains(ctx, propagationTimeout,
95+
func() (interface{}, error) {
96+
return conn.UpdateElasticsearchDomainConfigWithContext(ctx, &elasticsearch.UpdateElasticsearchDomainConfigInput{
97+
DomainName: aws.String(domainName),
98+
AccessPolicies: aws.String(policy),
99+
})
100+
},
101+
elasticsearch.ErrCodeValidationException,
102+
"A change/update is in progress",
103+
)
98104
if err != nil {
99105
return sdkdiag.AppendErrorf(diags, "setting Elasticsearch Domain Policy (%s): %s", d.Id(), err)
100106
}

0 commit comments

Comments
 (0)