diff --git a/resources/bedrock-agentalias.go b/resources/bedrock-agentalias.go index 5607e61c4..0ec47cb87 100644 --- a/resources/bedrock-agentalias.go +++ b/resources/bedrock-agentalias.go @@ -1,6 +1,9 @@ package resources import ( + "fmt" + "strings" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/bedrockagent" @@ -82,6 +85,13 @@ func ListBedrockAgentIds(svc *bedrockagent.BedrockAgent) ([]string, error) { return agentIds, nil } +func (f *BedrockAgentAlias) Filter() error { + if strings.HasPrefix(*f.AgentAliasName, "AgentTestAlias") { + return fmt.Errorf("cannot delete AWS managed Agent Alias") + } + return nil +} + func (f *BedrockAgentAlias) Remove() error { _, err := f.svc.DeleteAgentAlias(&bedrockagent.DeleteAgentAliasInput{ AgentAliasId: f.AgentAliasId, diff --git a/resources/bedrock-flowalias.go b/resources/bedrock-flowalias.go index e0914143a..196235008 100644 --- a/resources/bedrock-flowalias.go +++ b/resources/bedrock-flowalias.go @@ -1,6 +1,9 @@ package resources import ( + "fmt" + "strings" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/bedrockagent" @@ -82,6 +85,13 @@ func ListBedrockFlowIds(svc *bedrockagent.BedrockAgent) ([]string, error) { return flowIds, nil } +func (f *BedrockFlowAlias) Filter() error { + if strings.HasPrefix(*f.FlowAliasName, "TSTALIASID") { + return fmt.Errorf("cannot delete AWS managed Flow Alias") + } + return nil +} + func (f *BedrockFlowAlias) Remove() error { _, err := f.svc.DeleteFlowAlias(&bedrockagent.DeleteFlowAliasInput{ AliasIdentifier: f.FlowAliasId,