Skip to content
AWS Credentials

AWS Credentials

Overview

PyBritive provides four ways to deliver temporary AWS credentials to your tooling. Each mode suits a different workflow — from one-off terminal sessions to fully automated CLI integrations.

What you’ll learn:

  • How to export AWS credentials as environment variables
  • How to write credentials directly to the AWS credentials file
  • How to configure credential_process so the AWS CLI fetches credentials automatically
  • How to open the AWS console using temporary programmatic credentials
  • How to auto-renew credentials before they expire

Before You Begin

  • PyBritive installed and authenticated — see Getting Started
  • AWS CLI installed — run aws --version to check
  • At least one AWS profile available for checkout — see Listing Your Access

Note: Profile names in this tutorial are from the Britive demo tenant. Replace them with your own profile names from pybritive ls profiles.

Get AWS Credentials

Export credentials as environment variables

The env mode outputs temporary AWS credentials as shell export statements. Use eval to load them directly into your current terminal session.

Linux/macOS:

eval $(pybritive checkout "AWS SE Organization/696226360299 (se-demo)/S3 Bucket Admin" --mode env)

Verify the credentials are active:

aws sts get-caller-identity

Windows Command Prompt:

pybritive checkout "AWS SE Organization/696226360299 (se-demo)/S3 Bucket Admin" --mode env-wincmd

Windows PowerShell:

pybritive checkout "AWS SE Organization/696226360299 (se-demo)/S3 Bucket Admin" --mode env-winps

Credentials set via environment variables are active only for the current terminal session. Close the terminal or check in to remove them.

Write credentials to the AWS credentials file

The integrate mode writes temporary credentials directly to ~/.aws/credentials, making them available to the AWS CLI and any tool that reads the standard credentials file.

pybritive checkout "AWS SE Organization/696226360299 (se-demo)/S3 Bucket Admin" --mode integrate

To write to a non-default credentials file:

pybritive checkout "AWS SE Organization/696226360299 (se-demo)/S3 Bucket Admin" --mode integrate \
  --aws-credentials-file ~/.aws/credentials-britive

Verify the credentials were written:

aws sts get-caller-identity

Configure credential_process for automatic credentials

credential_process is an AWS CLI feature that delegates credential fetching to an external command. Configuring PyBritive as your credential_process means the AWS CLI automatically calls PyBritive to retrieve fresh credentials whenever it needs them — no manual checkout required.

Set up a profile alias

First create an alias for the profile you want to automate. Aliases reduce latency and simplify the config entry:

pybritive checkout "AWS SE Organization/696226360299 (se-demo)/S3 Bucket Admin" --alias s3-admin

Configure ~/.aws/config

Add a profile entry to ~/.aws/config using pybritive-aws-cred-process (a lightweight helper that reduces credential retrieval latency by approximately 50%):

[profile s3-admin]
credential_process=pybritive-aws-cred-process --profile s3-admin
region=us-east-1

You can also use the full profile path instead of an alias:

[profile s3-admin]
credential_process=pybritive-aws-cred-process --profile "AWS SE Organization/696226360299 (se-demo)/S3 Bucket Admin"
region=us-east-1

Use the profile

Any AWS CLI command that references this profile will automatically fetch fresh credentials from Britive:

aws s3 ls --profile s3-admin

You can also set it as your default profile for the session:

export AWS_PROFILE=s3-admin
aws s3 ls

Check out console access

The console mode checks out console access for the profile rather than programmatic credentials. Once checked out, the console button becomes available in the Britive UI where you can click it to launch the AWS console.

pybritive checkout "AWS SE Organization/696226360299 (se-demo)/S3 Bucket Admin" --mode console

To launch the AWS console, log in to the Britive UI, navigate to your checked out profiles, and click the console button.

When you are done, check in the console access:

pybritive checkin "AWS SE Organization/696226360299 (se-demo)/S3 Bucket Admin" --console

Auto-renew expiring credentials

The --force-renew flag checks whether your current credentials expire within a specified number of minutes. If they do, PyBritive automatically checks in and issues fresh credentials.

pybritive checkout s3-admin --mode integrate --force-renew 15

This is useful in long-running scripts where you want to ensure credentials remain valid without manual intervention.

Troubleshoot

SymptomCauseFix
aws: command not foundAWS CLI not installedInstall the AWS CLI before using these modes
Unable to locate credentialsenv variables not loadedUse eval $(pybritive checkout ... --mode env) not just printing them
credential_process returns no credentialsAlias not foundRe-run the checkout with --alias to recreate the alias
Console opens but shows access deniedProfile lacks console permissionsContact your Britive administrator
Credentials expire mid-script--force-renew not setAdd --force-renew 15 to your checkout command
ValueError: no checked out profile foundSession already expired or previously checked inThe profile is no longer active — run pybritive checkout again to start a new session

Next Steps

Last updated on