Configuration & Usage
Detailed configuration, credential resolution order, caching, and runtime behavior for the bx-aws-secrets module.
This guide covers effective settings, credential source precedence, LocalStack support, and operational behavior for bx-aws-secrets.
๐ง Configuration Sources
Each setting is resolved independently in this order:
this.awsinApplication.bx(per-application)Module settings in
boxlang.json(global)AWS environment variables (where supported)
๐งฉ Application.bx (Per-App)
Use this.aws when each app needs isolated credentials or region-specific behavior.
class {
this.name = "myApp"
this.aws = {
region : "us-east-2",
accessKeyId : "${AWS_ACCESS_KEY_ID}",
secretAccessKey : "${AWS_SECRET_ACCESS_KEY}",
sessionToken : "",
cacheTTL : 300,
endpointOverride : ""
}
}When this.aws is present, the module creates and reuses a dedicated SecretsManagerClient for that application.
๐ Global boxlang.json Settings
๐ฑ Environment Variable Fallback
Supported environment mappings:
region
AWS_REGION, fallback AWS_DEFAULT_REGION
accessKeyId
AWS_ACCESS_KEY_ID
secretAccessKey
AWS_SECRET_ACCESS_KEY
sessionToken
AWS_SESSION_TOKEN
cacheTTL and endpointOverride are not sourced from environment variables by the module.
๐ Settings Reference
region
string
""
AWS region (required for secret resolution)
accessKeyId
string
""
AWS access key id
secretAccessKey
string
""
AWS secret access key
sessionToken
string
""
Optional temporary credentials token
cacheTTL
numeric
300
Cache time-to-live in seconds
endpointOverride
string
""
Custom endpoint (for example LocalStack)
๐ Usage Examples
Resolve a secret directly:
Resolve with a fallback value:
Use in datasource config:
๐ง Caching Behavior
Cache key format is
region:secretNameSuccessful secret fetches are cached in-memory
Expired entries are refreshed on next access
Set
cacheTTLto0for effectively no cache reuse
๐ Client Lifecycle
Per-app client: Used when
this.awsexistsGlobal client: Used when module settings provide region-based config
Env client: Used when relying only on AWS environment variables
Per-app clients are closed on application shutdown, and all clients are closed on module/runtime shutdown.
๐งช Local Development with LocalStack
Create a test secret:
๐จ Troubleshooting
Secret returns
null: verify region is resolved and secret name exists in AWS Secrets ManagerLicense errors: confirm
bx-plusis installed and licensed; for local testing, setBX_AWS_DEV=truePermission errors: ensure IAM policy includes
secretsmanager:GetSecretValueWrong module settings key: use
bxaws-secretsundermodulesinboxlang.json
Last updated
Was this helpful?
