/eb-node-red

Node-RED for AWS Elastic Beanstalk

eb-node-red

Node-RED for AWS Elastic Beanstalk w/ or w/o reverse proxy.

Prerequired

Doing AWS tutorial

If you have not created EB yet I strongly recommend to do the followings tutorials first. AWS will create some roles include aws-elasticbeanstalk-ec2-role for EB automatically.

Getting Started Using Elastic Beanstalk - AWS Elastic Beanstalk

Add AWS S3 Full Access policy to aws-elasticbeanstalk-ec2-role

Login to the AWS Console on your browser, select Identity and Access Management (IAM) and add the AmazonS3FullAccess policy to the aws-elasticbeanstalk-ec2-role.

How to create Node-RED using Elastic Beanstalk

Clone project

First of all, you get eb-node-red project from github in your working directory.

$ git clone https://github.com/toconuts/eb-node-red.git
$ cd eb-node-red

Initialize git

$ git init

Setting Up the Application Settings

Defines the options if you required copy ./settings.js.dist, paste it name as ./settings.js then configure your settings for Node-RED.

$ cp settings.js.dist settings.js
  • awsRegion: region name to create eb-node-red.
  • awsS3Appname: application name usually used the same name as value of "name" key in ./package.json.
  • awsS3Bucket: bucket name to use. node-red-contrib-storage-s3 modules will create application name directory under this bucket.

Specifying reverse proxy

You can also choose a reverse proxy at ./.ebextensions/proxy.config

option_settings:
  aws:elasticbeanstalk:container:nodejs:
    ProxyServer: <nginx> | <apache> | <none>

Initialize Elastic Beanstalk environment

$ eb init

Create Elastic Beanstalk environment

$ eb create

Create command options

You can create a single instance, with option --single

$ eb create --single

You can create a instance in your vpc

$ eb create --vpc.id vpc-xxxxxx --vpc.ec2subnets subnet-xxxxx,subnet-xxxxx --vpc.publicip --vpc.elbpublic
  • --vpc.publicip: EC2 will be attached to public IP
  • --vpc.elbpublic: without this option, EC2 will be created internally

How to check routing

iptables (PREROUTING)

$ sudo iptables -t nat -S PREROUTING -v

Nginx configuration

If you choose nginx as proxy

$ cat /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf

Network statics

You can see listening ports of node and reverse proxy if you choose.

$ sudo netstat -anp

Environment variables

PORT variable will show you listening port.

$ sudo od -S1 -An /proc/$(ps aux | grep ^nodejs | perl -anlE 'say $F[1]' | tail -1)/environ