Giter Site home page Giter Site logo

swoodford / aws Goto Github PK

View Code? Open in Web Editor NEW
1.1K 53.0 550.0 1.78 MB

A collection of bash shell scripts for automating various tasks with Amazon Web Services using the AWS CLI and jq.

License: Apache License 2.0

Shell 100.00%
aws awscli amazon ec2 s3 elb cloudfront cloudwatch iam route53

aws's Introduction

AWS

A collection of bash shell scripts for automating various tasks with Amazon Web Services using the AWS CLI and jq.

Build Status

Table of contents

Why

Why does this project exist?

This repository is intended to make some of the more difficult DevOps tasks commonly required to maintain complex hosting infrastructure in AWS simple, quick and easy. This is my attempt to automate and expedite difficult, repetitive, tedious and time consuming processes into a simple shell script that gets the job done as cleanly as possible. These scripts were developed out of frustration in clicking around on the same things over and over again in the web console every day, week, month when they could easly be done in seconds in a script that uses the AWS CLI. I've tried to keep everything applicable to as many use cases across regions and across as many different AWS accounts as possible. I run many of these scripts myself, mostly on a Mac or in Linux and do periodic usability and bug checking, making updates for any changes to the CLI. I hope this collection of tools helps you too, and if you use these please hit the Star/Fork button and if you have any suggestions please open an Issue or PR!

Getting Started

What is the AWS Command Line Interface?

The AWS CLI is an open source tool built on top of the AWS SDK for Python (Boto) that provides commands for interacting with AWS services.

Installing the AWS Command Line Interface

Requirements:

  • Python 2 version 2.6.5+ or Python 3 version 3.3+
  • macOS, Linux, or Unix

If you already have pip and a supported version of Python, you can install the AWS CLI with the following command:

$ pip install awscli --upgrade --user

Configuring the AWS CLI

For general use, the aws configure command is the fastest way to set up your AWS CLI installation.

$ aws configure

The AWS CLI will prompt you for four pieces of information. AWS Access Key ID and AWS Secret Access Key are your account credentials.

Named Profiles

The AWS CLI supports named profiles stored in the config and credentials files. You can configure additional profiles by using aws configure with the --profile option or by adding entries to the config and credentials files.

$ aws configure --profile example

What is jq?

jq is a lightweight and flexible command-line JSON processor.

Installing jq

OS X: Use Homebrew to install jq:

$ brew install jq

Linux: jq is in the official Amazon Linux AMI, Debian and Ubuntu repositories.

Amazon Linux AMI, RHEL, CentOS:

$ sudo yum install jq

Debian/Ubuntu:

$ sudo apt-get install jq

Tools included in this repo:

cloudfront

CloudFront

cloudwatch

CloudWatch

ec2

EC2

elastic beanstalk

Elastic Beanstalk

iam

IAM

route53

Route53

s3

S3

vpc

VPC

waf

WAF

other tools

Other Tools

Bugs and feature requests

Have a bug or a feature request? The issue tracker is the preferred channel for bug reports, feature requests and submitting pull requests. If your problem or idea is not addressed yet, please open a new issue.

Creator

Shawn Woodford

Copyright and License

Code and Documentation Copyright 2012-2018 Shawn Woodford. Code released under the Apache License 2.0.

aws's People

Contributors

globart avatar jantvrdik avatar maor-rozenfeld avatar swoodford avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws's Issues

Add any other context or screenshots about the feature request here.

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Elastic Beanstalk EnvironmentHealth Alarm

Your tools look awesome! ๐Ÿ‘

Is there a way to automate the creation of an EnvironmentHealth alarm for a given Elastic Beanstalk application? I need to create the exact same alarm for a host of applications, each of which has multiple environments.

e.g.
I have foo-app with foo-app-production and foo-app-staging
I have bar-app with bar-app-production and bar-app-staging

All 4 of those need to message a SNS topic on both Alarm and OK.

Don't Repeat Yourself

Is your feature request related to a problem? Please describe.
Repeating yourself

Describe the solution you'd like
Pull the configuration into a single file

Describe alternatives you've considered
N/A

Additional context
N/A

You have this atop all of your scripts and if this ever changes, for whatever reason (which it probably won't), you'll be copy/pasting it all over again throughout. Also if someone wants to add some initialization steps beyond what is specified here you may benefit them as they could simply add to this included file. So instead of this:

if ! grep -q aws_access_key_id ~/.aws/config; then
  if ! grep -q aws_access_key_id ~/.aws/credentials; then
    echo "AWS config not found. Running \"aws configure\"."
    exit 1
  fi
fi

Move it to _pre_command.sh and improve it:

#!/usr/bin/env bash

# Look for the AWS CLI
if test ! $(which aws); then
  echo "Installing AWS CLI..."
  brew install awscli
fi

# Look for the AWS configuration
if ! grep -q aws_access_key_id ~/.aws/config; then
  if ! grep -q aws_access_key_id ~/.aws/credentials; then
    echo 'AWS configuration was not found. Running "aws configure"...'
    aws configure
  fi
fi

Then in all of your scripts simply put:

$SWOODFORD_AWS_DIRECTORY/_pre_command.sh

Or something more fancy (but that I think isn't really necessary):

$SWOODFORD_AWS_DIRECTORY/_pre_command.sh || sh -c 'echo; echo "The file \"\$SWOODFORD_AWS_DIRECTORY/_pre_command.sh\" was not found or executable! Please see this page for help: https://github.com/swoodford/aws"'

And then you can put this in an install.sh script:

#!/usr/bin/env bash

# Look for Homebrew and install it if not found
if test ! $(which brew); then
  echo "Installing homebrew..."
  /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi

# Get the code
git clone https://github.com/swoodford/aws.git ~/.swoodford_aws

# Set this (probably not needed)
export SWOODFORD_AWS_DIRECTORY=~/.swoodford_aws

# Add SWOODFORD_AWS_DIRECTORY variable for reference
grep -q -i -F 'SWOODFORD_AWS_DIRECTORY' ~/.bash_profile || sh -c 'echo "SWOODFORD_AWS_DIRECTORY=\"~/.swoodford_aws"\" >> ~/.bash_profile'

# Add SWOODFORD_AWS_DIRECTORY to the PATH
grep -q -i -F 'PATH="~/.swoodford_aws' ~/.bash_profile || sh -c 'echo "PATH=\"~/.swoodford_aws:\$PATH\"" >> ~/.bash_profile'

Then you can tell users "To simply install these scripts run the following:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/swoodford/aws/master/install.sh)" > /dev/null"

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.