Lesson 3 of 5 Compliance, Auditing and AI Safeguards

Choosing Credentials for Accessing Foundation Models

This lesson explains how applications and tools authenticate to Amazon Bedrock with IAM credentials or Bedrock API keys, and how to select the appropriate credential type.

Learning outcomes

After completing this lesson, you will be able to:

  • Use temporary IAM credentials from roles.
  • Distinguish short-term and long-term Bedrock API keys.
  • Choose and control credentials for each caller.

IAM credentials

Bedrock API calls are normally signed with AWS Signature Version 4 using IAM credentials. The recommended form is temporary credentials from an IAM role: Lambda, ECS, EKS, EC2 and SageMaker AI workloads receive them automatically from their roles, and people use IAM Identity Center or federation. Temporary credentials expire and rotate automatically, and roles can be scoped to specific models, inference profiles and guardrails. Long-term IAM user access keys are discouraged.

Amazon Bedrock API keys

Bedrock API keys let tools and SDKs that expect a simple bearer token call Bedrock without SigV4 signing. Short-term API keys are generated from an existing identity's session, inherit its permissions, and last up to 12 hours or until the session ends, whichever comes first; they cannot be revoked individually, so revocation means acting on the identity. Long-term API keys are associated with an IAM user (a service-specific credential), have an expiry chosen at creation (from one day to no expiry), and each IAM user can have up to two for rotation. AWS recommends long-term keys only for exploration and development.

12hours

Longest life of a short-term Bedrock API key

Sort into groups

Which credential?

Exam skills 4.3.8

Choose the credential type for each caller of Amazon Bedrock.

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

Choosing and controlling credentials

Applications and tools need credentials to call foundation models, and the right type depends on where they run. Production workloads on AWS use IAM roles, which provide temporary credentials that rotate automatically. Short-term Bedrock API keys suit temporary access from tools that require a key. Long-term API keys should be used only where unavoidable, with short expiry, storage in AWS Secrets Manager, least-privilege permissions and monitoring of their use.

Administrators can restrict or block API keys with IAM conditions and service control policies, for example denying the creation of long-term keys or denying calls authenticated with them. The following table summarises the options.

CredentialLifetimeBest forCautions
IAM role temporary credentialsShort, auto-rotatedProduction workloadsScope role to needed models
Short-term Bedrock API keyUp to 12 hours or sessionTemporary tool accessInherits caller's permissions
Long-term Bedrock API keyChosen expiry, IAM userExploration, key-only toolsStore in Secrets Manager, rotate, restrict
IAM user access keysLong-livedAvoidLeak risk

The following diagram matches three callers of Amazon Bedrock to the credential that suits each.

The credential for each Bedrock caller. The production chatbot on ECS Fargate uses its task role's temporary credentials; an analyst's afternoon with a key-only notebook tool uses a short-term API key that expires with the session; and a legacy on-premises tool gets a long-term API key with 30-day expiry stored in Secrets Manager, confined to an account where an SCP allows it.
The scenario is illustrative.
True or false

Controlling Bedrock access

Exam skills 4.3.8 · 4.3.3

Check how access to Bedrock models is controlled.

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

Three callers

A company has three callers of Bedrock.

CallerCredentialReason
Production chatbot on ECS FargateTask IAM roleTemporary, rotated, no secrets to manage
Analyst trying a third-party notebook tool that only accepts an API key for one afternoonShort-term API keyExpires with the session
Legacy on-premises tool that only supports a static keyLong-term API key with 30-day expiry in Secrets ManagerNo alternative; limit exposure

An SCP prevents long-term keys in production accounts, so the exception is confined to a controlled account.

Check yourself

Which credentials should production workloads use to call Bedrock?

Show answer

IAM roles with temporary credentials. Long-term API keys are for exploration only.

Exam Tips

Remember for the exam

  • Production workloads: IAM roles with temporary credentials.
  • Short-term Bedrock API keys last up to 12 hours or the session and inherit permissions.
  • Long-term Bedrock API keys belong to an IAM user; use for exploration only.
  • Store any long-term key in Secrets Manager with short expiry.
  • Block or restrict API keys with IAM conditions and SCPs.