Giter Club home page Giter Club logo

aws-runner's Introduction

AWS Runner

Use this node script to execute a series of aws api calls which are defined in file formatted as JSON.

!!! This repo contains private keys, and must remain a private repo !!!

aws-runner is currently coded to pull in the OpsWorks, Route53, and ELB apis, however it is coded to support all apis, and pulling in an API is currently a single line of code. It could be expanded in several ways so that the apis do not need to be specified explicitly.

Here an example file which defines two variables in a simulated response object, and later uses them as part of a Route53 RecordSet Alias

[
  {
    "response" : {
      "var1" : "marine-test-1420245491.us-west-2.elb.amazonaws.com",
      "var2" : "Z33MTJ483KN6FU"
    }
  },
  {
    "api" : "Route53",
    "command" : "changeResourceRecordSets",
    "sleep" : 30000,
    "params" : {
      "ChangeBatch": {
         "Changes": [
         {
           "Action": "UPSERT",
           "ResourceRecordSet": {
             "Name": "ops.aimstaging.com",
             "Type": "A",
             "AliasTarget": {
               "DNSName": "eval(response.var1)",
               "EvaluateTargetHealth": true,
               "HostedZoneId": "eval(response.var2)"
             }
           }
         }
         ]
       },
       "HostedZoneId": "Z17J9Y6BY2ZRYC"
    }
  }
]

Usage and flags

To run such a file, just run aws-runner passing a filename as an arg on the command line:

node aws-runner.js some-file.json

Aws-runner accepts several flags.

-s : Stream mode, aws-runner will accept a stream of data as variables, see below for 'Unix Pipe with Data Streams'.
-d : Debug mode, this will cause aws-runner to produce debug.log, which contains information about runs.
-v : Verbosity mode, this will cause aws-runner to produce debug info in the console.

Unix Pipe with Data Streams

That's all great, but it doesn't scale! That's ok we've got a solution to that. Since the purpose of aws-runner is to allow us to group together aws calls into standard process, we need to be able to provide these processes with dynamic data. The way to do that is by giving aws-runner a stream of data when executed, this is referred to as pipiing data. A simple command line call would look like:

echo '{
  "DNSName" : "opstest.aimstaging.com",
  "HostedZoneId" : "Z17J9Y6BY2ZRYC",
  "Target" : {
    "DNSName" : "marine-test-1420245491.us-west-2.elb.amazonaws.com",
    "HostedZoneId" : "Z33MTJ483KN6FU"
  }
}' | node aws-runner.js some-file.json -s

The stream provides is a json string and will be parsed into a variables object. It can be as big and have as much depth as needed.

The contents of 'some-file.json' might look like the file below, please note the contents of the evals 'variables.*'

[
  {
    "api" : "Route53",
    "command" : "changeResourceRecordSets",
    "params" : {
      "ChangeBatch": {
         "Changes": [
         {
           "Action": "UPSERT",
           "ResourceRecordSet": {
             "Name": "eval(variables.DNSName)",
             "Type": "A",
             "AliasTarget": {
               "DNSName": "eval(variables.Target.DNSName)",
               "EvaluateTargetHealth": true,
               "HostedZoneId": "eval(variables.Target.HostedZoneId)"
             }
           }
         }
         ]
       },
       "HostedZoneId": "eval(variables.HostedZoneId)"
    }
  }
]

aws-runner's People

Contributors

cajund avatar jregeimbal 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.