-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Option for user to automatically add Amazon Bedrock integrations (#1813)
Option for user to automatically add Amazon Bedrock integrations when read only instance role (IAM) is set #1759
- Loading branch information
1 parent
e99b516
commit bf69a5a
Showing
13 changed files
with
216 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
deepfence_server/pkg/generative-ai-integration/bedrock/aimodels.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package bedrock | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/bedrock" | ||
"github.com/deepfence/ThreatMapper/deepfence_server/model" | ||
) | ||
|
||
// ListBedrockModels Fetch enabled Bedrock models using IAM roles | ||
func ListBedrockModels(region string) ([]model.AddGenerativeAiIntegrationRequest, error) { | ||
sess, err := session.NewSession(&aws.Config{ | ||
Region: aws.String(region), | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
svc := bedrock.New(sess) | ||
models, err := svc.ListFoundationModels(&bedrock.ListFoundationModelsInput{ | ||
ByOutputModality: &textModality, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
resp := []model.AddGenerativeAiIntegrationRequest{} | ||
for _, modelSummary := range models.ModelSummaries { | ||
if *modelSummary.ModelLifecycle.Status == modelLifecycleActive { | ||
if _, ok := BedrockModelBody[*modelSummary.ModelId]; ok { | ||
resp = append(resp, model.AddGenerativeAiBedrockIntegration{ | ||
AWSRegion: region, | ||
UseIAMRole: true, | ||
ModelID: *modelSummary.ModelId, | ||
}) | ||
} | ||
} | ||
} | ||
return resp, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.