

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.

# Projekte mit AWS verwalten CloudFormation
<a name="cloudformation-projects"></a>

Amazon Bedrock ist in AWS integriert CloudFormation, sodass Sie Projekte als Teil Ihrer Infrastrukturvorlagen definieren und verwalten können. Mithilfe von JSON- oder YAML-Vorlagen können Sie Projekte konsistent und wiederholt für mehrere AWS-Konten und Regionen bereitstellen.

## AWS::BedrockMantle::Project
<a name="cloudformation-projects-resource"></a>

Verwenden Sie die `AWS::BedrockMantle::Project` Ressource, um ein Bedrock-Projekt in einer CloudFormation Vorlage zu erstellen und zu verwalten. Projekte, die über die API erstellt wurden, CloudFormation unterstützen dieselben Funktionen wie Projekte, die über die API erstellt wurden, einschließlich Anhängen von IAM-Richtlinien, Tagging und Beobachtbarkeit.

### Syntax
<a name="cloudformation-projects-syntax"></a>

Verwenden Sie die folgende Syntax, um diese Entität in Ihrer CloudFormation Vorlage zu deklarieren:

**Example CloudFormation Syntax**  

```
{
  "Type": "AWS::BedrockMantle::Project",
  "Properties": {
    "Name": String,
    "Tags": [
      { "Key": String, "Value": String },
      { "Key": String, "Value": String },
      { "Key": String, "Value": String },
      { "Key": String, "Value": String }
    ]
  }
}
```

```
Type: AWS::BedrockMantle::Project
Properties:
  Name: String
  Tags:
    Key: Value
```

### Eigenschaften
<a name="cloudformation-projects-properties"></a>

Name  
Erforderlich Der Name des Projekts. Muss innerhalb Ihres AWS-Kontos eindeutig sein.  
Typ: Zeichenfolge  
Minimum: 1  
Maximum: 64  
Pattern: `^([0-9a-zA-Z][ _-]?)+$`  
Aktualisierung erfordert: Austausch

Tags (Markierungen)  
Eine Übersicht mit Schlüssel-Wert-Paaren, die dem Projekt zur Kostenzuweisung und Zugriffskontrolle zugeordnet werden sollen.  
Typ: Zuweisung einer Zeichenfolge  
Aktualisierung erfordert: Keine Unterbrechung

**Hinweis zu Tag-Updates**  
CloudFormation Tag-Updates bei der internen `AWS::BedrockMantle::Project` Verwendung separater Operationen zum Hinzufügen und Entfernen. Es gibt keinen vollständigen atomaren Tag-Ersatz. Wenn ein Stack-Update während des Vorgangs fehlschlägt, befindet sich der Tagsatz des Projekts möglicherweise in einem teilweise aktualisierten Zustand. Überprüfen Sie nach einem Stack-Update, bei dem Tags geändert werden, immer den endgültigen Tag-Status.

### Rückgabewerte
<a name="cloudformation-projects-return-values"></a>

#### Punkt
<a name="cloudformation-projects-ref"></a>

Wenn Sie die logische ID dieser Ressource an die systemeigene `Ref` Funktion übergeben, wird die Projekt-ID `Ref` zurückgegeben (z. B.). `proj_abc123`

#### Fn:: GetAtt
<a name="cloudformation-projects-getatt"></a>

ProjectId  
Die eindeutige Kennung des Projekts (z. B.`proj_abc123`).

ProjectArn  
Der Amazon-Ressourcenname (ARN) des Projekts (z. B.`arn:aws:bedrock-mantle:us-east-1:123456789012:project/proj_abc123`).

Status  
Der Status des Projekts. `ACTIVE`bedeutet, dass das Projekt einsatzbereit ist. `ARCHIVED`bedeutet, dass das Projekt archiviert wurde und keine neuen Rückschlussanfragen annehmen kann.

CreatedAt  
Der Zeitstempel, zu dem das Projekt erstellt wurde.

UpdatedAt  
Der Zeitstempel, zu dem das Projekt zuletzt aktualisiert wurde.

## Beispiele
<a name="cloudformation-projects-examples"></a>

### Erstellen Sie ein Basisprojekt
<a name="cloudformation-projects-basic"></a>

Im folgenden Beispiel wird ein Projekt für eine Produktions-Chatbot-Anwendung erstellt:

**Example Grundlegendes Projekt**  

```
AWSTemplateFormatVersion: '2010-09-09'
Description: Amazon Bedrock Project for Production Chatbot

Resources:
  CustomerChatbotProject:
    Type: AWS::BedrockMantle::Project
    Properties:
      Name: CustomerChatbot-Production
      Tags:
        - Key: Project
          Value: CustomerChatbot
        - Key: Environment
          Value: Production
        - Key: Owner
          Value: TeamAlpha
        - Key: CostCenter
          Value: "21524"

Outputs:
  ProjectId:
    Description: The ID of the created project
    Value: !Ref CustomerChatbotProject

  ProjectArn:
    Description: The ARN of the created project
    Value: !GetAtt CustomerChatbotProject.ProjectArn
```

```
{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Resources": {
    "CustomerChatbotProject": {
      "Type": "AWS::BedrockMantle::Project",
      "Properties": {
        "Name": "CustomerChatbot-Production",
        "Tags": [
          { "Key": "Project", "Value": "CustomerChatbot" },
          { "Key": "Environment", "Value": "Production" },
          { "Key": "Owner", "Value": "TeamAlpha" },
          { "Key": "CostCenter", "Value": "21524" }
        ]
      }
    }
  },
  "Outputs": {
    "ProjectId": {
      "Description": "The ID of the created project",
      "Value": { "Ref": "CustomerChatbotProject" }
    },
    "ProjectArn": {
      "Description": "The ARN of the created project",
      "Value": { "Fn::GetAtt": ["CustomerChatbotProject", "ProjectArn"] }
    }
  }
}
```

