Skip to content

Commit

Permalink
added filters for aws managed aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
corybekk committed Sep 16, 2024
1 parent 1a5034e commit 5ea0b67
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions resources/bedrock-agentalias.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions resources/bedrock-flowalias.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5ea0b67

Please sign in to comment.