

Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.

# Verwaltung von IAM-Richtlinien für Projekte
<a name="security-iam-projects"></a>

Amazon Bedrock Projects unterstützt die direkte Zuordnung von IAM-Richtlinien, sodass Sie die Zugriffskontrolle auf Projektressourcenebene verwalten können. Dies bietet eine Alternative zur Verwaltung von Richtlinien für IAM-Benutzer und -Rollen.

## Grundlegendes zu IAM-Richtlinien auf Projektebene
<a name="security-iam-projects-understanding"></a>

IAM-Richtlinien auf Projektebene ermöglichen Ihnen:
+ **Zentralisieren Sie die Zugriffskontrolle**: Definieren Sie Berechtigungen direkt für die Projektressource
+ **Vereinfachen Sie die Verwaltung**: Aktualisieren Sie den Zugriff, ohne einzelne user/role Richtlinien zu ändern
+ **Einfache Prüfung**: Sehen Sie sich alle Berechtigungen für ein Projekt an einem Ort an
+ **Verwaltung delegieren**: Erlauben Sie den Projekteigentümern, den Zugriff auf ihre Projekte zu verwalten

## IAM-Richtlinien an Projekte anhängen
<a name="security-iam-projects-attaching"></a>

### Fügen Sie eine Richtlinie hinzu, um Zugriff zu gewähren
<a name="security-iam-projects-attach-grant"></a>

Hängen Sie eine IAM-Richtlinie direkt an ein Projekt an, um Berechtigungen zu gewähren:

```
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")
```

### Gewähren Sie einem Team vollen Projektzugriff
<a name="security-iam-projects-full-access"></a>

Gewähren Sie einem Team vollen Zugriff auf die Verwaltung und Nutzung eines Projekts:

```
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")
```

### Nur-Lesezugriff gewähren
<a name="security-iam-projects-readonly"></a>

Fügen Sie eine Richtlinie bei, die nur das Anzeigen von Projektdetails und das Stellen von Rückschlussanfragen erlaubt:

```
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")
```