GithubHelp home page GithubHelp logo

optionalg / bash-my-aws Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bash-my-aws/bash-my-aws

0.0 2.0 0.0 291 KB

Bash functions for managing AWS resources simply and easily

License: MIT License

Makefile 0.30% Shell 99.70%

bash-my-aws's Introduction

TravisCI

bash-my-aws

caveman

** 22 Nov 2015 - In breaking (change) news, we're proud to release the complete rework! **

bash-my-aws assists Infrastructure Jockeys using Amazon Web Services from the command line.

This project provides short, memorable commands for realtime control of resources in Amazon AWS. The goal is to reduce the time between intention and effect.

These functions make extensive use of the incredibly powerful AWSCLI.

Prerequisites

Installation

As shown below, you may simply clone the GitHub repo and source the files required. (You should probably fork it instead to keep your customisations)

$ git clone https://github.com/realestate-com-au/bash-my-aws.git ~/.bash-my-aws

Usage

Source the functions you want with something like:

$ for f in ~/.bash-my-aws/lib/*-functions; do source $f; done

Add the bash_completion scripts: (optional)

$ source ~/.bash-my-aws/bash_completion.sh

Typing stack[TAB][TAB] will list available functions for CloudFormation:

$ stack
stack             stack-elbs        stack-parameters  stack-update
stack-asgs        stack-events      stack-resources   stack-validate
stack-create      stack-failure     stack-status      stacks
stack-delete      stack-instances   stack-tail
stack-diff        stack-outputs     stack-template

$ instance
instance-asg          instance-ip           instance-start        instance-terminate    instances
instance-console      instance-ssh          instance-state        instance-type
instance-dns          instance-ssh-details  instance-stop         instance-userdata
instance-iam-profile  instance-stack        instance-tags         instance-volumes

$ asg
asg-capacity             asg-max-size-set         asg-resume               asgs
asg-desired-size-set     asg-min-size-set         asg-suspend
asg-instances            asg-processes_suspended  asgard

For more info on the query syntax used by AWSCLI, check out http://jmespath.org/tutorial.html

** Piping output between functions **

We're very excited to announce this functionality.

Most bash-my-aws functions will accept AWS Resource Ids from STDIN. This means you can pipe output from many functions into other functions.

$ instances | grep splunk | instance-stack | stack-status
splunk-forwarder  UPDATE_COMPLETE
splunk-forwarder-role CREATE_COMPLETE

Usage examples

cloudformation-functions

Create a stack

This function gives you tab completion for filenames (missing from AWSCLI).

$ stack-create
USAGE: stack-create stack

$ stack-create example      # creates stack called example using example.json

It's also one of the functions that allows you to omit the template name if it exists in the current directory and matches the stack name with '.json' appended.

It's even smart enough to detect that you've added '-blah' to the stack name.

$ stack-create example-test # creates stack called example-test using example.json

List stacks

This is basically 'ls' with the ability to filter by a search string

$ stacks # call without filter argument to return all stacks
example-app
example-app-test
example-app-dev
something
something-else

$ stacks example # Or filter out the relevant stacks
example-app
example-app-test
example-app-dev

See what changes will be made by updating a stack

$ stack-diff
USAGE: stack-diff stack [template-file]

$ stack-diff example-dev
template for stack (example) and contents of file (example-dev.json) are the same

e--- params
+++ example-params-dev.json
@@ -4,7 +4,7 @@
         "ParameterKey": "slipGeneratorRolePath"
     },
     {
-        "ParameterValue": "something",
+        "ParameterValue": "something-else",
         "ParameterKey": "storageBucketName"
     },
     {

Updating a stack

$ stack-update
USAGE: stack-update stack [template-file] [params-file]

$ stack-update example # creates stack called example using example.json
...

Deleting a stack

$ stack-delete
USAGE: stack-delete stack

$ stack-delete example # deletes stack called example
...

Tailing stack events

The create/update tasks call this one but it can also be called directly. It watches events for a stack until it sees them complete or fail.

$ stack-tail my-stack
---------------------------------------------------------------------------------------------------------------------------------------------------------
|                                                                  DescribeStackEvents                                                                  |
+--------------------------+-------------------------------+-------------------------------------------+------------------------------------------------+
|  2015-07-25T23:13:21.628Z|  MyStack                      |  AWS::CloudFormation::Stack               |  CREATE_IN_PROGRESS                            |
|  2015-07-25T23:13:27.221Z|  AppServerSSHSecurityGroup    |  AWS::EC2::SecurityGroup                  |  CREATE_IN_PROGRESS                            |
|  2015-07-25T23:13:27.235Z|  DeploymentSQSQueue           |  AWS::SQS::Queue                          |  CREATE_IN_PROGRESS                            |
|  2015-07-25T23:13:27.291Z|  InternalELBSecurityGroup     |  AWS::EC2::SecurityGroup                  |  CREATE_IN_PROGRESS                            |
|  2015-07-25T23:13:27.537Z|  AppServerRole                |  AWS::IAM::Role                           |  CREATE_IN_PROGRESS                            |
|  2015-07-25T23:13:28.244Z|  DeploymentSQSQueue           |  AWS::SQS::Queue                          |  CREATE_IN_PROGRESS                            |
|  2015-07-25T23:13:28.769Z|  DeploymentSQSQueue           |  AWS::SQS::Queue                          |  CREATE_COMPLETE                               |
+--------------------------+-------------------------------+-------------------------------------------+------------------------------------------------+

Advanced Options

Output Style

The bash-my-aws commands support all the outputs of awscli. As of version 1.7.36, the supported outputs are json, tables, or text.

bash-my-aws supports a shorthand switch of --json, --tables, or --text.

bash-my-aws's People

Contributors

jonhiggs avatar mbailey avatar holmesjr avatar silarsis 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.