Skip to content

Commit

Permalink
Merge pull request #432 from npellegrin/bug/bedrock-agent-datasource-…
Browse files Browse the repository at this point in the history
…stuck
  • Loading branch information
ekristen authored Nov 25, 2024
2 parents 1611bd9 + cca02de commit 49a6740
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions resources/bedrock-agent-datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,32 @@ func (r *BedrockDataSource) Properties() types.Properties {
}

func (r *BedrockDataSource) Remove(_ context.Context) error {
_, err := r.svc.DeleteDataSource(&bedrockagent.DeleteDataSourceInput{
// Must set retention to RETAIN to be able to delete datasource when data is already removed
// Reference: https://github.com/ekristen/aws-nuke/issues/431
current, err := r.svc.GetDataSource(&bedrockagent.GetDataSourceInput{
DataSourceId: r.ID,
KnowledgeBaseId: r.KnowledgeBaseID,
})
if err != nil {
return err
}
_, err = r.svc.UpdateDataSource(&bedrockagent.UpdateDataSourceInput{
DataDeletionPolicy: aws.String(bedrockagent.DataDeletionPolicyRetain),
DataSourceConfiguration: current.DataSource.DataSourceConfiguration,
DataSourceId: r.ID,
Description: current.DataSource.Description,
KnowledgeBaseId: r.KnowledgeBaseID,
Name: current.DataSource.Name,
ServerSideEncryptionConfiguration: current.DataSource.ServerSideEncryptionConfiguration,
VectorIngestionConfiguration: current.DataSource.VectorIngestionConfiguration,
})
if err != nil {
return err
}
_, err = r.svc.DeleteDataSource(&bedrockagent.DeleteDataSourceInput{
DataSourceId: r.ID,
KnowledgeBaseId: r.KnowledgeBaseID,
})

return err
}

Expand Down

0 comments on commit 49a6740

Please sign in to comment.