All Projects → felixb → Swamp

felixb / Swamp

Licence: mit
Teh AWS profile manager

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to Swamp

Trailscraper
A command-line tool to get valuable information out of AWS CloudTrail
Stars: ✭ 352 (+826.32%)
Mutual labels:  aws, hacktoberfest
Aws
Development repository for the aws cookbook
Stars: ✭ 473 (+1144.74%)
Mutual labels:  aws, hacktoberfest
Github Profile Readme Generator
GitHub profile readme generator allows you to create nice and simple GitHub profile readme files that will be included in your profile previews.
Stars: ✭ 374 (+884.21%)
Mutual labels:  hacktoberfest, profile
Stopstalk Deployment
Stop stalking and start StopStalking 😉
Stars: ✭ 276 (+626.32%)
Mutual labels:  aws, hacktoberfest
Aws Mfa
Manage AWS MFA Security Credentials
Stars: ✭ 606 (+1494.74%)
Mutual labels:  aws, mfa
Iam Policy Json To Terraform
Small tool to convert an IAM Policy in JSON format into a Terraform aws_iam_policy_document
Stars: ✭ 282 (+642.11%)
Mutual labels:  aws, hacktoberfest
Product Is
Welcome to the WSO2 Identity Server source code! For info on working with the WSO2 Identity Server repository and contributing code, click the link below.
Stars: ✭ 435 (+1044.74%)
Mutual labels:  hacktoberfest, mfa
Tfsec
Security scanner for your Terraform code
Stars: ✭ 3,622 (+9431.58%)
Mutual labels:  aws, hacktoberfest
Spring Cloud Aws
Integration for Amazon Web Services APIs with Spring
Stars: ✭ 541 (+1323.68%)
Mutual labels:  aws, hacktoberfest
Serverless Dynamodb Local
Serverless Dynamodb Local Plugin - Allows to run dynamodb locally for serverless
Stars: ✭ 530 (+1294.74%)
Mutual labels:  aws, hacktoberfest
Aws
AWS SDK with readable code and async responses
Stars: ✭ 268 (+605.26%)
Mutual labels:  aws, hacktoberfest
Aws Toolkit Vscode
AWS Toolkit for Visual Studio Code, an extension for working with AWS services including AWS Lambda.
Stars: ✭ 823 (+2065.79%)
Mutual labels:  aws, hacktoberfest
Foremast
Spinnaker Pipeline/Infrastructure Configuration and Templating Tool - Pipelines as Code.
Stars: ✭ 263 (+592.11%)
Mutual labels:  aws, hacktoberfest
Aws Sdk Ruby
The official AWS SDK for Ruby.
Stars: ✭ 3,328 (+8657.89%)
Mutual labels:  aws, hacktoberfest
Aws Toolkit Eclipse
AWS Toolkit for Eclipse – an open-source plugin for developing, deploying, and managing AWS applications.
Stars: ✭ 252 (+563.16%)
Mutual labels:  aws, hacktoberfest
Guider
Performance Analyzer
Stars: ✭ 393 (+934.21%)
Mutual labels:  hacktoberfest, profile
Drone Cache
A Drone plugin for caching current workspace files between builds to reduce your build times
Stars: ✭ 194 (+410.53%)
Mutual labels:  aws, hacktoberfest
Checkov
Prevent cloud misconfigurations during build-time for Terraform, Cloudformation, Kubernetes, Serverless framework and other infrastructure-as-code-languages with Checkov by Bridgecrew.
Stars: ✭ 3,572 (+9300%)
Mutual labels:  aws, hacktoberfest
Aws Vault
A vault for securely storing and accessing AWS credentials in development environments
Stars: ✭ 5,626 (+14705.26%)
Mutual labels:  aws, mfa
Aws Cdk
The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
Stars: ✭ 7,963 (+20855.26%)
Mutual labels:  aws, hacktoberfest

SWAMP: Profile Manager for AWS Build Status

You can use swamp to switch AWS profiles with ease.

Use case

swamp assumes you have an AWS account with CLI access credentials and you want to assume role into a set of AWS accounts from there. swamp optionally supports MFA authentication before assuming the target role.

Without MFA

swamp calls aws sts assume-role and writes the returned credentials into the specified target profile.

Example:

Create a session token based on your default profile:

$ swamp -profile default -target-profile target -target-role admin -account [target-account-id]
Wrote session token for profile target
Token is valid until: 2017-07-06 08:31:10 +0000 UTC

Create a session token based on your instance profile when running in an ec2 instance or ecs task:

