Skip to content

Commit

Permalink
fix: Fix policy_version inconsistent result after apply error for
Browse files Browse the repository at this point in the history
aws_opensearchserverless_lifecycle_policy
  • Loading branch information
acwwat committed Sep 28, 2024
1 parent 511e425 commit b3d5cb8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/39528.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
```release-note:bug
resource/aws_opensearchserverless_lifecycle_policy: Fix "Provider produced inconsistent result after apply" error on update due to `policy_version` computed attribute changing
```
```release-note:bug
resource/aws_opensearchserverless_security_policy: Fix "Provider produced inconsistent result after apply" error on update due to `policy_version` computed attribute changing
```
4 changes: 1 addition & 3 deletions internal/service/opensearchserverless/lifecycle_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ func (r *resourceLifecyclePolicy) Schema(ctx context.Context, _ resource.SchemaR
},
"policy_version": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
names.AttrType: schema.StringAttribute{
CustomType: fwtypes.StringEnumType[awstypes.LifecyclePolicyType](),
Expand Down Expand Up @@ -187,6 +184,7 @@ func (r *resourceLifecyclePolicy) Update(ctx context.Context, req resource.Updat
}

in.ClientToken = aws.String(id.UniqueId())
in.PolicyVersion = state.PolicyVersion.ValueStringPointer() // use policy version from state since it can be recalculated on update

out, err := conn.UpdateLifecyclePolicy(ctx, in)
if err != nil {
Expand Down

0 comments on commit b3d5cb8

Please sign in to comment.