awsenv - AWS环境配置加载程序

网友投稿 677 2022-10-17

awsenv - AWS环境配置加载程序

awsenv - AWS环境配置加载程序

awsenv

AWS environment config loader.

awsenv is a small binary that loads AWS environment variables for an AWS profile from ~/.aws/credentials - useful if you're regularly switching credentials and using tools like Vagrant. In addition to aws_access_key_id and aws_secret_access_key, it will also optionally load settings for aws_keyname and aws_keypath.

Installation

# install Go from https://golang.org/dl/export GOPATH=$HOME/gogo get -u github.com/soniah/awsenv

This will automatically download, compile and install the awsenv executable to $GOPATH/bin.

Usage

Import variables into your environment by eval-ing a backticked call to awsenv.

eval `awsenv profile-name`

For example, if you had the following credential files:

% cat ~/.aws/credentials[example1]aws_access_key_id = DEADBEEFDEADBEEFaws_secret_access_key = DEADBEEFDEADBEEF1vzfgefDEADBEEFDEADBEEF% cat /var/tmp/credentials[example2]aws_access_key_id = DEADBEEFDEADBEEFaws_secret_access_key = DEADBEEFDEADBEEF1vzfgefDEADBEEFDEADBEEFaws_keyname = 'example2_key'aws_keypath = "~/.ssh/example2.pem"

The following shell commands would import AWS variables into your environment:

% eval `awsenv example1`% env | grep AWSAWS_ACCESS_KEY_ID=DEADBEEFDEADBEEFAWS_SECRET_ACCESS_KEY=DEADBEEFDEADBEEF1vzfgefDEADBEEFDEADBEEF% eval `awsenv example2 -f /var/tmp/credentials -v`AWS_ACCESS_KEY_ID=DEADBEEFDEADBEEFAWS_SECRET_ACCESS_KEY=DEADBEEFDEADBEEF1vzfgefDEADBEEFDEADBEEFAWS_KEYNAME=example2_keyAWS_KEYPATH=/Users/sonia/.ssh/example2.pem

Vagrant Example

In a Vagrantfile you could do:

override.ssh.username = "ubuntu"aws.keypair_name = ENV['AWS_KEYNAME']override.ssh.private_key_path = ENV['AWS_KEYPATH']

Flags

The accepted flags can be displayed using -h:

% awsenv -hUsage: awsenv [OPTIONS] ProfileApplication Options: -v, --verbose Verbose output -f, --filename= Credentials file (~/.aws/credentials)Help Options: -h, --help Show this help messageArguments: Profile

Contributions

Contributions are welcome; here is an example workflow using hub.

go get github.com/soniah/awsenvcd $GOPATH/src/github.com/soniah/awsenvhub forkgit co -b dev (and write some code)git push -u devhub pull-request

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Warkeys- 魔兽争霸III外挂程序
下一篇:postman多环境配置token自动登录配置
相关文章

 发表评论

暂时没有评论,来抢沙发吧~