Skip to main content

guardrails

Creates, updates, deletes, gets or lists a guardrails resource.

Overview

Nameguardrails
TypeResource
Idaws.bedrock.guardrails

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringThe name of the guardrail. (pattern: <code>[0-9a-zA-Z-_]+</code>)
automated_reasoning_policyobjectThe current Automated Reasoning policy configuration for the guardrail, if any is configured.
blocked_input_messagingstringThe message that the guardrail returns when it blocks a prompt.
blocked_outputs_messagingstringThe message that the guardrail returns when it blocks a model response.
content_policyobjectThe content policy that was configured for the guardrail.
contextual_grounding_policyobjectThe contextual grounding policy used in the guardrail.
created_atstring (date-time)The date and time at which the guardrail was created.
cross_region_detailsobjectDetails about the system-defined guardrail profile that you're using with your guardrail, including the guardrail profile ID and Amazon Resource Name (ARN).
descriptionstringThe description of the guardrail.
failure_recommendationsarrayAppears if the status of the guardrail is FAILED. A list of recommendations to carry out before retrying the request.
guardrail_arnstringThe ARN of the guardrail. (pattern: <code>arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:[0-9]{12}:guardrail/[a-z0-9]+</code>)
guardrail_idstringThe unique identifier of the guardrail. (pattern: <code>[a-z0-9]+</code>)
kms_key_arnstringThe ARN of the KMS key that encrypts the guardrail. (pattern: <code>arn:aws(-[^:]+)?:kms:[a-zA-Z0-9-]*:[0-9]{12}:key/[a-zA-Z0-9-]{36}</code>)
sensitive_information_policyobjectThe sensitive information policy that was configured for the guardrail.
statusstringThe status of the guardrail. (CREATING, UPDATING, VERSIONING, READY, FAILED, DELETING)
status_reasonsarrayAppears if the status is FAILED. A list of reasons for why the guardrail failed to be created, updated, versioned, or deleted.
topic_policyobjectThe topic policy that was configured for the guardrail.
updated_atstring (date-time)The date and time at which the guardrail was updated.
versionstringThe version of the guardrail. (pattern: <code>(([1-9][0-9]{0,7})|(DRAFT))</code>)
word_policyobjectThe word policy that was configured for the guardrail.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_guardrailselectguardrail_identifier, regionguardrailVersionGets details about a guardrail. If you don't specify a version, the response returns details for the DRAFT version.
list_guardrailsselectregionguardrailIdentifier, maxResults, nextTokenLists details about all the guardrails in an account. To list the DRAFT version of all your guardrails, don't specify the guardrailIdentifier field. To list all versions of a guardrail, specify the ARN of the guardrail in the guardrailIdentifier field. You can set the maximum number of results to return in a response in the maxResults field. If there are more results than the number you set, the response returns a nextToken that you can send in another ListGuardrails request to see the next batch of results.
create_guardrailinsertregion, name, blockedInputMessaging, blockedOutputsMessagingCreates a guardrail to block topics and to implement safeguards for your generative AI applications. You can configure the following policies in a guardrail to avoid undesirable and harmful content, filter out denied topics and words, and remove sensitive information for privacy protection. Content filters - Adjust filter strengths to block input prompts or model responses containing harmful content. Denied topics - Define a set of topics that are undesirable in the context of your application. These topics will be blocked if detected in user queries or model responses. Word filters - Configure filters to block undesirable words, phrases, and profanity. Such words can include offensive terms, competitor names etc. Sensitive information filters - Block or mask sensitive information such as personally identifiable information (PII) or custom regex in user inputs and model responses. In addition to the above policies, you can also configure the messages to be returned to the user if a user input or model response is in violation of the policies defined in the guardrail. For more information, see Amazon Bedrock Guardrails in the Amazon Bedrock User Guide.
create_guardrail_versioninsertguardrail_identifier, regionCreates a version of the guardrail. Use this API to create a snapshot of the guardrail when you are satisfied with a configuration, or to compare the configuration with another version.
update_guardrailupdateguardrail_identifier, region, name, blockedInputMessaging, blockedOutputsMessagingUpdates a guardrail with the values you specify. Specify a name and optional description. Specify messages for when the guardrail successfully blocks a prompt or a model response in the blockedInputMessaging and blockedOutputsMessaging fields. Specify topics for the guardrail to deny in the topicPolicyConfig object. Each GuardrailTopicConfig object in the topicsConfig list pertains to one topic. Give a name and description so that the guardrail can properly identify the topic. Specify DENY in the type field. (Optional) Provide up to five prompts that you would categorize as belonging to the topic in the examples list. Specify filter strengths for the harmful categories defined in Amazon Bedrock in the contentPolicyConfig object. Each GuardrailContentFilterConfig object in the filtersConfig list pertains to a harmful category. For more information, see Content filters. For more information about the fields in a content filter, see GuardrailContentFilterConfig. Specify the category in the type field. Specify the strength of the filter for prompts in the inputStrength field and for model responses in the strength field of the GuardrailContentFilterConfig. (Optional) For security, include the ARN of a KMS key in the kmsKeyId field.
delete_guardraildeleteguardrail_identifier, regionguardrailVersionDeletes a guardrail. To delete a guardrail, only specify the ARN of the guardrail in the guardrailIdentifier field. If you delete a guardrail, all of its versions will be deleted. To delete a version of a guardrail, specify the ARN of the guardrail in the guardrailIdentifier field and the version in the guardrailVersion field.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
guardrail_identifierstringThe unique identifier of the guardrail. This can be an ID or the ARN.
regionstringAWS region (default: us-east-1)
guardrailIdentifierstringThe unique identifier of the guardrail. This can be an ID or the ARN.
guardrailVersionstringThe version of the guardrail.
maxResultsintegerThe maximum number of results to return in the response.
nextTokenstringIf there are more results than were returned in the response, the response returns a nextToken that you can send in another ListGuardrails request to see the next batch of results.

