ladderlore
Request a guide
  • Type a service name, like S3 or IAM.

Concept

Credential types for Bedrock

Production uses IAM roles. A Bedrock API key is a bearer token: short-term for tools, long-term for trying things out.

Runs on AWS compute?
IAM role
Quick test or tool?
Short-term key
Long-term key with expiry
yesnopreferredlast resort
Prefer roles, then short-term keys.
  • IAM role

    Lifetime
    Temporary, auto-renewed
    Use
    Production
  • Short-term API key

    Lifetime
    Up to 12 hours
    Use
    Short sessions and tools
  • Long-term API key

    Lifetime
    Until your expiry date
    Use
    Exploration only
Lifetime and use of each type.

What it is

The default credential for production is an IAM role. Code on EC2, ECS, EKS or Lambda gets temporary credentials from the role automatically and signs requests with them (Signature Version 4). People sign in through IAM Identity Center or a federated identity and also get temporary credentials. Nothing secret sits in the code, and credentials expire on their own.

What it is

Amazon Bedrock also accepts an API key, which is a bearer token sent in an Authorization header or in the AWS_BEARER_TOKEN_BEDROCK variable. It is simple, which helps for a quick test or a tool that cannot sign requests. A short-term key lasts up to 12 hours or until the session that made it ends, whichever is shorter, inherits the permissions of the identity that made it, and works only in the Region where it was created. AWS recommends it for production use, with a refresh before it expires. A long-term key creates an IAM user and lasts until the expiry date you set. AWS recommends long-term keys only for exploration.

What it is

Control keys with IAM. iam:CreateServiceSpecificCredential decides who can make long-term keys, and the condition key iam:ServiceSpecificCredentialAgeDays caps their lifetime. bedrock:CallWithBearerToken decides who can use a key, and bedrock:bearerTokenType picks short-term or long-term. A Deny on CallWithBearerToken blocks keys entirely. For rotation, set an expiry and replace keys before they expire. If a long-term key leaks, deactivate, reset or delete it. A short-term key cannot be deactivated. Invalidate the session that made it, or deny bedrock:CallWithBearerToken.

What it is

Store any key you must keep in AWS Secrets Manager, with scheduled rotation, and read it at run time. CloudTrail logs the API calls, but the key itself is not logged.

Remember

  • Production: IAM role with temporary credentials.
  • Short-term API key: up to 12 hours, Region-bound, inherits the creator’s permissions.
  • Long-term API key: an IAM user with an expiry date. Exploration only.
  • Limit keys with iam:CreateServiceSpecificCredential and bedrock:CallWithBearerToken.

Remember

  • Rotate by expiry and replacement. Long-term leak: deactivate or reset. Short-term leak: end the session or deny CallWithBearerToken.
  • Keep keys in Secrets Manager, not in code.

On the exam

  • “Application on Lambda calls Bedrock” points to the Lambda execution role, not an API key.
  • “Developer tests a model quickly from a script” points to a short-term API key, or long-term with a short expiry.
  • “Stop anyone using long-lived Bedrock keys” points to a policy that limits or denies key creation and use.
  • “Key must be stored and rotated” points to AWS Secrets Manager.