Skip to content

Commit

Permalink
IT-3988: Add role to invoke model and move inline sso policy to manag…
Browse files Browse the repository at this point in the history
…ed policy (#1277)

* Add role

* Move policy from inline to managed

* Rename stack/policy

* Fix per review

* Rename stack

* Restore inline policy per review

* Create agent role in all accounts per review

* Rename output per review
  • Loading branch information
xschildw authored Nov 13, 2024
1 parent d258791 commit 5554047
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
10 changes: 10 additions & 0 deletions org-formation/300-account-defaults/_tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,13 @@ ItKmsKey:
IncludeMasterAccount: true
Account: '*'
Region: !Ref primaryRegion

BedrockAgentRole:
Type: update-stacks
Template: ./bedrock-agent-role.yaml
StackName: bedrock-agent-role
DefaultOrganizationBindingRegion: !Ref primaryRegion
DefaultOrganizationBinding:
IncludeMasterAccount: false
Account: '*'
Region: !Ref primaryRegion
36 changes: 36 additions & 0 deletions org-formation/300-account-defaults/bedrock-agent-role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
AWSTemplateFormatVersion: '2010-09-09'
Description: Enables executing a Bedrock model

Resources:
# https://docs.aws.amazon.com/bedrock/latest/userguide/agents-permissions.html
bedrockAgentRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service: bedrock.amazonaws.com
Action: sts:AssumeRole
Condition:
StringEquals:
aws:SourceAccount: !Ref AWS::AccountId
ArnLike:
aws:SourceArn: !Sub "arn:aws:bedrock:${AWS::Region}:${AWS::AccountId}:agent/*"
Policies:
- PolicyName: bedrockAgentPolicy
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: "bedrock:InvokeModel"
Resource:
- !Sub "arn:aws:bedrock:${AWS::Region}::foundation-model/*"

Outputs:
BedrockAgentRoleArn:
Description: The ARN of the Bedrock Agent Role
Value: !GetAtt bedrockAgentRole.Arn
Export:
Name: !Sub '${AWS::StackName}-BedrockAgentRoleArn'
28 changes: 28 additions & 0 deletions org-formation/600-access/_tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -388,3 +388,31 @@ SynapseAthenaUserAccessPolicy:
]
}
PolicyName: SynapseAthenaUserAccessPolicy

SynapseLlmDeveloperPolicy:
Type: update-stacks
Template: https://raw.githubusercontent.com/Sage-Bionetworks/aws-infra/v0.5.1/templates/IAM/managed-policy.yaml
StackName: synapsellm-developer-policy
DefaultOrganizationBinding:
IncludeMasterAccount: true
Account:
- SynapseLlmProdAccount
Region: !Ref primaryRegion
Parameters:
PolicyDocument: >-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:::cf-template*"
},
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "*"
}
]
}
PolicyName: SynapseLlmDeveloperPolicy

0 comments on commit 5554047

Please sign in to comment.