Jhamar S.
Jhamar S.

Reputation: 71

Setting environment variables when deploying MEAN Stack app to AWS EC2

I'm deploying a project that I've been working on to AWS for the first time and everything that I've read, regarding deploying a MEAN stack app to ec2, states that you install the project via git repo. However I have environment variables for different API keys and my database string that I placed in my .gitignore file so I'm facing the issue of trying to set those environment variables so that my web application runs correctly. Does anyone have any idea how to go about this?

Upvotes: 1

Views: 389

Answers (1)

Brian Whicheloe
Brian Whicheloe

Reputation: 141

An EC2 instance is an entire virtual system. When you create a new EC2 instance, you will need to connect to it, git clone your project, install any necessary dependencies (NodeJS, NPM, etc.) and then start your application with any environment variables that you like.

You will want to use a tool like scp to upload any non version controlled files, like your database string, or create them on the instance with a text editor (Vim, nano, etc.)

You can create a startup script that does this when the instance is created, however if you are deploying the project for the first time on a new machine, I don't think this is the way you will want to go.

Upvotes: 2

Related Questions