java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.mixins.preview.core.Mixin
software.amazon.awscdk.mixins.preview.services.bedrock.mixins.CfnGuardrailPropsMixin
All Implemented Interfaces:
IMixin, software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.121.0 (build d7af9b9)", date="2025-12-18T18:20:23.400Z") @Stability(Stable) public class CfnGuardrailPropsMixin extends Mixin implements IMixin
Creates a guardrail to detect and filter harmful content in your generative AI application.

Amazon Bedrock Guardrails provides the following safeguards (also known as policies) to detect and filter harmful content:

  • Content filters - Detect and filter harmful text or image content in input prompts or model responses. Filtering is done based on detection of certain predefined harmful content categories: Hate, Insults, Sexual, Violence, Misconduct and Prompt Attack. You also can adjust the filter strength for each of these categories.
  • Denied topics - Define a set of topics that are undesirable in the context of your application. The filter will help block them if detected in user queries or model responses.
  • Word filters - Configure filters to help block undesirable words, phrases, and profanity (exact match). Such words can include offensive terms, competitor names, etc.
  • Sensitive information filters - Configure filters to help block or mask sensitive information, such as personally identifiable information (PII), or custom regex in user inputs and model responses. Blocking or masking is done based on probabilistic detection of sensitive information in standard formats in entities such as SSN number, Date of Birth, address, etc. This also allows configuring regular expression based detection of patterns for identifiers.
  • Contextual grounding check - Help detect and filter hallucinations in model responses based on grounding in a source and relevance to the user query.

For more information, see How Amazon Bedrock Guardrails works .

Example:

 // The code below shows an example of how to instantiate this type.
 // The values are placeholders you should change.
 import software.amazon.awscdk.mixins.preview.mixins.*;
 import software.amazon.awscdk.mixins.preview.services.bedrock.mixins.*;
 CfnGuardrailPropsMixin cfnGuardrailPropsMixin = CfnGuardrailPropsMixin.Builder.create(CfnGuardrailMixinProps.builder()
         .automatedReasoningPolicyConfig(AutomatedReasoningPolicyConfigProperty.builder()
                 .confidenceThreshold(123)
                 .policies(List.of("policies"))
                 .build())
         .blockedInputMessaging("blockedInputMessaging")
         .blockedOutputsMessaging("blockedOutputsMessaging")
         .contentPolicyConfig(ContentPolicyConfigProperty.builder()
                 .contentFiltersTierConfig(ContentFiltersTierConfigProperty.builder()
                         .tierName("tierName")
                         .build())
                 .filtersConfig(List.of(ContentFilterConfigProperty.builder()
                         .inputAction("inputAction")
                         .inputEnabled(false)
                         .inputModalities(List.of("inputModalities"))
                         .inputStrength("inputStrength")
                         .outputAction("outputAction")
                         .outputEnabled(false)
                         .outputModalities(List.of("outputModalities"))
                         .outputStrength("outputStrength")
                         .type("type")
                         .build()))
                 .build())
         .contextualGroundingPolicyConfig(ContextualGroundingPolicyConfigProperty.builder()
                 .filtersConfig(List.of(ContextualGroundingFilterConfigProperty.builder()
                         .action("action")
                         .enabled(false)
                         .threshold(123)
                         .type("type")
                         .build()))
                 .build())
         .crossRegionConfig(GuardrailCrossRegionConfigProperty.builder()
                 .guardrailProfileArn("guardrailProfileArn")
                 .build())
         .description("description")
         .kmsKeyArn("kmsKeyArn")
         .name("name")
         .sensitiveInformationPolicyConfig(SensitiveInformationPolicyConfigProperty.builder()
                 .piiEntitiesConfig(List.of(PiiEntityConfigProperty.builder()
                         .action("action")
                         .inputAction("inputAction")
                         .inputEnabled(false)
                         .outputAction("outputAction")
                         .outputEnabled(false)
                         .type("type")
                         .build()))
                 .regexesConfig(List.of(RegexConfigProperty.builder()
                         .action("action")
                         .description("description")
                         .inputAction("inputAction")
                         .inputEnabled(false)
                         .name("name")
                         .outputAction("outputAction")
                         .outputEnabled(false)
                         .pattern("pattern")
                         .build()))
                 .build())
         .tags(List.of(CfnTag.builder()
                 .key("key")
                 .value("value")
                 .build()))
         .topicPolicyConfig(TopicPolicyConfigProperty.builder()
                 .topicsConfig(List.of(TopicConfigProperty.builder()
                         .definition("definition")
                         .examples(List.of("examples"))
                         .inputAction("inputAction")
                         .inputEnabled(false)
                         .name("name")
                         .outputAction("outputAction")
                         .outputEnabled(false)
                         .type("type")
                         .build()))
                 .topicsTierConfig(TopicsTierConfigProperty.builder()
                         .tierName("tierName")
                         .build())
                 .build())
         .wordPolicyConfig(WordPolicyConfigProperty.builder()
                 .managedWordListsConfig(List.of(ManagedWordsConfigProperty.builder()
                         .inputAction("inputAction")
                         .inputEnabled(false)
                         .outputAction("outputAction")
                         .outputEnabled(false)
                         .type("type")
                         .build()))
                 .wordsConfig(List.of(WordConfigProperty.builder()
                         .inputAction("inputAction")
                         .inputEnabled(false)
                         .outputAction("outputAction")
                         .outputEnabled(false)
                         .text("text")
                         .build()))
                 .build())
         .build())
 .strategy(PropertyMergeStrategy.OVERRIDE)
 .build();
 

See Also:
  • Field Details

    • CFN_PROPERTY_KEYS

      @Stability(Stable) protected static final List<String> CFN_PROPERTY_KEYS
  • Constructor Details

    • CfnGuardrailPropsMixin

      protected CfnGuardrailPropsMixin(software.amazon.jsii.JsiiObjectRef objRef)
    • CfnGuardrailPropsMixin

      protected CfnGuardrailPropsMixin(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • CfnGuardrailPropsMixin

      @Stability(Stable) public CfnGuardrailPropsMixin(@NotNull CfnGuardrailMixinProps props, @Nullable CfnPropertyMixinOptions options)
      Create a mixin to apply properties to AWS::Bedrock::Guardrail.

      Parameters:
      props - L1 properties to apply. This parameter is required.
      options - Mixin options.
    • CfnGuardrailPropsMixin

      @Stability(Stable) public CfnGuardrailPropsMixin(@NotNull CfnGuardrailMixinProps props)
      Create a mixin to apply properties to AWS::Bedrock::Guardrail.

      Parameters:
      props - L1 properties to apply. This parameter is required.
  • Method Details

    • applyTo

      @Stability(Stable) @NotNull public software.constructs.IConstruct applyTo(@NotNull software.constructs.IConstruct construct)
      Apply the mixin properties to the construct.

      Specified by:
      applyTo in interface IMixin
      Specified by:
      applyTo in class Mixin
      Parameters:
      construct - This parameter is required.
    • supports

      @Stability(Stable) @NotNull public Boolean supports(@NotNull software.constructs.IConstruct construct)
      Check if this mixin supports the given construct.

      Specified by:
      supports in interface IMixin
      Overrides:
      supports in class Mixin
      Parameters:
      construct - This parameter is required.
    • getProps

      @Stability(Stable) @NotNull protected CfnGuardrailMixinProps getProps()
    • getStrategy

      @Stability(Stable) @NotNull protected PropertyMergeStrategy getStrategy()