Skip to content

Commit

Permalink
chore(bedrock): update bedrock
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-rafams committed Oct 15, 2024
1 parent 8a14cf7 commit 93efb20
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 104 deletions.
20 changes: 20 additions & 0 deletions apidocs/namespaces/bedrock/classes/Guardrail.md
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,26 @@ Commonly this is the resource's `ref`.

***

### grantApply()

> **grantApply**(`grantee`): `Grant`
Grant the given identity permissions to apply the guardrail.

#### Parameters

**grantee**: `IGrantable`

#### Returns

`Grant`

#### Inherited from

[`GuardrailBase`](GuardrailBase.md).[`grantApply`](GuardrailBase.md#grantapply)

***

### toString()

> **toString**(): `string`
Expand Down
20 changes: 20 additions & 0 deletions apidocs/namespaces/bedrock/classes/GuardrailBase.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,26 @@ Commonly this is the resource's `ref`.

***

### grantApply()

> **grantApply**(`grantee`): `Grant`
Grant the given identity permissions to apply the guardrail.

#### Parameters

**grantee**: `IGrantable`

#### Returns

`Grant`

#### Implementation of

[`IGuardrail`](../interfaces/IGuardrail.md).[`grantApply`](../interfaces/IGuardrail.md#grantapply)

***

### toString()

> **toString**(): `string`
Expand Down
16 changes: 16 additions & 0 deletions apidocs/namespaces/bedrock/interfaces/IGuardrail.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,19 @@ account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).
#### Inherited from

`IResource.applyRemovalPolicy`

***

### grantApply()

> **grantApply**(`grantee`): `Grant`
Grant the given identity permissions to apply the guardrail.

#### Parameters

**grantee**: `IGrantable`

#### Returns

`Grant`
16 changes: 16 additions & 0 deletions src/cdk-lib/bedrock/guardrails/guardrails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import * as fs from 'fs';
import { Arn, ArnFormat, IResolvable, IResource, Lazy, Resource, Stack } from 'aws-cdk-lib';
import * as bedrock from 'aws-cdk-lib/aws-bedrock';
import * as iam from 'aws-cdk-lib/aws-iam';
import { IKey } from 'aws-cdk-lib/aws-kms';
import { md5hash } from 'aws-cdk-lib/core/lib/helpers-internal';
import { Construct } from 'constructs';
Expand All @@ -36,6 +37,10 @@ export interface IGuardrail extends IResource {
* @example "yympzo398ipq"
*/
readonly guardrailId: string;
/**
* Grant the given identity permissions to apply the guardrail.
*/
grantApply(grantee: iam.IGrantable): iam.Grant;
}

/**
Expand All @@ -51,6 +56,17 @@ export abstract class GuardrailBase extends Resource implements IGuardrail {
* The ID of the guardrail.
*/
public abstract readonly guardrailId: string;
/**
* Grant the given identity permissions to apply the guardrail.
*/
public grantApply(grantee: iam.IGrantable): iam.Grant {
return iam.Grant.addToPrincipal({
grantee,
resourceArns: [this.guardrailArn],
actions: ['bedrock:ApplyGuardrail'],
scope: this,
});
}
}

/******************************************************************************
Expand Down
Loading

0 comments on commit 93efb20

Please sign in to comment.