Using Amazon Credential Daemon with the Amazon CLI and Amazon SDKs
You can use Amazon Credential Daemon today with any Amazon CLI version and any Amazon SDK that supports the
credential_process setting in the shared Amazon config file. The Amazon CLI, the Amazon
SDKs, and tools built on them (such as Terraform and the Amazon CDK) run a command you specify to
get credentials. With Amazon Credential Daemon, that command is creds get. It returns short-lived
session credentials from the daemon, and keeps long-term keys and session tokens out of
~/.aws.
Topics
How it works
When a tool needs credentials for a profile that uses credential_process, the
following happens:
-
A tool needs credentials for a profile and finds
credential_processin that profile. -
The tool runs
creds get --credential.name--format credential-process -
Amazon Credential Daemon returns temporary credentials as JSON: an
ASIA...access key ID, a secret access key, a session token, and an expiration. The long-term secret (access key, refresh token, or private key) never leaves the daemon. -
The tool uses the credentials, and runs the command again before they expire.
Prerequisites
Before you configure a profile, confirm the following:
-
Amazon Credential Daemon is installed and running. To check, run
credsd status. For installation instructions, see Installing Amazon Credential Daemon. -
A credential is stored in Amazon Credential Daemon. To check, run
creds list. For example, to store an IAM Identity Center sign-in, run the following command.$creds bootstrap --credential work aws-idc-sso \ --start-url https://example.awsapps.com/start --sso-region us-east-1 \ --account-id 111122223333 --role-name Developer -
You know the full path to
creds. To find it, runcommand -v creds. A user-scoped macOS install puts it in~/.local/bin/creds; a Linux system install puts it in/usr/local/bin/creds.
Configure a profile that gets credentials from Amazon Credential Daemon
To configure a profile that gets credentials from Amazon Credential Daemon, complete the following steps:
-
Open the shared config file,
~/.aws/config. -
Add a profile whose
credential_processsetting runscreds get. Use the absolute path tocreds, because the tool that runs the command might not use your shell'sPATH.[profile work] region = us-east-1 credential_process = /Users/alice/.local/bin/creds get --credential work --format credential-process -
Remove anything for this profile that would take precedence over
credential_process:aws_access_key_idandaws_secret_access_keyin~/.aws/credentials, andAWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY, andAWS_SESSION_TOKENin your environment. The Amazon CLI and SDKs use those first. -
Test the profile. The output shows the role session that Amazon Credential Daemon served.
$aws sts get-caller-identity --profile work{ "UserId": "AROAEXAMPLEID:alice", "Account": "111122223333", "Arn": "arn:aws:sts::111122223333:assumed-role/Developer/alice" }
Examples
The following examples show how to use a credential_process profile with the
Amazon CLI, Amazon SDKs, and other tools.
Run the command yourself
To see what a tool receives, run the command directly.
$creds get --credential work --format credential-process{"Version":1,"AccessKeyId":"ASIAIOSFODNN7EXAMPLE","SecretAccessKey":"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY","SessionToken":"IQoJb3JpZ2luX2VjE...","Expiration":"2026-11-23T18:00:00Z"}
Use the profile with the Amazon CLI
Pass the profile with the --profile option.
$aws s3 ls --profile work
Or set the AWS_PROFILE environment variable.
$export AWS_PROFILE=work$aws s3 ls
Use the profile with an Amazon SDK
Any SDK that reads the shared config file picks up the profile. The following example uses the Amazon SDK for Python (Boto3).
import boto3 session = boto3.Session(profile_name="work") print(session.client("sts").get_caller_identity()["Arn"])
Some SDKs and tools select a profile from the environment, such as the Amazon SDK for
Java, the Amazon SDK for JavaScript, Terraform, and the Amazon CDK. For these, set the
AWS_PROFILE environment variable.
$export AWS_PROFILE=work$terraform plan
Use one sign-in for several roles
An IAM Identity Center credential can serve other account and role pairs that you
allowed when you stored it (--allow-role). Give each pair its own
profile.
[profile work-prod-readonly] region = us-east-1 credential_process = /Users/alice/.local/bin/creds get --credential work --account 444455556666 --role ReadOnly --format credential-process
Use credentials with a tool that doesn't read the Amazon config file
Export the credentials into the current shell instead. They are short-lived and stay only in that shell's environment.
$eval "$(creds get --credential work --format shell)"
Shell formats are also available for fish and PowerShell (--format fish,
--format powershell).
Give an AI coding agent its own profile
Store a separate credential for the agent, and point the agent's profile at it. Add
--agentic so that Amazon Credential Daemon records the caller as an agent in its audit
trail.
[profile agent] region = us-east-1 credential_process = /Users/alice/.local/bin/creds get --credential agent-ro --agentic --format credential-process
Considerations
Keep the following in mind when you use a credential_process profile with
Amazon Credential Daemon:
-
The command runs without a shell. Most SDKs split the
credential_processvalue into arguments and run it directly. Don't use pipes,~, or environment variables such as$HOMEin the value. Use full paths. -
Credentials refresh automatically. Tools run the command again shortly before the expiration, and Amazon Credential Daemon renews the session when it can. If a sign-in can no longer renew on its own (for example, an IAM Identity Center session that has ended), the command fails until you run
creds login --credential.name -
Errors reach the tool. If Amazon Credential Daemon can't serve credentials,
creds getexits with a non-zero status and prints the reason to standard error. The Amazon CLI or SDK includes that message in its error, for exampleError when retrieving credentials from custom-process: .... -
Removing or replacing a credential needs approval. Reading a credential with
creds getdoesn't. Operations that remove or replace stored credentials ask for Touch ID on macOS, orsudo creds request approveon Linux.id
Troubleshooting
The following table lists common messages, their causes, and how to fix them.
Message |
Cause |
Fix |
|---|---|---|
|
The tool couldn't find |
Use the absolute path from |
|
The profile name is wrong, or the tool isn't reading the config file. |
Check |
The caller identity isn't the role you expected. |
Keys in |
Remove them for this profile (step 3 of the procedure). |
|
The daemon isn't running. |
Run |
|
The stored sign-in has ended. |
Run |
|
No credential with that name is stored in the daemon. |
Run |