Skip to content

To automatically add new ec2 instances to nginx upstream server

Notifications You must be signed in to change notification settings

singhupendra/aws-autoscale

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aws-autoscale

To automatically add/remove new ec2 instances to nginx upstream server and avoid ELB.This script checks the health of the new instance prior adding the it to the load balancer.

Requirements

You need to perform several task before using this. Steps required are given below:
1. Create a SNS topic
You can refer below url for same
http://docs.aws.amazon.com/sns/latest/dg/CreateTopic.html

2. Subscribe an endpoint(HTTP) (webserver where you will recieve the SNS notification and run this script)
You can refer below url for same
http://docs.aws.amazon.com/sns/latest/dg/SubscribeTopic.html

3. Create an autoscale lifecycle before termination
http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/adding-lifecycle-hooks.html

4. Provide access to nginx file so that webserver can edit the file
use setfacl command for this

5. Provide privilege to reload the nginx service to the use executing this script
use visudo and add
nginx ALL=(root)NOPASSWD:/etc/init.d/nginx (trying to find better and secure way to reload the service)

6. Access Key ID and Secret Access Key
http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html

Installation

Just copy the files in your webroot (within a desired folder).
Edit the config file and provide your acess key id, secret access key and region NOTE : YOU MIGHT NEED TO TWEAK FEW THINGS AS PER YOUR ENVIRONMENT.

About

To automatically add new ec2 instances to nginx upstream server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages