- Newest
- Most votes
- Most comments
This is now supported natively. Elastic Beanstalk platform versions released on or after March 26, 2025 can resolve Secrets Manager secrets (and Parameter Store parameters) during instance bootstrapping and expose the resolved value as an application environment variable. On the supported Docker platform, the application in the container can read that variable normally, so you do not need to create or copy a .env file.
For a JSON secret containing username and password, a current platform version can map the individual top-level keys in an .ebextensions file:
# .ebextensions/environment-secrets.config option_settings: aws:elasticbeanstalk:application:environmentsecrets: DOCDB_USERNAME: arn:aws:secretsmanager:us-east-1:111122223333:secret:docdb-AbCd12:username DOCDB_PASSWORD: arn:aws:secretsmanager:us-east-1:111122223333:secret:docdb-AbCd12:password
Replace those example ARNs with the full ARN of your secret. JSON-key extraction requires a platform version released on or after January 13, 2026. On an earlier supported version, map the whole secret to one environment variable and parse the JSON in the Node.js application, or upgrade the platform first.
The important permission boundary is the Elastic Beanstalk environment's EC2 instance profile role, not the role used by the deployment client. Grant that role secretsmanager:GetSecretValue only for the required secret ARN. Add kms:Decrypt for the KMS key only when the secret uses a customer-managed key. Do not put the secret value in Dockerrun.aws.json, the source bundle, or an .env file.
One operational detail is easy to miss: rotation does not automatically update the value in already-running application processes. Elastic Beanstalk fetches it during instance bootstrapping. After rotation, trigger UpdateEnvironment or RestartAppServer to refresh the environment, and make the application tolerate old and new database credentials during a rolling refresh or scale-out.
Official references:
answered a month ago
Relevant content
asked a year ago
