Subhasis Das
Subhasis Das

Reputation: 334

How to store environment variables on AWS EC2?

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

Answers (2)

Nir Alfasi
Nir Alfasi

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

AWS PS
AWS PS

Reputation: 4710

The best secure way is to use AWS system Manager

Rerference:

https://aws.amazon.com/blogs/mt/use-parameter-store-to-securely-access-secrets-and-config-data-in-aws-codedeploy/

Its secure and fully compatible with codedeploy

Upvotes: 3

Related Questions