SELECT examples

Gets details about a guardrail. If you don't specify a version, the response returns details for the DRAFT version.

SELECT
name,
automated_reasoning_policy,
blocked_input_messaging,
blocked_outputs_messaging,
content_policy,
contextual_grounding_policy,
created_at,
cross_region_details,
description,
failure_recommendations,
guardrail_arn,
guardrail_id,
kms_key_arn,
sensitive_information_policy,
status,
status_reasons,
topic_policy,
updated_at,
version,
word_policy
FROM aws.bedrock.guardrails
WHERE guardrail_identifier = '{{ guardrail_identifier }}' -- required
AND region = '{{ region }}' -- required
AND guardrailVersion = '{{ guardrailVersion }}'
;

INSERT examples

Creates a guardrail to block topics and to implement safeguards for your generative AI applications. You can configure the following policies in a guardrail to avoid undesirable and harmful content, filter out denied topics and words, and remove sensitive information for privacy protection. Content filters - Adjust filter strengths to block input prompts or model responses containing harmful content. Denied topics - Define a set of topics that are undesirable in the context of your application. These topics will be blocked if detected in user queries or model responses. Word filters - Configure filters to block undesirable words, phrases, and profanity. Such words can include offensive terms, competitor names etc. Sensitive information filters - Block or mask sensitive information such as personally identifiable information (PII) or custom regex in user inputs and model responses. In addition to the above policies, you can also configure the messages to be returned to the user if a user input or model response is in violation of the policies defined in the guardrail. For more information, see Amazon Bedrock Guardrails in the Amazon Bedrock User Guide.

INSERT INTO aws.bedrock.guardrails (
name,
description,
topicPolicyConfig,
contentPolicyConfig,
wordPolicyConfig,
sensitiveInformationPolicyConfig,
contextualGroundingPolicyConfig,
automatedReasoningPolicyConfig,
crossRegionConfig,
blockedInputMessaging,
blockedOutputsMessaging,
kmsKeyId,
tags,
clientRequestToken,
region
)
SELECT
'{{ name }}' /* required */,
'{{ description }}',
'{{ topicPolicyConfig }}',
'{{ contentPolicyConfig }}',
'{{ wordPolicyConfig }}',
'{{ sensitiveInformationPolicyConfig }}',
'{{ contextualGroundingPolicyConfig }}',
'{{ automatedReasoningPolicyConfig }}',
'{{ crossRegionConfig }}',
'{{ blockedInputMessaging }}' /* required */,
'{{ blockedOutputsMessaging }}' /* required */,
'{{ kmsKeyId }}',
'{{ tags }}',
'{{ clientRequestToken }}',
'{{ region }}'
RETURNING
created_at,
guardrail_arn,
guardrail_id,
version
;

UPDATE examples

Updates a guardrail with the values you specify. Specify a name and optional description. Specify messages for when the guardrail successfully blocks a prompt or a model response in the blockedInputMessaging and blockedOutputsMessaging fields. Specify topics for the guardrail to deny in the topicPolicyConfig object. Each GuardrailTopicConfig object in the topicsConfig list pertains to one topic. Give a name and description so that the guardrail can properly identify the topic. Specify DENY in the type field. (Optional) Provide up to five prompts that you would categorize as belonging to the topic in the examples list. Specify filter strengths for the harmful categories defined in Amazon Bedrock in the contentPolicyConfig object. Each GuardrailContentFilterConfig object in the filtersConfig list pertains to a harmful category. For more information, see Content filters. For more information about the fields in a content filter, see GuardrailContentFilterConfig. Specify the category in the type field. Specify the strength of the filter for prompts in the inputStrength field and for model responses in the strength field of the GuardrailContentFilterConfig. (Optional) For security, include the ARN of a KMS key in the kmsKeyId field.

UPDATE aws.bedrock.guardrails
SET
name = '{{ name }}',
description = '{{ description }}',
topicPolicyConfig = '{{ topicPolicyConfig }}',
contentPolicyConfig = '{{ contentPolicyConfig }}',
wordPolicyConfig = '{{ wordPolicyConfig }}',
sensitiveInformationPolicyConfig = '{{ sensitiveInformationPolicyConfig }}',
contextualGroundingPolicyConfig = '{{ contextualGroundingPolicyConfig }}',
automatedReasoningPolicyConfig = '{{ automatedReasoningPolicyConfig }}',
crossRegionConfig = '{{ crossRegionConfig }}',
blockedInputMessaging = '{{ blockedInputMessaging }}',
blockedOutputsMessaging = '{{ blockedOutputsMessaging }}',
kmsKeyId = '{{ kmsKeyId }}'
WHERE
guardrail_identifier = '{{ guardrail_identifier }}' --required
AND region = '{{ region }}' --required
AND name = '{{ name }}' --required
AND blockedInputMessaging = '{{ blockedInputMessaging }}' --required
AND blockedOutputsMessaging = '{{ blockedOutputsMessaging }}' --required
RETURNING
guardrail_arn,
guardrail_id,
updated_at,
version;

DELETE examples

Deletes a guardrail. To delete a guardrail, only specify the ARN of the guardrail in the guardrailIdentifier field. If you delete a guardrail, all of its versions will be deleted. To delete a version of a guardrail, specify the ARN of the guardrail in the guardrailIdentifier field and the version in the guardrailVersion field.

DELETE FROM aws.bedrock.guardrails
WHERE guardrail_identifier = '{{ guardrail_identifier }}' --required
AND region = '{{ region }}' --required
AND guardrailVersion = '{{ guardrailVersion }}'
;