# Guardrail

Guradrail settings for BedrockInvokeModel.

- Source: [`aws-stepfunctions-tasks/lib/bedrock/guardrail.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/bedrock/guardrail.ts#L7)
- Type last changed: v2.149.0 · 12 Jul 2024

## Example

```ts
import * as bedrock from 'aws-cdk-lib/aws-bedrock';

const model = bedrock.FoundationModel.fromFoundationModelId(
  this,
  'Model',
  bedrock.FoundationModelIdentifier.AMAZON_TITAN_TEXT_G1_EXPRESS_V1,
);

const task = new tasks.BedrockInvokeModel(this, 'Prompt Model with guardrail', {
  model,
  body: sfn.TaskInput.fromObject(
    {
      inputText: 'Generate a list of five first names.',
      textGenerationConfig: {
        maxTokenCount: 100,
        temperature: 1,
      },
    },
  ),
  guardrail: tasks.Guardrail.enable('guardrailId', 1),
  resultSelector: {
    names: sfn.JsonPath.stringAt('$.Body.results[0].outputText'),
  },
});
```

## Properties

- `guardrailIdentifier`: string — The identitifier of guardrail.

- `guardrailVersion`: string — The version of guardrail.

## Methods

- `enable(identifier: string, version: number): Guardrail // chainable` (static) — Enable guardrail.

  **Parameters**

  - `identifier` — The id or arn of the guardrail.
  - `version` — The version of the guardrail.

- `enableDraft(identifier: string): Guardrail // chainable` (static) — Enable guardrail with DRAFT version.

  **Parameters**

  - `identifier` — The identifier of the guardrail.
