Reputation: 334
I'm using dotenv to fetch and use environment variables from a .env file in my node app while running it locally. But this .env file can't be committed to github for security reasons. I'm using codepipeline and codedeploy to deploy the app continuously to ec2 but then the environment variables are missing on the ec2 instance server. How do I configure the environment variables for my node.js app in AWS EC2 (ubuntu AMI) ?
Upvotes: 2
Views: 5510
Reputation: 53525
Other than using AWS Systems Manager Parameter Store as mentioned in the accepted answer, there's also an option of using AWS Secrets Manager.
Both options require accessing the service from the application!
This also means that if you need an env-var for bootstrap, for example, on which port to run your server: you'll want your app to read $PORT
env var, then you should consider using user data.
Upvotes: 0
Reputation: 4710
The best secure way is to use AWS system Manager
Rerference:
Its secure and fully compatible with codedeploy
Upvotes: 3