Coder Social home page Coder Social logo

grz0zrg / aws-ec2-region-switcher Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 153 KB

A simple single page web interface to toggle / spawn AWS EC2 instances on different region at will.

License: BSD 3-Clause "New" or "Revised" License

JavaScript 74.58% Pug 12.15% CSS 13.26%

aws-ec2-region-switcher's Introduction

AWS EC2 Region Switcher

A simple single page web interface to toggle / spawn AWS EC2 instances on different region at will.

This use Pug to render the page, Node.js with Express.js and the AWS API.

This can be customized easily for different use cases.

See views/index.pug views/style.css for page customization and eventually server.js config.js for logic customization.

What does it do

My use case for this is a personal multi region VPN portal.

It show a list of flags which spawn an instance on the corresponding region from a launch template when a flag is clicked on.

All named instances matching the nameTag config property are terminated upon a flag click so it is basically moving a single instance across regions.

There is also a CloudWatch alarm on the instance it spawn, the alarm terminate the instance automatically based on some amount of inbound network inactivity, this can be removed easily for a permanent instance.

I use a free dynamic DNS service to cust costs (no static IP) and provide a way to reach the instance with the same address when it move to other regions but there is less setup to do on the instance with a static Elastic IP.

Howto

This require some prior setup on AWS interface (console) such as :

  • correct authorizations must be given for the AWS API user so the AWS API works
  • an EC2 launch template must be created on each regions you want to spawn instances on, makes sure to provide an identifiable instance NAME (this app will match the template instance NAME when fetching / terminating instances)
  • the nameTag in the config.js file must be updated to match the one in the launch template
  • the launchTemplate and region name for each regions must be given in the config.js file, the code property is to show the correct flag
  • if you use usePing: true in the config.js you must allow inbound ICMP on your instance security group

If you use a static Elastic IP for the instances then set usePing: true, the instance status switch feedback on the UI will be more accurate.

If you use a dynamic DNS service (or a domain name) then in config.js set usePing: true and instancesDomainName to the domain that will be used to access the instances, the instance status switch feedback on the UI will be more accurate and probably faster than the default which use AWS InstanceStatus property.

Once everything is done you can just run it :

npm install node server.js

I recommend PM2 if you want to run it permanently as a daemon process.

For AWS EC2 VPN setup see here (this require some small prior knowledge about EC2)

AWS EC2 Region Switcher screenshot

aws-ec2-region-switcher's People

Contributors

grz0zrg avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.