Code Monkey home page Code Monkey logo

saws-api's Introduction

Sinatra AWS - API

With SAWS-API you can easily communicate or integrate your services with AWS APIs. It supports all REST AWS APIs including Autoscaling, EC2.

Usage

Clone this repo

git clone [email protected]:/piripirigoso/saws-api.git

Install all GEMs

bundle install

Start it

rackup

Configure

Edit the application.yml and put your aws key id and key secret:

general:
  aws_user: 'INSERT HERE YOUR AWS KEY'
  aws_pass: 'INSERT HERE YOUR AWS SECRET'

Examples

In this example below, you can check the Private IP Address from any Instance.

def ec2_private_address id
  parameters = {
    'InstanceId' => id
  }
  instance_info = XmlSimple.xml_in(aws_module('ec2','DescribeInstances',parameters))
  ip = instance_info['reservationSet'][0]['item'][0]['instancesSet'][0]['item'][0]['privateIpAddress'][0]
  ip
end
  
get '/ec2/:InstanceId' do
  ec2_private_address "#{params[:InstanceId]}"
end

Upon set it, go to http://YOUR_IP:PORT//ec2/YOUR-INSTANCE-ID

Adding new modules

Imagining you want support S3 API too, it simple. Edit the aplication.yml and add the following parameters:

s3:
  api_proto: http
  api_endpoint: s3.us-east-1.amazonaws.com
  api_version: '2013-02-01'

And in your application.rb run aws_module('s3','YOURACTION',parameters) as you prefer.

saws-api's People

Contributors

renato-farias avatar

Watchers

Rod 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.