Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix policy_version inconsistent result after apply error for aws_opensearchserverless_lifecycle_policy and aws_opensearchserverless_security_policy #39528

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changelog/39528.txt
Original file line number Diff line number Diff line change
@@ -0,0 +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
4 changes: 1 addition & 3 deletions internal/service/opensearchserverless/security_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ func (r *resourceSecurityPolicy) Schema(ctx context.Context, req resource.Schema
},
"policy_version": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
names.AttrType: schema.StringAttribute{
CustomType: fwtypes.StringEnumType[awstypes.SecurityPolicyType](),
Expand Down Expand Up @@ -195,6 +192,7 @@ func (r *resourceSecurityPolicy) Update(ctx context.Context, req resource.Update
}

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

out, err := conn.UpdateSecurityPolicy(ctx, input)

Expand Down
Loading