Prerequisites
Before configuring Mage:- Create a secret in AWS Secrets Manager in the Region Mage will use.
- Grant the IAM role or user running Mage permission to call
secretsmanager:GetSecretValuefor the required secrets. - If a secret uses a customer-managed KMS key, also grant
kms:Decryptfor that key.
Configure AWS authentication
Mage checks environment variables first, then built-in Mage secrets with the same credential names. When no explicit access keys are configured, the underlying AWS SDK uses its default provider chain. In AWS, prefer an IAM role attached to the Mage workload so that you do not need long-lived access keys. When a workload role is not available, set the following environment variables on every Mage process that renders templates containing AWS secret references:
These values may be provided as protected deployment environment variables. Mage also checks its built-in secret store for variables with these exact names, but that bootstrapping option requires Mage’s secret database to be available before the AWS client is created.
Do not place literal AWS credentials in
io_config.yaml, pipeline code, or version control.
Reference a secret
Useaws_secret_var anywhere Mage template variables are supported:
aws_secret_var returns the complete SecretString. If the AWS secret contains JSON, extract the field you need with json_value:
SecretString rather than SecretBinary.
Cache behavior and rotation
Mage uses the AWS Secrets Manager caching client and its library-managed refresh interval for normalaws_secret_var lookups. A rotated value is not guaranteed to appear immediately. Bypass the cache for a lookup with:
GetSecretValue directly and increases AWS API traffic. Existing database connections and clients can continue using an older credential until they are recreated.
Troubleshooting
Access denied
Confirm the active IAM identity can callsecretsmanager:GetSecretValue on the requested secret. For a customer-managed KMS key, also confirm it can call kms:Decrypt. Check both the IAM policy and any resource-based policy on the secret.
Secret not found
Verify the secret name or ARN and the configured Region. Mage usesAWS_REGION_NAME, then AWS_DEFAULT_REGION, and otherwise us-west-2. If the secret is in another account, use a full ARN and ensure the secret policy permits the Mage identity.
Invalid secret identifier
Confirm that the value passed toaws_secret_var is a valid secret name or ARN. Mage reports invalid AWS parameters separately from missing secrets.
Invalid credentials or expired token
For access-key authentication, confirm the access key and secret key belong together. Temporary credentials also require a currentAWS_SESSION_TOKEN. Prefer a workload IAM role to avoid manually rotating these credentials.
JSON secret renders as one string
aws_secret_var returns the full secret string. Use json_value(aws_secret_var('secret-name'), 'field') to select a value from a JSON object.
Security recommendations
- Prefer workload IAM roles over long-lived access keys.
- Grant
secretsmanager:GetSecretValueonly for the secrets Mage requires. - Use separate roles and secret paths for development, staging, and production.
- Enable AWS Secrets Manager rotation where supported by the downstream service.
- Avoid logging rendered configuration or secret values.
- Audit access with AWS CloudTrail.