Lesson 2 of 4 Secure Access, GenAI Gateways and CI/CD

Writing Least-Privilege Policies for Amazon Bedrock

This lesson covers Bedrock permissions and condition keys, which decide which principals can invoke which models, use which knowledge bases and change which guardrails.

Learning outcomes

After completing this lesson, you will be able to:

  • Identify the IAM actions and resources for each Bedrock operation.
  • Enforce guardrails with bedrock:GuardrailIdentifier and organisation policies.
  • Choose credentials for FM access, including Bedrock API keys.

Actions and resources

Least privilege for Amazon Bedrock starts with knowing which IAM actions each operation needs. Invoking a model uses bedrock:InvokeModel, which also covers the Converse API, and bedrock:InvokeModelWithResponseStream, which also covers ConverseStream. Knowledge bases use bedrock:Retrieve and bedrock:RetrieveAndGenerate on knowledge base ARNs, and agents use bedrock:InvokeAgent on agent alias ARNs.

These actions can be limited to specific resources: foundation model ARNs, in the form arn:aws:bedrock:REGION::foundation-model/MODEL_ID, inference profile ARNs, provisioned model ARNs, custom model ARNs and prompt ARNs. When a request uses a cross-Region inference profile, the policy must allow both the profile and the foundation model in each Region the profile can route to. A least privilege policy lists only the actions and specific ARNs a role needs, never bedrock:* on all resources, as the following policy shows.

{
  "Version": "2012-10-17",
  "Statement": [
    {"Sid": "InvokeApprovedModelsViaEUProfile",
     "Effect": "Allow",
     "Action": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"],
     "Resource": [
       "arn:aws:bedrock:eu-central-1:111122223333:inference-profile/eu.amazon.nova-pro-v1:0",
       "arn:aws:bedrock:eu-*::foundation-model/amazon.nova-pro-v1:0"]},
    {"Sid": "RequireApprovedGuardrail",
     "Effect": "Deny",
     "Action": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"],
     "Resource": "*",
     "Condition": {"StringNotEquals": {"bedrock:GuardrailIdentifier": "arn:aws:bedrock:eu-central-1:111122223333:guardrail/gr-abc123:4"}}}
  ]
}
Select all that apply

A least-privilege Bedrock policy

Exam skills 2.3.3

A role calls one approved model with Converse and ConverseStream through an EU cross-Region inference profile. Choose what its policy must allow.

Log in to try this activity Interactive activities are free with an account.

Condition keys and organisation controls

Condition keys refine permissions beyond actions and resources. bedrock:GuardrailIdentifier can require that every invocation applies a specific guardrail, and a specific version of it, which enforces safety policy through IAM instead of trusting each application to remember it. Global condition keys add further limits: aws:SourceVpce requires calls to arrive through a specific VPC endpoint, aws:RequestedRegion limits the Regions that may be used, and aws:PrincipalTag or resource tags implement attribute-based access control (ABAC), where access follows tags such as a team or project.

At the organisation level, service control policies in AWS Organizations can deny unapproved models in every account, whatever individual IAM policies allow, and permissions boundaries cap the permissions of roles that developers create themselves.

IAM Access Analyzer validates policies, finds resources shared outside the account and generates least privilege policies from CloudTrail activity, which helps tighten broad policies used during development.

The following diagram shows an IAM deny statement deciding two model calls, one with the approved guardrail and one without.

Enforcing the corporate guardrail with IAM. An IAM policy or SCP statement denies InvokeModel and InvokeModelWithResponseStream unless bedrock:GuardrailIdentifier matches the approved guardrail ARN, so calls that pass the guardrail succeed and calls without it fail with AccessDeniedException.
The condition can also require a specific guardrail version.
Match the pairs

Controls for Bedrock access

Exam skills 2.3.3 · 3.2.1

Match each requirement with the IAM or organisation control that enforces it.

Log in to try this activity Interactive activities are free with an account.

Credentials for FM access

Applications running on AWS should call Bedrock with IAM roles, which provide temporary credentials that rotate automatically. Amazon Bedrock API keys offer an alternative bearer-token form of access for tools that cannot sign requests. Short-term keys, derived from an IAM session, expire with that session and suit temporary use. Long-term keys are tied to an IAM user and suit only exploration, because a leaked long-term key remains valid until someone revokes it. Organisations can restrict or disable API key use with IAM and SCP conditions.

When a gateway also calls models from third-party providers, their API keys belong in AWS Secrets Manager, with rotation configured, and are retrieved at run time rather than stored in code or configuration. The following table summarises the controls.

ControlEnforces
Specific model and profile ARNsOnly approved models can be invoked
bedrock:GuardrailIdentifier conditionEvery invocation uses an approved guardrail
aws:SourceVpce conditionCalls only through a private endpoint
SCPsOrganization-wide model and Region restrictions
Permissions boundariesMaximum permissions for developer-created roles
IAM Access AnalyzerPolicy validation and least privilege generation
Worked example

Enforcing guardrails everywhere

A security team requires that all model invocations in production accounts apply the corporate guardrail. Some teams forget to pass it.

Checking application code cannot guarantee compliance. An IAM policy or SCP statement that denies InvokeModel and InvokeModelWithResponseStream unless bedrock:GuardrailIdentifier matches the approved guardrail ARN enforces it: calls without the guardrail fail with AccessDeniedException.

Check yourself

Does bedrock:InvokeModel permission allow streaming responses?

Show answer

No. Streaming needs bedrock:InvokeModelWithResponseStream. InvokeModel also covers Converse.

Exam Tips

Remember for the exam

  • InvokeModel permission covers Converse; streaming needs InvokeModelWithResponseStream.
  • Scope permissions to specific model, inference profile and knowledge base ARNs.
  • Enforce guardrails through IAM with the bedrock:GuardrailIdentifier condition key.
  • Restrict models and Regions organization-wide with SCPs.