기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
프로젝트에서 IAM 정책 관리
Amazon Bedrock Projects는 직접 IAM 정책 연결을 지원하므로 프로젝트 리소스 수준에서 액세스 제어를 관리할 수 있습니다. 이는 IAM 사용자 및 역할에 대한 정책 관리의 대안을 제공합니다.
프로젝트 수준 IAM 정책 이해
프로젝트 수준 IAM 정책을 사용하면 다음을 수행할 수 있습니다.
-
액세스 제어 중앙 집중화: 프로젝트 리소스에 대한 직접 권한 정의
-
관리 간소화: 개별 사용자/역할 정책을 수정하지 않고 액세스 업데이트
-
간편한 감사: 프로젝트의 모든 권한을 한 곳에서 볼 수 있습니다.
-
위임 관리: 프로젝트 소유자가 프로젝트에 대한 액세스를 관리하도록 허용
프로젝트에 IAM 정책 연결
액세스 권한을 부여하는 정책 연결
IAM 정책을 프로젝트에 직접 연결하여 권한을 부여합니다.
import boto3 import json iam = boto3.client('iam', region_name='us-east-1') project_arn = "arn:aws:bedrock-mantle:us-east-1:123456789012:project/proj_abc123" # Define the identity-based policy document policy_document = { "Version": "2012-10-17", "Statement": [ { "Sid": "AllowTeamAlphaAccess", "Effect": "Allow", "Action": [ "bedrock-mantle:ListTagsForResources", "bedrock-mantle:GetProject" ], "Resource": project_arn } ] } policy_json = json.dumps(policy_document) # Create a managed policy create_response = iam.create_policy( PolicyName="TeamAlphaAccessPolicy", PolicyDocument=policy_json, Description="Grants Team Alpha read access to the Bedrock project" ) policy_arn = create_response['Policy']['Arn'] print(f"Policy created: {policy_arn}") # Attach the policy to alice (IAM user) iam.attach_user_policy( UserName="alice", PolicyArn=policy_arn ) print("Policy attached to alice") # Attach the policy to bob (IAM user) iam.attach_user_policy( UserName="bob", PolicyArn=policy_arn ) print("Policy attached to bob") # Attach the policy to TeamAlphaRole (IAM role) iam.attach_role_policy( RoleName="TeamAlphaRole", PolicyArn=policy_arn ) print("Policy attached to TeamAlphaRole")
팀에 전체 프로젝트 액세스 권한 부여
팀이 프로젝트를 관리하고 사용할 수 있는 전체 액세스 권한을 허용합니다.
import boto3 import json iam = boto3.client('iam', region_name='us-east-1') project_arn = "arn:aws:bedrock-mantle:us-east-1:123456789012:project/proj_abc123" # Identity-based policy — no Principal block needed policy_document = { "Version": "2012-10-17", "Statement": [ { "Sid": "FullProjectAccess", "Effect": "Allow", "Action": "bedrock-mantle:*", "Resource": project_arn } ] } # Create a managed policy create_response = iam.create_policy( PolicyName="DataScienceFullAccess", PolicyDocument=json.dumps(policy_document), Description="Grants DataScienceTeamRole full access to the Bedrock project" ) policy_arn = create_response['Policy']['Arn'] print(f"Policy created: {policy_arn}") # Attach to the DataScienceTeamRole iam.attach_role_policy( RoleName="DataScienceTeamRole", PolicyArn=policy_arn ) print("Full access policy attached to DataScienceTeamRole")
에 읽기 전용 액세스 권한 부여
프로젝트 세부 정보를 보고 추론 요청만 수행할 수 있도록 허용하는 정책을 연결합니다.
import boto3 import json iam = boto3.client('iam', region_name='us-east-1') project_arn = "arn:aws:bedrock-mantle:us-east-1:123456789012:project/proj_abc123" # Identity-based policy — no Principal block needed policy_document = { "Version": "2012-10-17", "Statement": [ { "Sid": "ReadOnlyAccess", "Effect": "Allow", "Action": [ "bedrock-mantle:CreateInference", "bedrock-mantle:GetProject", "bedrock-mantle:ListProjects", "bedrock-mantle:ListTagsForResources" ], "Resource": project_arn } ] } # Create a managed policy create_response = iam.create_policy( PolicyName="ReadOnlyAccessPolicy", PolicyDocument=json.dumps(policy_document), Description="Grants viewer1 and viewer2 read-only access to the Bedrock project" ) policy_arn = create_response['Policy']['Arn'] print(f"Policy created: {policy_arn}") # Attach to viewer1 iam.attach_user_policy( UserName="viewer1", PolicyArn=policy_arn ) print("Policy attached to viewer1") # Attach to viewer2 iam.attach_user_policy( UserName="viewer2", PolicyArn=policy_arn ) print("Policy attached to viewer2")