Quick answer
Amazon Bedrock Guardrails only apply when a request specifies them, so any developer can call a model without one. To make guardrails mandatory, add the bedrock:GuardrailIdentifier condition key to the IAM policies of your application roles, allowing InvokeModel and InvokeModelWithResponseStream only when your approved guardrail and version are included. Requests without it are denied.
Key takeaways
- Guardrails are opt-in per request. A missing parameter means no protection, and no error.
- The bedrock:GuardrailIdentifier IAM condition key turns guardrails from a convention into an enforced control.
- Use an Allow with StringEquals for application roles, and optionally an explicit Deny for defense in depth.
- Always test the negative case: call a model without the guardrail and confirm you get AccessDenied.
Amazon Bedrock Guardrails are one of the strongest built-in AI safety controls in any cloud: prompt attack detection, content filters, denied topics, PII masking and contextual grounding checks in one place. But they have one big weakness. They only run when the request asks for them.
The problem: guardrails are opt-in
A guardrail is applied when an InvokeModel request includes a guardrail identifier and version, or when a Converse API request includes a guardrail configuration. If a developer forgets — or a test script, a new microservice or an attacker with stolen credentials simply leaves it out — the model responds without any guardrail. No error, no warning.
In most AWS accounts we audit, guardrails exist and are used by the main application, but nothing stops another workload from calling the same models without them.
The fix: the bedrock:GuardrailIdentifier condition key
Amazon Bedrock supports an IAM condition key, bedrock:GuardrailIdentifier, that exposes which guardrail a request specifies. You can use it to allow model invocation only when your approved guardrail is attached.
Pattern 1: scoped Allow for application roles
Attach this to the IAM role your application uses. Replace the model ARN, account ID and guardrail ID and version with your own.
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "InvokeOnlyWithApprovedGuardrail",
"Effect": "Allow",
"Action": [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream"
],
"Resource": "arn:aws:bedrock:us-east-1::foundation-model/APPROVED-MODEL-ID",
"Condition": {
"StringEquals": {
"bedrock:GuardrailIdentifier": "arn:aws:bedrock:us-east-1:111122223333:guardrail/GUARDRAIL-ID:1"
}
}
}]
}
Because the Allow only matches when the condition is true, requests without the guardrail — or with a different one — fall through to IAM's default implicit deny.
Pattern 2: explicit Deny for defense in depth
An Allow only works if no other policy grants broader Bedrock access — and in real accounts, something often does (AmazonBedrockFullAccess, an old admin policy, a permission boundary gap). An explicit Deny wins over any Allow:
{
"Sid": "DenyInvokeWithoutApprovedGuardrail",
"Effect": "Deny",
"Action": [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream"
],
"Resource": "*",
"Condition": {
"StringNotEquals": {
"bedrock:GuardrailIdentifier": "arn:aws:bedrock:us-east-1:111122223333:guardrail/GUARDRAIL-ID:1"
}
}
}
With StringNotEquals, a request that omits the guardrail entirely also matches, so it's denied. You can place this in the application role, a permissions boundary, or — to cover every workload — a service control policy, with exceptions for the roles that legitimately manage guardrails or run evaluations.
Test before you enforce organization-wide. An SCP mistake can break every Bedrock workload at once. Roll out to one account, confirm the positive and negative tests below, then expand.
Things to get right
- Pin the version. Including the version in the identifier means a guardrail edit can't silently weaken production. Publish a new version, test it, then update the policy.
- Cover streaming. Include
bedrock:InvokeModelWithResponseStreamas well asbedrock:InvokeModel. The Converse and ConverseStream APIs are authorized through these same actions. - Inference profiles. If you use cross-region inference profiles, your
Resourceneeds to include the inference profile ARN and the foundation model ARNs in each region of the profile. - Wrap untrusted content. Use guardrail input tags around retrieved documents and user-supplied content so the prompt attack filter evaluates them. See indirect prompt injection.
- Remember non-Bedrock models. For models hosted elsewhere, call the
ApplyGuardrailAPI on inputs and outputs. IAM can't force that, so verify it in code review.
How to test it
- Using the application role, call the model with the approved guardrail. It should succeed.
- Call the same model without a guardrail. You should get
AccessDeniedException. - Call with a different guardrail, or a different version. That should also be denied.
- Check CloudTrail for the denied calls, and alert on them. Repeated denials from one role usually mean a misconfigured service — or someone probing.
Guardrails are one layer, not the whole stack
Enforced guardrails stop a whole class of mistakes, but they don't replace least-privilege model access, permission-aware retrieval, PrivateLink endpoints or invocation logging. Our AWS secure AI deployment baseline covers the full set, and IAM-enforced guardrails are a required control in every CertiSafe AI audit of AWS.
Frequently asked questions
Are Amazon Bedrock Guardrails applied automatically?
No. A guardrail is only evaluated when the request includes a guardrail identifier and version — in the InvokeModel parameters or the Converse API's guardrail configuration. Without IAM enforcement, a request that omits it simply runs without a guardrail.
What does the bedrock:GuardrailIdentifier condition key do?
It lets an IAM policy check which guardrail a model invocation request specifies. You can allow model invocation only when a specific guardrail (and version) is included, so requests without the approved guardrail are denied.
Can Bedrock Guardrails protect models that aren't hosted on Bedrock?
Yes. The ApplyGuardrail API evaluates text against a guardrail without invoking a Bedrock model, so you can screen inputs and outputs for self-hosted models or other providers. IAM enforcement of invocation doesn't apply in that case, so your application must call ApplyGuardrail explicitly.
Get certified against the leaks covered in this article
CertiSafe AI tests your live AI features every quarter and gives you a verifiable stamp for your website.