Skip to content

Commit

Permalink
Merge pull request #33918 from hashicorp/b-aws_opensearchserverless_c…
Browse files Browse the repository at this point in the history
…ollection_crash

r/aws_opensearchserverless_collection: return error on read
  • Loading branch information
johnsonaj authored Oct 12, 2023
2 parents 55b8975 + d8e8073 commit 2bd489f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/33918.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_opensearchserverless_collection: Fix crash when error is returned
```
8 changes: 8 additions & 0 deletions internal/service/opensearchserverless/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ func (r *resourceCollection) Read(ctx context.Context, req resource.ReadRequest,
return
}

if err != nil {
resp.Diagnostics.AddError(
create.ProblemStandardMessage(names.OpenSearchServerless, create.ErrActionReading, ResNameCollection, state.ID.ValueString(), nil),
err.Error(),
)
return
}

state.ARN = flex.StringToFramework(ctx, out.Arn)
state.CollectionEndpoint = flex.StringToFramework(ctx, out.CollectionEndpoint)
state.DashboardEndpoint = flex.StringToFramework(ctx, out.DashboardEndpoint)
Expand Down

0 comments on commit 2bd489f

Please sign in to comment.