Skip to content

Sample NodeJS server that will be deployed to AWS EC2

Notifications You must be signed in to change notification settings

bsgrigorov/ec2_node_server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Setup

Setup environment variables

Create env.bat/.sh file and fill in all the variables

@set AWS_ACCESS_KEY_ID=
@set AWS_SECRET_ACCESS_KEY=
@set AWS_DEFAULT_REGION=us-west-2
@set TF_VAR_aws_private_key_file_path=.\\aws_key.pem
@set TF_VAR_ec2_user="ec2-user"

Create aws_key.pem file in the top level directory of the project and add your private key that you will be using to connect to the ec2 instance with. Make sure your key is added to your key pairs in the ec2 instances page of your AWS account.

Running terraform

Install terraform

Run:

env.bat
terraform init
terraform plan
terraform apply

Running the node server

Install docker Start docker vm

docker-machine start
docker-machine env

Build and run the docker container

docker build -t ec2server .
docker run -d -p 8080:8080 --name=ec2server ec2server

The docker machine runs on 192.168.99.100 so you can hit the server like this

curl 192.168.99.100:8080

About

Sample NodeJS server that will be deployed to AWS EC2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published