Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hubot-env not working with hubpot-aws properly on env load #50

Open
stormlrd opened this issue Oct 6, 2016 · 5 comments
Open

hubot-env not working with hubpot-aws properly on env load #50

stormlrd opened this issue Oct 6, 2016 · 5 comments

Comments

@stormlrd
Copy link

stormlrd commented Oct 6, 2016

Hi,

for some reason I cannot get hubot ec2 ls to work properly after changing environments using hubot env load --filename=profile.env

the first profile I load persists on an ec2 ls.

am I doing something wrong here? I've tested this on a fresh hubot install and I just can't make the switch between accounts.

the env load shows all the right changes for access keys etc.

but the ec2 ls on the second env load shows the first ones results..

if I switch from loading profile1 first to profile2 , when I load profile1 after profile2 I get profile2 results... and vice versa..

sitting here scratching my head a bit :\ I've tried modifying the code to make variables unset using =null and nothing has worked to date.

some ideas would be great.
thanks.

@stormlrd
Copy link
Author

stormlrd commented Oct 6, 2016

needed to make my aws.coffee have a new line in it before the return:

aws.config.update({accessKeyId: aws.config.accessKeyId, secretAccessKey: aws.config.secretAccessKey});

@yoheimuta
Copy link
Owner

I just can't make the switch between accounts.

@stormlrd I'm sure that it is not an expected behavior.
Could you paste some operation logs about these behaviors ?

@stormlrd
Copy link
Author

stormlrd commented Oct 8, 2016

basically it went like this in my testing:

hubot env load --filename=env1.env
hubot ec2 ls

hubot env load --filename=env2.env
hubot ec2 ls

the env files had the same variables declared and were showing in the output as changing. i.e I saw different access key and secret ids but the second hubot ec2 ls call was showing the first environments one still.

I've kinda forked the code and applied the fix and moved on for now tho.

@yoheimuta
Copy link
Owner

Thanks for sharing commands.

I run the same commands, and switching the accounts were properly worked.

# Delete all environments before running test commands
hubot> hubot env flush all
Flushing all --dry-run=false...
Complete flushing all

# Confirm to delete all environment about access key and secret
hubot> hubot env current --prefix=HUBOT_AWS
HUBOT_AWS_DEBUG=1
HUBOT_AWS_CAN_ACCESS_ROLE=tech

# Load the access key and secret written in a aws-cred-tech-intern.env file
hubot> hubot env load --filename=aws-cred-tech-intern.env
Loading env --filename=aws-cred-tech-intern.env, --dry-run=false...
HUBOT_AWS_CREDENTIALS=tech-intern
HUBOT_AWS_ACCESS_KEY_ID=AKIA # I deleted a rest of id for secrecy
HUBOT_AWS_SECRET_ACCESS_KEY=***
HUBOT_AWS_REGION=ap-northeast-1

# Confirm to complete loading the data
hubot> hubot env current --prefix=HUBOT_AWS
HUBOT_AWS_DEBUG=1
HUBOT_AWS_CAN_ACCESS_ROLE=tech
HUBOT_AWS_CREDENTIALS=tech-intern
HUBOT_AWS_ACCESS_KEY_ID=AKIA
HUBOT_AWS_SECRET_ACCESS_KEY=***
HUBOT_AWS_REGION=ap-northeast-1

# Confirm to show details about tech-intern ec2 instances
hubot> hubot ec2 ls
Fetching all (instance_id is not provided)...
hubot> time     state   id      image   az      subnet  type    ip      name
2015-07-15 17:38:25+09:00       running i-553040a0      ami-936d9d93    ap-northeast-1c subnet-d9ae5980 t2.medium       172.31.21.209   test-instance

# Switch to load an another access key and secret.
## See https://github.com/yoheimuta/hubot-aws/blob/master/example/env/aws-cred-tech.env
hubot> hubot env load --filename=aws-cred-private.env
Loading env --filename=aws-cred-private.env, --dry-run=false...
HUBOT_AWS_CREDENTIALS=private
HUBOT_AWS_ACCESS_KEY_ID=AKIAJXUF2PN2WVNTVUEA
HUBOT_AWS_SECRET_ACCESS_KEY=***

# Confirm to switch loading data
hubot> hubot env current --prefix=HUBOT_AWS
HUBOT_AWS_DEBUG=1
HUBOT_AWS_CAN_ACCESS_ROLE=tech
HUBOT_AWS_CREDENTIALS=private
HUBOT_AWS_ACCESS_KEY_ID=AKIAJXUF2PN2WVNTVUEA
HUBOT_AWS_SECRET_ACCESS_KEY=***
HUBOT_AWS_REGION=ap-northeast-1

# Confirm to show details about private ec2 instances
hubot> hubot ec2 ls
Fetching all (instance_id is not provided)...
hubot> time     state   id      image   az      subnet  type    ip      name
2016-09-11 11:22:24+09:00       stopped i-515777ce      ami-936d9d93    ap-northeast-1a subnet-a8d12cdf t2.micro        10.0.1.160      [NoName]

Could you share operation logs including all stdout from hubot, not only running commands ?

@stormlrd
Copy link
Author

stormlrd commented Oct 12, 2016

mcp env file

rad.env
zenstorm.env

mcp env load --filename=rad.env

mcp
Loading env --filename=rad.env, --dry-run=false...

HUBOT_AWS_CREDENTIALS=radium
HUBOT_AWS_ACCESS_KEY_ID={obscured}
HUBOT_AWS_SECRET_ACCESS_KEY=***
HUBOT_AWS_REGION=ap-southeast-2
HUBOT_AWS_DEFAULT_REGION=ap-southeast-2
AWS_DEFAULT_REGION=ap-southeast-2
AWS_ACCESS_KEY_ID={obscured}
AWS_SECRET_ACCESS_KEY=***
HUBOT_AWS_CAN_ACCESS_ROLE=admin
HUBOT_SLACK_API_TOKEN=***
HUBOT_SLACK_CHANNEL_NAME=#mine

mcp ec2 ls

mcp
Fetching all (instance_id is not provided)...

server list from rad successfully pulled

mcp env load --filename=zenstorm.env

mcp
Loading env --filename=zenstorm.env, --dry-run=false...

HUBOT_AWS_CREDENTIALS=Zenstorm
HUBOT_AWS_ACCESS_KEY_ID={obscured}
HUBOT_AWS_SECRET_ACCESS_KEY=***
AWS_ACCESS_KEY_ID={obscured}
AWS_SECRET_ACCESS_KEY=***

mcp ec2 ls

mcpBOT [8:48 AM]
Fetching all (instance_id is not provided)...

Rad server list returned again
On a fresh hubot install too. Commands were run from slack using a slack adapter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants