Code Monkey home page Code Monkey logo

awsudo's Introduction

awsudo

awsudo is a command-line tool that requests temporary credentials from STS to use an IAM role.

If MFA is enabled, you'll be prompted for the token code.

Usage

First, you need to define your credentials in ~/.aws/credentials:

[default]
aws_access_key_id = AKIAIJFLKDSJFKLDSZ2Q
aws_secret_access_key = Eoz3FDKJLSfdsJLKFDjflsFDjklJFDjfdFDjdOKa

Then define your profiles in ~/.aws/config:

[profile administrator@development]
role_arn = arn:aws:iam::00000000002:role/administrator
source_profile = default
mfa_serial = arn:aws:iam::00000000001:mfa/pmuller

[profile administrator@staging]
role_arn = arn:aws:iam::00000000003:role/administrator
source_profile = default
mfa_serial = arn:aws:iam::00000000001:mfa/pmuller

[profile administrator@production]
role_arn = arn:aws:iam::00000000004:role/administrator
source_profile = default
mfa_serial = arn:aws:iam::00000000001:mfa/pmuller

You can use awsudo either to get temporary credentials as ready-to-use environment variables:

$ awsudo administrator@staging
Enter MFA code:
AWS_ACCESS_KEY_ID=ASIAJFSDLKJFS3VLA
AWS_SECRET_ACCESS_KEY=UKvIegRLKJSFLKJFDSLKFJSDLKJ
AWS_SESSION_TOKEN=FQoDYXdzEHIaDONIt4M0O10zRms0ac2.....

Or to directly run another executable with credentials defined in its environment:

$ awsudo administrator@development aws iam list-groups
Enter MFA code:
{
    "Groups": [
        {
            "Path": "/",
            "CreateDate": "2016-08-01T02:13:52Z",
            "GroupId": "AGPAILKJFSDLFKJSDLFS2",
            "Arn": "arn:aws:iam::1234567890:group/administrators",
            "GroupName": "administrators"
        },
        {
            "Path": "/",
            "CreateDate": "2016-08-01T02:24:05Z",
            "GroupId": "AGPAFSJDKLJFDSLKJFST6",
            "Arn": "arn:aws:iam::1234567890:group/users",
            "GroupName": "users"
        }
    ]
}

Development

Run tests:

$ make check

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.