Giter Site home page Giter Site logo

aws-cli's Introduction

About

Very simple program to start, stop or print the state of some instances running on aws.
The flags name and owner are used as filters when making the ec2 actions (poweron|poweroff|state).

For this program to run properly it is necessary to have the aws credentials stored in your home directory ($HOME/.aws/credentials).
More information about aws credentials: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html

Here is an example of ~/.aws/credentials file:

[default]
aws_access_key_id = 123456...
aws_secret_access_key = sfdlkjs.....
region = us-east-2

Installing

  • Just clone this repo and compile it:
git clone https://github.com/git-hyagi/aws-cli.git
cd aws-cli
go install aws-test.go

Running

  • power off instance:
aws-test poweroff -n <instance name> -o <owner>
  • For example, to turn off all ec2 instances with name yagi-* and aws owner '1234':
aws-test poweroff -n `yagi-*` -o 1234
  • power on instance:
aws-test poweron -n <instance name> -o <owner>
  • get instance state:
aws-test state -n <instance name> -o <owner>
  • it is also possible to configure env vars instead of passing the owner and/or the instance name(s) through parameter(s):
export INSTANCE_NAME="yagi-*"
export INSTANCE_OWNER=1234
aws-test state

Pre-reqs

You should have go installed to compile this program. Here is the steps to download and install go on Linux:

wget https://golang.org/dl/go1.15.2.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.15.2.linux-amd64.tar.gz
rm -f go1.15.2.linux-amd64.tar.gz

Configure the env vars:

cat<<EOF>> ~/.bash_profile

# Go specific environment vars
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
export GOPATH=$HOME/go
export GOBIN=$HOME/go/bin
EOF

source ~/.bash_profile

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.