> **Experimental**
>
> `@aws-cdk/aws-bedrock-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# KnowledgeBaseAttributes

Attributes for referencing an existing knowledge base.

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`bedrock/knowledge-bases/knowledge-base.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/@aws-cdk/aws-bedrock-alpha/bedrock/knowledge-bases/knowledge-base.ts#L120)
- Type last changed: v2.274.0-alpha.0 · 21 Oct 2026

## Example

TypeScript:

```ts
declare const role: iam.Role;

const byArn = bedrock.KnowledgeBase.fromKnowledgeBaseArn(this, 'ImportedByArn',
  'arn:aws:bedrock:us-east-1:123456789012:knowledge-base/KB12345678');

// Assumed to be in the same account and region as this stack
const byId = bedrock.KnowledgeBase.fromKnowledgeBaseId(this, 'ImportedById', 'KB12345678');

const withRole = bedrock.KnowledgeBase.fromKnowledgeBaseAttributes(this, 'ImportedWithRole', {
  knowledgeBaseArn: 'arn:aws:bedrock:us-east-1:123456789012:knowledge-base/KB12345678',
  role,
});
```

Python:

```python
# role: iam.Role

by_arn = bedrock.KnowledgeBase.from_knowledge_base_arn(self, "ImportedByArn", "arn:aws:bedrock:us-east-1:123456789012:knowledge-base/KB12345678")

# Assumed to be in the same account and region as this stack
by_id = bedrock.KnowledgeBase.from_knowledge_base_id(self, "ImportedById", "KB12345678")

with_role = bedrock.KnowledgeBase.from_knowledge_base_attributes(self, "ImportedWithRole",
    knowledge_base_arn="arn:aws:bedrock:us-east-1:123456789012:knowledge-base/KB12345678",
    role=role
)
```

Java:

```java
Role role;

IKnowledgeBase byArn = KnowledgeBase.fromKnowledgeBaseArn(this, "ImportedByArn", "arn:aws:bedrock:us-east-1:123456789012:knowledge-base/KB12345678");

// Assumed to be in the same account and region as this stack
IKnowledgeBase byId = KnowledgeBase.fromKnowledgeBaseId(this, "ImportedById", "KB12345678");

IKnowledgeBase withRole = KnowledgeBase.fromKnowledgeBaseAttributes(this, "ImportedWithRole", KnowledgeBaseAttributes.builder()
        .knowledgeBaseArn("arn:aws:bedrock:us-east-1:123456789012:knowledge-base/KB12345678")
        .role(role)
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
Role role;

var byArn = KnowledgeBase.FromKnowledgeBaseArn(this, "ImportedByArn", "arn:aws:bedrock:us-east-1:123456789012:knowledge-base/KB12345678");

// Assumed to be in the same account and region as this stack
var byId = KnowledgeBase.FromKnowledgeBaseId(this, "ImportedById", "KB12345678");

var withRole = KnowledgeBase.FromKnowledgeBaseAttributes(this, "ImportedWithRole", new KnowledgeBaseAttributes {
    KnowledgeBaseArn = "arn:aws:bedrock:us-east-1:123456789012:knowledge-base/KB12345678",
    Role = role
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
var role Role

byArn := bedrock.KnowledgeBase_FromKnowledgeBaseArn(this, jsii.String("ImportedByArn"), jsii.String("arn:aws:bedrock:us-east-1:123456789012:knowledge-base/KB12345678"))

// Assumed to be in the same account and region as this stack
byId := bedrock.KnowledgeBase_FromKnowledgeBaseId(this, jsii.String("ImportedById"), jsii.String("KB12345678"))

withRole := bedrock.KnowledgeBase_FromKnowledgeBaseAttributes(this, jsii.String("ImportedWithRole"), &KnowledgeBaseAttributes{
	KnowledgeBaseArn: jsii.String("arn:aws:bedrock:us-east-1:123456789012:knowledge-base/KB12345678"),
	Role: Role,
})
```

## Properties

- `knowledgeBaseArn`: string (required) — The ARN of the knowledge base.

- `role`: any — The service role of the knowledge base.

  **Default:** the role is unknown
