Guardrail

class Guardrail : KotlinCustomResource

Resource for managing an Amazon Bedrock Guardrail.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.bedrock.Guardrail("example", {
name: "example",
blockedInputMessaging: "example",
blockedOutputsMessaging: "example",
description: "example",
contentPolicyConfig: {
filtersConfigs: [{
inputStrength: "MEDIUM",
outputStrength: "MEDIUM",
type: "HATE",
}],
},
sensitiveInformationPolicyConfig: {
piiEntitiesConfigs: [{
action: "BLOCK",
type: "NAME",
}],
regexesConfigs: [{
action: "BLOCK",
description: "example regex",
name: "regex_example",
pattern: "^\\d{3}-\\d{2}-\\d{4}$",
}],
},
topicPolicyConfig: {
topicsConfigs: [{
name: "investment_topic",
examples: ["Where should I invest my money ?"],
type: "DENY",
definition: "Investment advice refers to inquiries, guidance, or recommendations regarding the management or allocation of funds or assets with the goal of generating returns .",
}],
},
wordPolicyConfig: {
managedWordListsConfigs: [{
type: "PROFANITY",
}],
wordsConfigs: [{
text: "HATE",
}],
},
});
import pulumi
import pulumi_aws as aws
example = aws.bedrock.Guardrail("example",
name="example",
blocked_input_messaging="example",
blocked_outputs_messaging="example",
description="example",
content_policy_config={
"filters_configs": [{
"input_strength": "MEDIUM",
"output_strength": "MEDIUM",
"type": "HATE",
}],
},
sensitive_information_policy_config={
"pii_entities_configs": [{
"action": "BLOCK",
"type": "NAME",
}],
"regexes_configs": [{
"action": "BLOCK",
"description": "example regex",
"name": "regex_example",
"pattern": "^\\d{3}-\\d{2}-\\d{4}$",
}],
},
topic_policy_config={
"topics_configs": [{
"name": "investment_topic",
"examples": ["Where should I invest my money ?"],
"type": "DENY",
"definition": "Investment advice refers to inquiries, guidance, or recommendations regarding the management or allocation of funds or assets with the goal of generating returns .",
}],
},
word_policy_config={
"managed_word_lists_configs": [{
"type": "PROFANITY",
}],
"words_configs": [{
"text": "HATE",
}],
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.Bedrock.Guardrail("example", new()
{
Name = "example",
BlockedInputMessaging = "example",
BlockedOutputsMessaging = "example",
Description = "example",
ContentPolicyConfig = new Aws.Bedrock.Inputs.GuardrailContentPolicyConfigArgs
{
FiltersConfigs = new[]
{
new Aws.Bedrock.Inputs.GuardrailContentPolicyConfigFiltersConfigArgs
{
InputStrength = "MEDIUM",
OutputStrength = "MEDIUM",
Type = "HATE",
},
},
},
SensitiveInformationPolicyConfig = new Aws.Bedrock.Inputs.GuardrailSensitiveInformationPolicyConfigArgs
{
PiiEntitiesConfigs = new[]
{
new Aws.Bedrock.Inputs.GuardrailSensitiveInformationPolicyConfigPiiEntitiesConfigArgs
{
Action = "BLOCK",
Type = "NAME",
},
},
RegexesConfigs = new[]
{
new Aws.Bedrock.Inputs.GuardrailSensitiveInformationPolicyConfigRegexesConfigArgs
{
Action = "BLOCK",
Description = "example regex",
Name = "regex_example",
Pattern = "^\\d{3}-\\d{2}-\\d{4}$",
},
},
},
TopicPolicyConfig = new Aws.Bedrock.Inputs.GuardrailTopicPolicyConfigArgs
{
TopicsConfigs = new[]
{
new Aws.Bedrock.Inputs.GuardrailTopicPolicyConfigTopicsConfigArgs
{
Name = "investment_topic",
Examples = new[]
{
"Where should I invest my money ?",
},
Type = "DENY",
Definition = "Investment advice refers to inquiries, guidance, or recommendations regarding the management or allocation of funds or assets with the goal of generating returns .",
},
},
},
WordPolicyConfig = new Aws.Bedrock.Inputs.GuardrailWordPolicyConfigArgs
{
ManagedWordListsConfigs = new[]
{
new Aws.Bedrock.Inputs.GuardrailWordPolicyConfigManagedWordListsConfigArgs
{
Type = "PROFANITY",
},
},
WordsConfigs = new[]
{
new Aws.Bedrock.Inputs.GuardrailWordPolicyConfigWordsConfigArgs
{
Text = "HATE",
},
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/bedrock"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := bedrock.NewGuardrail(ctx, "example", &bedrock.GuardrailArgs{
Name: pulumi.String("example"),
BlockedInputMessaging: pulumi.String("example"),
BlockedOutputsMessaging: pulumi.String("example"),
Description: pulumi.String("example"),
ContentPolicyConfig: &bedrock.GuardrailContentPolicyConfigArgs{
FiltersConfigs: bedrock.GuardrailContentPolicyConfigFiltersConfigArray{
&bedrock.GuardrailContentPolicyConfigFiltersConfigArgs{
InputStrength: pulumi.String("MEDIUM"),
OutputStrength: pulumi.String("MEDIUM"),
Type: pulumi.String("HATE"),
},
},
},
SensitiveInformationPolicyConfig: &bedrock.GuardrailSensitiveInformationPolicyConfigArgs{
PiiEntitiesConfigs: bedrock.GuardrailSensitiveInformationPolicyConfigPiiEntitiesConfigArray{
&bedrock.GuardrailSensitiveInformationPolicyConfigPiiEntitiesConfigArgs{
Action: pulumi.String("BLOCK"),
Type: pulumi.String("NAME"),
},
},
RegexesConfigs: bedrock.GuardrailSensitiveInformationPolicyConfigRegexesConfigArray{
&bedrock.GuardrailSensitiveInformationPolicyConfigRegexesConfigArgs{
Action: pulumi.String("BLOCK"),
Description: pulumi.String("example regex"),
Name: pulumi.String("regex_example"),
Pattern: pulumi.String("^\\d{3}-\\d{2}-\\d{4}$"),
},
},
},
TopicPolicyConfig: &bedrock.GuardrailTopicPolicyConfigArgs{
TopicsConfigs: bedrock.GuardrailTopicPolicyConfigTopicsConfigArray{
&bedrock.GuardrailTopicPolicyConfigTopicsConfigArgs{
Name: pulumi.String("investment_topic"),
Examples: pulumi.StringArray{
pulumi.String("Where should I invest my money ?"),
},
Type: pulumi.String("DENY"),
Definition: pulumi.String("Investment advice refers to inquiries, guidance, or recommendations regarding the management or allocation of funds or assets with the goal of generating returns ."),
},
},
},
WordPolicyConfig: &bedrock.GuardrailWordPolicyConfigArgs{
ManagedWordListsConfigs: bedrock.GuardrailWordPolicyConfigManagedWordListsConfigArray{
&bedrock.GuardrailWordPolicyConfigManagedWordListsConfigArgs{
Type: pulumi.String("PROFANITY"),
},
},
WordsConfigs: bedrock.GuardrailWordPolicyConfigWordsConfigArray{
&bedrock.GuardrailWordPolicyConfigWordsConfigArgs{
Text: pulumi.String("HATE"),
},
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.bedrock.Guardrail;
import com.pulumi.aws.bedrock.GuardrailArgs;
import com.pulumi.aws.bedrock.inputs.GuardrailContentPolicyConfigArgs;
import com.pulumi.aws.bedrock.inputs.GuardrailSensitiveInformationPolicyConfigArgs;
import com.pulumi.aws.bedrock.inputs.GuardrailTopicPolicyConfigArgs;
import com.pulumi.aws.bedrock.inputs.GuardrailWordPolicyConfigArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new Guardrail("example", GuardrailArgs.builder()
.name("example")
.blockedInputMessaging("example")
.blockedOutputsMessaging("example")
.description("example")
.contentPolicyConfig(GuardrailContentPolicyConfigArgs.builder()
.filtersConfigs(GuardrailContentPolicyConfigFiltersConfigArgs.builder()
.inputStrength("MEDIUM")
.outputStrength("MEDIUM")
.type("HATE")
.build())
.build())
.sensitiveInformationPolicyConfig(GuardrailSensitiveInformationPolicyConfigArgs.builder()
.piiEntitiesConfigs(GuardrailSensitiveInformationPolicyConfigPiiEntitiesConfigArgs.builder()
.action("BLOCK")
.type("NAME")
.build())
.regexesConfigs(GuardrailSensitiveInformationPolicyConfigRegexesConfigArgs.builder()
.action("BLOCK")
.description("example regex")
.name("regex_example")
.pattern("^\\d{3}-\\d{2}-\\d{4}$")
.build())
.build())
.topicPolicyConfig(GuardrailTopicPolicyConfigArgs.builder()
.topicsConfigs(GuardrailTopicPolicyConfigTopicsConfigArgs.builder()
.name("investment_topic")
.examples("Where should I invest my money ?")
.type("DENY")
.definition("Investment advice refers to inquiries, guidance, or recommendations regarding the management or allocation of funds or assets with the goal of generating returns .")
.build())
.build())
.wordPolicyConfig(GuardrailWordPolicyConfigArgs.builder()
.managedWordListsConfigs(GuardrailWordPolicyConfigManagedWordListsConfigArgs.builder()
.type("PROFANITY")
.build())
.wordsConfigs(GuardrailWordPolicyConfigWordsConfigArgs.builder()
.text("HATE")
.build())
.build())
.build());
}
}
resources:
example:
type: aws:bedrock:Guardrail
properties:
name: example
blockedInputMessaging: example
blockedOutputsMessaging: example
description: example
contentPolicyConfig:
filtersConfigs:
- inputStrength: MEDIUM
outputStrength: MEDIUM
type: HATE
sensitiveInformationPolicyConfig:
piiEntitiesConfigs:
- action: BLOCK
type: NAME
regexesConfigs:
- action: BLOCK
description: example regex
name: regex_example
pattern: ^\d{3}-\d{2}-\d{4}$
topicPolicyConfig:
topicsConfigs:
- name: investment_topic
examples:
- Where should I invest my money ?
type: DENY
definition: Investment advice refers to inquiries, guidance, or recommendations regarding the management or allocation of funds or assets with the goal of generating returns .
wordPolicyConfig:
managedWordListsConfigs:
- type: PROFANITY
wordsConfigs:
- text: HATE

Import

Using pulumi import, import Amazon Bedrock Guardrail using using a comma-delimited string of guardrail_id and version. For example:

$ pulumi import aws:bedrock/guardrail:Guardrail example guardrail-id-12345678,DRAFT

Properties

Link copied to clipboard

Message to return when the guardrail blocks a prompt.

Link copied to clipboard

Message to return when the guardrail blocks a model response.

Link copied to clipboard

Content policy config for a guardrail. See Content Policy Config for more information.

Link copied to clipboard

Contextual grounding policy config for a guardrail. See Contextual Grounding Policy Config for more information.

Link copied to clipboard
val createdAt: Output<String>

Unix epoch timestamp in seconds for when the Guardrail was created.

Link copied to clipboard
val description: Output<String>

Description of the guardrail or its version.

Link copied to clipboard
val guardrailArn: Output<String>

ARN of the Guardrail.

Link copied to clipboard
val guardrailId: Output<String>

ID of the Guardrail.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val kmsKeyArn: Output<String>?

The KMS key with which the guardrail was encrypted at rest.

Link copied to clipboard
val name: Output<String>

Name of the guardrail. The following arguments are optional:

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Sensitive information policy config for a guardrail. See Sensitive Information Policy Config for more information.

Link copied to clipboard
val status: Output<String>

Status of the Bedrock Guardrail. One of READY, FAILED.

Link copied to clipboard
val tags: Output<Map<String, String>>?

Key-value map of resource tags. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Link copied to clipboard
val tagsAll: Output<Map<String, String>>
Link copied to clipboard
Link copied to clipboard

Topic policy config for a guardrail. See Topic Policy Config for more information.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val version: Output<String>

Version of the Guardrail.

Link copied to clipboard

Word policy config for a guardrail. See Word Policy Config for more information.