### Erstellen Sie mehrere Projekte für verschiedene Umgebungen
<a name="cloudformation-projects-multi-env"></a>

Das folgende Beispiel stellt separate Projekte für Entwicklungs-, Staging- und Produktionsumgebungen in einem einzigen Stapel bereit:

```
AWSTemplateFormatVersion: '2010-09-09'
Description: Amazon Bedrock Projects for Multi-Environment Deployment

Parameters:
  ApplicationName:
    Type: String
    Default: InternalSearch
    Description: Name of the application

  CostCenter:
    Type: String
    Description: Cost center for billing allocation

Resources:
  DevelopmentProject:
    Type: AWS::BedrockMantle::Project
    Properties:
      Name: !Sub "${ApplicationName}-Development"
      Tags:
        - Key: Project
          Value: !Ref ApplicationName
        - Key: Environment
          Value: Development
        - Key: CostCenter
          Value: !Ref CostCenter

  StagingProject:
    Type: AWS::BedrockMantle::Project
    Properties:
      Name: !Sub "${ApplicationName}-Staging"
      Tags:
        - Key: Project
          Value: !Ref ApplicationName
        - Key: Environment
          Value: Staging
        - Key: CostCenter
          Value: !Ref CostCenter

  ProductionProject:
    Type: AWS::BedrockMantle::Project
    Properties:
      Name: !Sub "${ApplicationName}-Production"
      Tags:
        - Key: Project
          Value: !Ref ApplicationName
        - Key: Environment
          Value: Production
        - Key: CostCenter
          Value: !Ref CostCenter

Outputs:
  DevelopmentProjectArn:
    Value: !GetAtt DevelopmentProject.ProjectArn
    Export:
      Name: !Sub "${ApplicationName}-Dev-ProjectArn"

  StagingProjectArn:
    Value: !GetAtt StagingProject.ProjectArn
    Export:
      Name: !Sub "${ApplicationName}-Staging-ProjectArn"

  ProductionProjectArn:
    Value: !GetAtt ProductionProject.ProjectArn
    Export:
      Name: !Sub "${ApplicationName}-Prod-ProjectArn"
```

### Erstellen Sie ein Projekt mit IAM-Rollenzugriff
<a name="cloudformation-projects-iam"></a>

Im folgenden Beispiel wird ein Projekt erstellt und eine IAM-Richtlinie angehängt, die einer bestimmten Rolle Zugriff auf Aufrufmodelle gewährt:

```
AWSTemplateFormatVersion: '2010-09-09'
Description: Amazon Bedrock Project with IAM Access Control

Resources:
  ProductionProject:
    Type: AWS::BedrockMantle::Project
    Properties:
      Name: CustomerChatbot-Production
      Tags:
        - Key: Environment
          Value: Production
        - Key: CostCenter
          Value: "21524"

  ProductionAppRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: BedrockProjectProductionRole
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              Service: lambda.amazonaws.com
            Action: sts:AssumeRole
      Policies:
        - PolicyName: BedrockProjectInvokeAccess
          PolicyDocument:
            Version: '2012-10-17'
            Statement:
              - Effect: Allow
                Action:
                  - bedrock-mantle:CreateInference
                  - bedrock-mantle:GetProject
                Resource: !GetAtt ProductionProject.ProjectArn

Outputs:
  ProjectArn:
    Value: !GetAtt ProductionProject.ProjectArn

  RoleArn:
    Value: !GetAtt ProductionAppRole.Arn
```

## Verwenden von CloudFormation Ausgaben mit der Projects-API
<a name="cloudformation-projects-using-outputs"></a>

Nach der Bereitstellung Ihres CloudFormation Stacks können Sie mithilfe der Stack-Ausgaben auf den Projekt-ARN und die ID in Ihrem Anwendungscode verweisen:

```
import boto3
from openai import OpenAI

# Retrieve project details from CloudFormation stack outputs
cfn = boto3.client('cloudformation', region_name='us-east-1')

response = cfn.describe_stacks(StackName='my-bedrock-projects-stack')
outputs = {o['OutputKey']: o['OutputValue'] for o in response['Stacks'][0]['Outputs']}

production_project_arn = outputs['ProductionProjectArn']

# Extract project ID from ARN
# ARN format: arn:aws:bedrock-mantle:us-east-1:123456789012:project/proj_abc123
project_id = production_project_arn.split('/')[-1]

print(f"Using project: {project_id}")

# Use the project for inference
client = OpenAI(project=project_id)

response = client.responses.create(
    model="openai.gpt-oss-120b",
    input="Hello from a CloudFormation-managed project!"
)

print(response)
```

## Weitere Informationen
<a name="cloudformation-projects-learn-more"></a>

Weitere Informationen zur Verwendung CloudFormation mit Amazon Bedrock-Ressourcen finden Sie unter:
+ [Erstellen Sie Amazon Bedrock-Ressourcen mit AWS CloudFormation](creating-resources-with-cloudformation.md)
+ [ CloudFormation AWS-Benutzerhandbuch](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html)
+ [Referenz zum Amazon Bedrock-Ressourcentyp](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/AWS_Bedrock.html)