$ swamp -instance -target-profile target -target-role admin -account [target-account-id]
Wrote session token for profile target
Token is valid until: 2017-07-06 08:31:10 +0000 UTC

With MFA

swamp calls aws sts get-session-token with MFA authentication to obtain a profile with enabled MFA. The returned credentials are written to the specified intermediate profile. Subsequent calls may skip that step as long as the session token is still valid. With these intermediate credentials aws sts assume-role is called as above.

Example:

$ swamp -target-profile target -target-role admin -account [target-account-id] -mfa-device arn:aws:iam::[origin-account-id]:mfa/[userid]
Enter mfa token for arn:aws:iam::[origin-account-id]:mfa/[userid]: XXXXXX
Wrote session token for profile session-token
Token is valid until: 2017-07-06 20:32:09 +0000 UTC
Wrote session token for profile target
Token is valid until: 2017-07-06 08:31:10 +0000 UTC

And run it again:

$ swamp -target-profile target -target-role admin -account [target-account-id] -mfa-device arn:aws:iam::[origin-account-id]:mfa/[userid]
Session token for profile session-token is still valid
Wrote session token for profile target
Token is valid until: 2017-07-06 08:32:15 +0000 UTC

Or create a session profile only:

$ swamp -mfa-device arn:aws:iam::[origin-account-id]:mfa/[userid]
Enter mfa token for arn:aws:iam::[origin-account-id]:mfa/[userid]: XXXXXX
Wrote session token for profile session-token
Token is valid until: 2017-07-06 20:32:09 +0000 UTC

Auto-Obtain MFA Token

If using swamp with an mfa-enabled account you can use the -mfa-exec flag to tell swamp to try to obtain the token itself. You need to give an executable command which returns the 6-digit code.

swamp is known to integrate well with the following tools:

  • pass / pass-otp: -mfa-exec "pass otp amazonaws.com"
  • ykman: -mfa-exec "ykman oath code amazonaws.com | awk '{ print $NF }'"

Example:

$ swamp -target-profile target -target-role admin -account [target-account-id] -mfa-device arn:aws:iam::[origin-account-id]:mfa/[userid] -mfa-exec "pass otp amazonaws.com"
Obtaining mfa token for: arn:aws:iam::[origin-account-id]:mfa/[userid]
Wrote session token for profile session-token
Token is valid until: 2017-07-06 20:32:09 +0000 UTC
Wrote session token for profile target
Token is valid until: 2017-07-06 08:31:10 +0000 UTC

Renew

swamp allows running in a loop to create a new profile for the target account before credentials expire. It even works with enabled MFA thanks to the cached intermediate credentials.

Example

$ swamp -target-profile target -target-role admin -account [target-account-id] -mfa-device arn:aws:iam::[origin-account-id]:mfa/[userid] -renew
Enter mfa token for arn:aws:iam::[origin-account-id]:mfa/[userid]: XXXXXX
Wrote session token for profile session-token
Token is valid until: 2017-07-06 20:32:09 +0000 UTC
Wrote session token for profile target
Token is valid until: 2017-07-06 08:31:10 +0000 UTC
Session token for profile session-token is still valid
Wrote session token for profile target
Token is valid until: 2017-07-06 08:46:10 +0000 UTC
...

Set profile in environment

swamp allows setting a profile as AWS_PROFILE in the environment. In order to activate this, at least -export-profile must be set. This tells swamp to write the profile to the a file (default is /tmp/current_swamp_profile) which can then be sourced and used in your shell. If you want to specify the file the profile is written to, you must also set export-file.

Example

With export-file:

$ swamp -target-profile target -target-role admin -account [target-account-id] -mfa-device arn:aws:iam::[origin-account-id]:mfa/[userid] -export-profile && source /tmp/current_swamp_profile

When setting export-file yourself:

$ swamp -target-profile target -target-role admin -account [target-account-id] -mfa-device arn:aws:iam::[origin-account-id]:mfa/[userid] -export-profile -export-file [/path/to/file] && source [/path/to/file]

Generating shell aliases

swamp has a lot of command line options. It is strongly recommended to create some kind of aliases for running swamp more easily. swamp -alias-config <config.yaml> does exactly that:

swamp -alias-config example/config.yaml >> ~/.bashrc

The output example/bash_aliases.sh file is generated from the example config example/config.yaml.

Install

General

Fetch the latest binary from https://github.com/felixb/swamp/releases. You may install it from source by running make install optionally setting something like TARGET=/usr/local/bin/ to specify a different installation target.

macOS

You can install swamp on macOS using brew with a third-party repository. Simply run brew tap splieth/swamp to add the repository and then brew install swamp to install the binary.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].