Skip to content
v2.278.0

Experimental

@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

RegexFilter Struct ​

A Regular expression (regex) filter for sensitive information.

Example ​

ts
const guardrail = new bedrock.Guardrail(this, 'bedrockGuardrails', {
  guardrailName: 'my-BedrockGuardrails',
});
// Add regex filter with input/output actions
guardrail.addRegexFilter({
  name: 'TestRegexFilter',
  pattern: 'test-pattern',
  action: bedrock.GuardrailAction.ANONYMIZE,
  // below props are optional
  description: 'This is a test regex filter',
  inputAction: bedrock.GuardrailAction.BLOCK,
  inputEnabled: true,
  outputAction: bedrock.GuardrailAction.ANONYMIZE,
  outputEnabled: true,
});
python
guardrail = bedrock.Guardrail(self, "bedrockGuardrails",
    guardrail_name="my-BedrockGuardrails"
)
# Add regex filter with input/output actions
guardrail.add_regex_filter(
    name="TestRegexFilter",
    pattern="test-pattern",
    action=bedrock.GuardrailAction.ANONYMIZE,
    # below props are optional
    description="This is a test regex filter",
    input_action=bedrock.GuardrailAction.BLOCK,
    input_enabled=True,
    output_action=bedrock.GuardrailAction.ANONYMIZE,
    output_enabled=True
)
java
Guardrail guardrail = Guardrail.Builder.create(this, "bedrockGuardrails")
        .guardrailName("my-BedrockGuardrails")
        .build();
// Add regex filter with input/output actions
guardrail.addRegexFilter(RegexFilter.builder()
        .name("TestRegexFilter")
        .pattern("test-pattern")
        .action(GuardrailAction.ANONYMIZE)
        // below props are optional
        .description("This is a test regex filter")
        .inputAction(GuardrailAction.BLOCK)
        .inputEnabled(true)
        .outputAction(GuardrailAction.ANONYMIZE)
        .outputEnabled(true)
        .build());
csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
var guardrail = new Guardrail(this, "bedrockGuardrails", new GuardrailProps {
    GuardrailName = "my-BedrockGuardrails"
});
// Add regex filter with input/output actions
guardrail.AddRegexFilter(new RegexFilter {
    Name = "TestRegexFilter",
    Pattern = "test-pattern",
    Action = GuardrailAction.ANONYMIZE,
    // below props are optional
    Description = "This is a test regex filter",
    InputAction = GuardrailAction.BLOCK,
    InputEnabled = true,
    OutputAction = GuardrailAction.ANONYMIZE,
    OutputEnabled = true
});
go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
guardrail := bedrock.NewGuardrail(this, jsii.String("bedrockGuardrails"), &GuardrailProps{
	GuardrailName: jsii.String("my-BedrockGuardrails"),
})
// Add regex filter with input/output actions
guardrail.AddRegexFilter(&RegexFilter{
	Name: jsii.String("TestRegexFilter"),
	Pattern: jsii.String("test-pattern"),
	Action: bedrock.GuardrailAction_ANONYMIZE,
	// below props are optional
	Description: jsii.String("This is a test regex filter"),
	InputAction: bedrock.GuardrailAction_BLOCK,
	InputEnabled: jsii.Boolean(true),
	OutputAction: bedrock.GuardrailAction_ANONYMIZE,
	OutputEnabled: jsii.Boolean(true),
})

Properties ​

The action to take when a regex match is detected.
descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string #
The description of the regex filter.

Default: No description

inputActionoptionalGuardrailActioninput_actionoptionalGuardrailActioninputActionoptionalGuardrailActionInputActionoptionalGuardrailActionInputActionoptionalGuardrailAction = GuardrailAction.BLOCK #
The action to take when a regex match is detected in the input.
inputEnabledoptionalbooleaninput_enabledoptionalboolinputEnabledoptionalBooleanInputEnabledoptionalboolInputEnabledoptional*bool = true #
Whether the regex filter is enabled for input.
namestringnamestrnameStringNamestringName*string required #
The name of the regex filter.
outputActionoptionalGuardrailActionoutput_actionoptionalGuardrailActionoutputActionoptionalGuardrailActionOutputActionoptionalGuardrailActionOutputActionoptionalGuardrailAction = GuardrailAction.BLOCK #
The action to take when a regex match is detected in the output.
outputEnabledoptionalbooleanoutput_enabledoptionalbooloutputEnabledoptionalBooleanOutputEnabledoptionalboolOutputEnabledoptional*bool = true #
Whether the regex filter is enabled for output.
patternstringpatternstrpatternStringPatternstringPattern*string required #
The regular expression pattern to match.