guardrails
Creates, updates, deletes, gets or lists a guardrails resource.
Overview
| Name | guardrails |
| Type | Resource |
| Id | aws.bedrock.guardrails |
Fields
The following fields are returned by SELECT queries:
- get_guardrail
- list_guardrails
| Name | Datatype | Description |
|---|---|---|
name | string | The name of the guardrail. (pattern: <code>[0-9a-zA-Z-_]+</code>) |
automated_reasoning_policy | object | The current Automated Reasoning policy configuration for the guardrail, if any is configured. |
blocked_input_messaging | string | The message that the guardrail returns when it blocks a prompt. |
blocked_outputs_messaging | string | The message that the guardrail returns when it blocks a model response. |
content_policy | object | The content policy that was configured for the guardrail. |
contextual_grounding_policy | object | The contextual grounding policy used in the guardrail. |
created_at | string (date-time) | The date and time at which the guardrail was created. |
cross_region_details | object | Details about the system-defined guardrail profile that you're using with your guardrail, including the guardrail profile ID and Amazon Resource Name (ARN). |
description | string | The description of the guardrail. |
failure_recommendations | array | Appears if the status of the guardrail is FAILED. A list of recommendations to carry out before retrying the request. |
guardrail_arn | string | The ARN of the guardrail. (pattern: <code>arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:[0-9]{12}:guardrail/[a-z0-9]+</code>) |
guardrail_id | string | The unique identifier of the guardrail. (pattern: <code>[a-z0-9]+</code>) |
kms_key_arn | string | The 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_policy | object | The sensitive information policy that was configured for the guardrail. |
status | string | The status of the guardrail. (CREATING, UPDATING, VERSIONING, READY, FAILED, DELETING) |
status_reasons | array | Appears if the status is FAILED. A list of reasons for why the guardrail failed to be created, updated, versioned, or deleted. |
topic_policy | object | The topic policy that was configured for the guardrail. |
updated_at | string (date-time) | The date and time at which the guardrail was updated. |
version | string | The version of the guardrail. (pattern: <code>(([1-9][0-9]{0,7})|(DRAFT))</code>) |
word_policy | object | The word policy that was configured for the guardrail. |
| Name | Datatype | Description |
|---|---|---|
id | string | The unique identifier of the guardrail. (pattern: <code>[a-z0-9]+</code>) |
name | string | The name of the guardrail. (pattern: <code>[0-9a-zA-Z-_]+</code>) |
arn | string | The ARN of the guardrail. (pattern: <code>arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:[0-9]{12}:guardrail/[a-z0-9]+</code>) |
created_at | string (date-time) | The date and time at which the guardrail was created. |
cross_region_details | object | Details about the system-defined guardrail profile that you're using with your guardrail, including the guardrail profile ID and Amazon Resource Name (ARN). |
description | string | A description of the guardrail. |
status | string | The status of the guardrail. (CREATING, UPDATING, VERSIONING, READY, FAILED, DELETING) |
updated_at | string (date-time) | The date and time at which the guardrail was last updated. |
version | string | The version of the guardrail. (pattern: <code>(([1-9][0-9]{0,7})|(DRAFT))</code>) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_guardrail | select | guardrail_identifier, region | guardrailVersion | Gets details about a guardrail. If you don't specify a version, the response returns details for the DRAFT version. |
list_guardrails | select | region | guardrailIdentifier, maxResults, nextToken | Lists 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_guardrail | insert | region, name, blockedInputMessaging, blockedOutputsMessaging | 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. | |
create_guardrail_version | insert | guardrail_identifier, region | Creates 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_guardrail | update | guardrail_identifier, region, name, blockedInputMessaging, blockedOutputsMessaging | 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. | |
delete_guardrail | delete | guardrail_identifier, region | guardrailVersion | 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. |
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.
| Name | Datatype | Description |
|---|---|---|
guardrail_identifier | string | The unique identifier of the guardrail. This can be an ID or the ARN. |
region | string | AWS region (default: us-east-1) |
guardrailIdentifier | string | The unique identifier of the guardrail. This can be an ID or the ARN. |
guardrailVersion | string | The version of the guardrail. |
maxResults | integer | The maximum number of results to return in the response. |
nextToken | string | If 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
- get_guardrail
- list_guardrails
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 }}'
;
Lists 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.
SELECT
id,
name,
arn,
created_at,
cross_region_details,
description,
status,
updated_at,
version
FROM aws.bedrock.guardrails
WHERE region = '{{ region }}' -- required
AND guardrailIdentifier = '{{ guardrailIdentifier }}'
AND maxResults = '{{ maxResults }}'
AND nextToken = '{{ nextToken }}'
;
INSERT examples
- create_guardrail
- create_guardrail_version
- Manifest
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
;
Creates 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.
INSERT INTO aws.bedrock.guardrails (
description,
clientRequestToken,
guardrail_identifier,
region
)
SELECT
'{{ description }}',
'{{ clientRequestToken }}',
'{{ guardrail_identifier }}',
'{{ region }}'
RETURNING
guardrail_id,
version
;
# Description fields are for documentation purposes
- name: guardrails
props:
- name: region
value: "{{ region }}"
description: Required parameter for the guardrails resource.
- name: guardrail_identifier
value: "{{ guardrail_identifier }}"
description: Required parameter for the guardrails resource.
- name: name
value: "{{ name }}"
- name: description
value: "{{ description }}"
- name: topicPolicyConfig
description: |
Contains details about topics that the guardrail should identify and deny.
value:
topicsConfig:
- name: "{{ name }}"
definition: "{{ definition }}"
examples: "{{ examples }}"
type_: "{{ type_ }}"
inputAction: "{{ inputAction }}"
outputAction: "{{ outputAction }}"
inputEnabled: {{ inputEnabled }}
outputEnabled: {{ outputEnabled }}
tierConfig:
tierName: "{{ tierName }}"
- name: contentPolicyConfig
description: |
Contains details about how to handle harmful content.
value:
filtersConfig:
- type_: "{{ type_ }}"
inputStrength: "{{ inputStrength }}"
outputStrength: "{{ outputStrength }}"
inputModalities: "{{ inputModalities }}"
outputModalities: "{{ outputModalities }}"
inputAction: "{{ inputAction }}"
outputAction: "{{ outputAction }}"
inputEnabled: {{ inputEnabled }}
outputEnabled: {{ outputEnabled }}
tierConfig:
tierName: "{{ tierName }}"
- name: wordPolicyConfig
description: |
Contains details about the word policy to configured for the guardrail.
value:
wordsConfig:
- text: "{{ text }}"
inputAction: "{{ inputAction }}"
outputAction: "{{ outputAction }}"
inputEnabled: {{ inputEnabled }}
outputEnabled: {{ outputEnabled }}
managedWordListsConfig:
- type_: "{{ type_ }}"
inputAction: "{{ inputAction }}"
outputAction: "{{ outputAction }}"
inputEnabled: {{ inputEnabled }}
outputEnabled: {{ outputEnabled }}
- name: sensitiveInformationPolicyConfig
description: |
Contains details about PII entities and regular expressions to configure for the guardrail.
value:
piiEntitiesConfig:
- type_: "{{ type_ }}"
action: "{{ action }}"
inputAction: "{{ inputAction }}"
outputAction: "{{ outputAction }}"
inputEnabled: {{ inputEnabled }}
outputEnabled: {{ outputEnabled }}
regexesConfig:
- name: "{{ name }}"
description: "{{ description }}"
pattern_: "{{ pattern_ }}"
action: "{{ action }}"
inputAction: "{{ inputAction }}"
outputAction: "{{ outputAction }}"
inputEnabled: {{ inputEnabled }}
outputEnabled: {{ outputEnabled }}
- name: contextualGroundingPolicyConfig
description: |
The policy configuration details for the guardrails contextual grounding policy.
value:
filtersConfig:
- type_: "{{ type_ }}"
threshold: {{ threshold }}
action: "{{ action }}"
enabled: {{ enabled }}
- name: automatedReasoningPolicyConfig
description: |
Configuration settings for integrating Automated Reasoning policies with Amazon Bedrock Guardrails.
value:
policies:
- "{{ policies }}"
confidenceThreshold: {{ confidenceThreshold }}
- name: crossRegionConfig
description: |
The system-defined guardrail profile that you're using with your guardrail. Guardrail profiles define the destination Amazon Web Services Regions where guardrail inference requests can be automatically routed. Using guardrail profiles helps maintain guardrail performance and reliability when demand increases. For more information, see the Amazon Bedrock User Guide.
value:
guardrailProfileIdentifier: "{{ guardrailProfileIdentifier }}"
- name: blockedInputMessaging
value: "{{ blockedInputMessaging }}"
- name: blockedOutputsMessaging
value: "{{ blockedOutputsMessaging }}"
- name: kmsKeyId
value: "{{ kmsKeyId }}"
- name: tags
value:
- key: "{{ key }}"
value: "{{ value }}"
- name: clientRequestToken
value: "{{ clientRequestToken }}"
UPDATE examples
- update_guardrail
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
- delete_guardrail
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 }}'
;