Class CfnGuardrail
- All Implemented Interfaces:
IInspectable,IGuardrailRef,IEnvironmentAware,ITaggableV2,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
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:
import software.amazon.awscdk.services.bedrock.*;
// Import a guardrail created through the L1 CDK CfnGuardrail construct
CfnGuardrail l1guardrail = CfnGuardrail.Builder.create(this, "MyCfnGuardrail")
.blockedInputMessaging("blockedInputMessaging")
.blockedOutputsMessaging("blockedOutputsMessaging")
.name("namemycfnguardrails")
.wordPolicyConfig(WordPolicyConfigProperty.builder()
.wordsConfig(List.of(WordConfigProperty.builder()
.text("drugs")
.build()))
.build())
.build();
IGuardrail importedGuardrail = Guardrail.fromCfnGuardrail(l1guardrail);
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceConfiguration settings for integrating Automated Reasoning policies with Amazon Bedrock Guardrails.static final classA fluent builder forCfnGuardrail.static interfaceContains filter strengths for harmful content.static interfaceThe tier that your guardrail uses for content filters.static interfaceContains details about how to handle harmful content.static interfaceThe filter configuration details for the guardrails contextual grounding filter.static interfaceThe policy configuration details for the guardrails contextual grounding policy.static interfaceThe system-defined guardrail profile that you're using with your guardrail.static interfaceThe managed word list to configure for the guardrail.static interfaceThe PII entity to configure for the guardrail.static interfaceThe regular expression to configure for the guardrail.static interfaceContains details about PII entities and regular expressions to configure for the guardrail.static interfaceDetails about topics for the guardrail to identify and deny.static interfaceContains details about topics that the guardrail should identify and deny.static interfaceThe tier that your guardrail uses for denied topic filters.static interfaceA word to configure for the guardrail.static interfaceContains details about the word policy to configured for the guardrail.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.interfaces.bedrock.IGuardrailRef
IGuardrailRef.Jsii$Default, IGuardrailRef.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.ITaggableV2
ITaggableV2.Jsii$Default, ITaggableV2.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCfnGuardrail(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnGuardrail(software.amazon.jsii.JsiiObjectRef objRef) CfnGuardrail(software.constructs.Construct scope, String id, CfnGuardrailProps props) Create a newAWS::Bedrock::Guardrail. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringarnForGuardrail(IGuardrailRef resource) Timestamp.Appears if thestatusof the guardrail isFAILED.The ARN of the guardrail.The unique identifier of the guardrail.The status of the guardrail.Appears if thestatusisFAILED.Timestamp.The version of the guardrail that was created.Configuration settings for integrating Automated Reasoning policies with Amazon Bedrock Guardrails.The message to return when the guardrail blocks a prompt.The message to return when the guardrail blocks a model response.Tag Manager which manages the tags for this resource.The content filter policies to configure for the guardrail.Contextual grounding policy config for a guardrail.The system-defined guardrail profile that you're using with your guardrail.A description of the guardrail.A reference to a Guardrail resource.The ARN of the AWS key that you use to encrypt the guardrail.getName()The name of the guardrail.The sensitive information policy to configure for the guardrail.getTags()The tags that you want to attach to the guardrail.The topic policies to configure for the guardrail.The word policy you configure for the guardrail.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.static BooleanChecks whether the given object is a CfnGuardrail.renderProperties(Map<String, Object> props) voidConfiguration settings for integrating Automated Reasoning policies with Amazon Bedrock Guardrails.voidConfiguration settings for integrating Automated Reasoning policies with Amazon Bedrock Guardrails.voidsetBlockedInputMessaging(String value) The message to return when the guardrail blocks a prompt.voidsetBlockedOutputsMessaging(String value) The message to return when the guardrail blocks a model response.voidThe content filter policies to configure for the guardrail.voidThe content filter policies to configure for the guardrail.voidContextual grounding policy config for a guardrail.voidContextual grounding policy config for a guardrail.voidsetCrossRegionConfig(IResolvable value) The system-defined guardrail profile that you're using with your guardrail.voidThe system-defined guardrail profile that you're using with your guardrail.voidsetDescription(String value) A description of the guardrail.voidsetKmsKeyArn(String value) The ARN of the AWS key that you use to encrypt the guardrail.voidThe name of the guardrail.voidThe sensitive information policy to configure for the guardrail.voidThe sensitive information policy to configure for the guardrail.voidThe tags that you want to attach to the guardrail.voidsetTopicPolicyConfig(IResolvable value) The topic policies to configure for the guardrail.voidThe topic policies to configure for the guardrail.voidsetWordPolicyConfig(IResolvable value) The word policy you configure for the guardrail.voidThe word policy you configure for the guardrail.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getEnv, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validatePropertiesMethods inherited from class software.amazon.awscdk.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.constructs.Construct
getNode, isConstructMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.interfaces.IEnvironmentAware
getEnvMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnGuardrail
protected CfnGuardrail(software.amazon.jsii.JsiiObjectRef objRef) -
CfnGuardrail
protected CfnGuardrail(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnGuardrail
@Stability(Stable) public CfnGuardrail(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnGuardrailProps props) Create a newAWS::Bedrock::Guardrail.- Parameters:
scope- Scope in which this resource is defined. This parameter is required.id- Construct identifier for this resource (unique in its scope). This parameter is required.props- Resource properties. This parameter is required.
-
-
Method Details
-
arnForGuardrail
- Parameters:
resource- This parameter is required.
-
isCfnGuardrail
Checks whether the given object is a CfnGuardrail.- Parameters:
x- This parameter is required.
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspectin interfaceIInspectable- Parameters:
inspector- tree inspector to collect and process attributes. This parameter is required.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderPropertiesin classCfnResource- Parameters:
props- This parameter is required.
-
getAttrCreatedAt
Timestamp. -
getAttrFailureRecommendations
Appears if thestatusof the guardrail isFAILED.A list of recommendations to carry out before retrying the request.
-
getAttrGuardrailArn
The ARN of the guardrail. -
getAttrGuardrailId
The unique identifier of the guardrail. -
getAttrStatus
The status of the guardrail. -
getAttrStatusReasons
Appears if thestatusisFAILED.A list of reasons for why the guardrail failed to be created, updated, versioned, or deleted.
-
getAttrUpdatedAt
Timestamp. -
getAttrVersion
The version of the guardrail that was created.This value will always be
DRAFT. -
getCdkTagManager
Tag Manager which manages the tags for this resource.- Specified by:
getCdkTagManagerin interfaceITaggableV2
-
getCfnProperties
- Overrides:
getCfnPropertiesin classCfnResource
-
getGuardrailRef
A reference to a Guardrail resource.- Specified by:
getGuardrailRefin interfaceIGuardrailRef
-
getBlockedInputMessaging
The message to return when the guardrail blocks a prompt. -
setBlockedInputMessaging
The message to return when the guardrail blocks a prompt. -
getBlockedOutputsMessaging
The message to return when the guardrail blocks a model response. -
setBlockedOutputsMessaging
The message to return when the guardrail blocks a model response. -
getName
The name of the guardrail. -
setName
The name of the guardrail. -
getAutomatedReasoningPolicyConfig
Configuration settings for integrating Automated Reasoning policies with Amazon Bedrock Guardrails.Returns union: either
IResolvableorCfnGuardrail.AutomatedReasoningPolicyConfigProperty -
setAutomatedReasoningPolicyConfig
Configuration settings for integrating Automated Reasoning policies with Amazon Bedrock Guardrails. -
setAutomatedReasoningPolicyConfig
@Stability(Stable) public void setAutomatedReasoningPolicyConfig(@Nullable CfnGuardrail.AutomatedReasoningPolicyConfigProperty value) Configuration settings for integrating Automated Reasoning policies with Amazon Bedrock Guardrails. -
getContentPolicyConfig
The content filter policies to configure for the guardrail.Returns union: either
IResolvableorCfnGuardrail.ContentPolicyConfigProperty -
setContentPolicyConfig
The content filter policies to configure for the guardrail. -
setContentPolicyConfig
@Stability(Stable) public void setContentPolicyConfig(@Nullable CfnGuardrail.ContentPolicyConfigProperty value) The content filter policies to configure for the guardrail. -
getContextualGroundingPolicyConfig
Contextual grounding policy config for a guardrail.Returns union: either
IResolvableorCfnGuardrail.ContextualGroundingPolicyConfigProperty -
setContextualGroundingPolicyConfig
Contextual grounding policy config for a guardrail. -
setContextualGroundingPolicyConfig
@Stability(Stable) public void setContextualGroundingPolicyConfig(@Nullable CfnGuardrail.ContextualGroundingPolicyConfigProperty value) Contextual grounding policy config for a guardrail. -
getCrossRegionConfig
The system-defined guardrail profile that you're using with your guardrail.Returns union: either
IResolvableorCfnGuardrail.GuardrailCrossRegionConfigProperty -
setCrossRegionConfig
The system-defined guardrail profile that you're using with your guardrail. -
setCrossRegionConfig
@Stability(Stable) public void setCrossRegionConfig(@Nullable CfnGuardrail.GuardrailCrossRegionConfigProperty value) The system-defined guardrail profile that you're using with your guardrail. -
getDescription
A description of the guardrail. -
setDescription
A description of the guardrail. -
getKmsKeyArn
The ARN of the AWS key that you use to encrypt the guardrail. -
setKmsKeyArn
The ARN of the AWS key that you use to encrypt the guardrail. -
getSensitiveInformationPolicyConfig
The sensitive information policy to configure for the guardrail.Returns union: either
IResolvableorCfnGuardrail.SensitiveInformationPolicyConfigProperty -
setSensitiveInformationPolicyConfig
The sensitive information policy to configure for the guardrail. -
setSensitiveInformationPolicyConfig
@Stability(Stable) public void setSensitiveInformationPolicyConfig(@Nullable CfnGuardrail.SensitiveInformationPolicyConfigProperty value) The sensitive information policy to configure for the guardrail. -
getTags
The tags that you want to attach to the guardrail. -
setTags
The tags that you want to attach to the guardrail. -
getTopicPolicyConfig
The topic policies to configure for the guardrail.Returns union: either
IResolvableorCfnGuardrail.TopicPolicyConfigProperty -
setTopicPolicyConfig
The topic policies to configure for the guardrail. -
setTopicPolicyConfig
@Stability(Stable) public void setTopicPolicyConfig(@Nullable CfnGuardrail.TopicPolicyConfigProperty value) The topic policies to configure for the guardrail. -
getWordPolicyConfig
The word policy you configure for the guardrail.Returns union: either
IResolvableorCfnGuardrail.WordPolicyConfigProperty -
setWordPolicyConfig
The word policy you configure for the guardrail. -
setWordPolicyConfig
@Stability(Stable) public void setWordPolicyConfig(@Nullable CfnGuardrail.WordPolicyConfigProperty value) The word policy you configure for the guardrail.
-