UPDATE : EB Cli tools v3 now supports multiple aws profiles
AWS makes it very simple to push to different environments of an application, but what if you need to push to a completely separate AWS account?
It's not really possible, but you can shoehorn it with the following set up....
Say you have 2 branches -
stage is set to push to an AWS account in the usual way. The branch is mapped to an EB environment, and you use a
.elasticbeanstalk/aws_credential_file file to store your credentials.
Your EB files would look something like this...
[global] ApplicationName=myApplication AwsCredentialFile=.elasticbeanstalk/aws_credential_file DevToolsEndpoint=git.elasticbeanstalk.eu-west-1.amazonaws.com InstanceProfileName=aws-elasticbeanstalk-ec2-role Region=eu-west-1 ServiceEndpoint=https://elasticbeanstalk.eu-west-1.amazonaws.com [branches] stage=stage-env [branch:stage] ApplicationName=myApplication EnvironmentName=stage-env
To have another branch push to another account, you will need to create another AWS credentials file, say
.elasticbeanstalk/aws_credential_file_production, and then add that to your config.
Clearly, you can only use one at once, so you need to comment / uncomment (with a #) the creds file, when you want to switch between them. You can change other settings as well, such as the
So, and example config file would be...
"(pushing to a production account)"
[global] #ApplicationName=myApplication #AwsCredentialFile=.elasticbeanstalk/aws_credential_file ApplicationName=myProductionApplication AwsCredentialFile=.elasticbeanstalk/aws_credential_file_production DevToolsEndpoint=git.elasticbeanstalk.eu-west-1.amazonaws.com InstanceProfileName=aws-elasticbeanstalk-ec2-role Region=eu-west-1 ServiceEndpoint=https://elasticbeanstalk.eu-west-1.amazonaws.com [branches] stage=stage-env production=prod-env [branch:stage] ApplicationName=myApplication EnvironmentName=stage-env [branch:production] ApplicationName=myProductionApplication EnvironmentName=prod-env
Its a bit of hack, but the workflow is;
1) checkout branch
2) swap out the top two lines in the config
3) aws.push as per usual.
For it to work, you DO need to repeat the
EnvironmentName in the
To make this a slicker process, ideally you would run
git aws.push and pass it the config file to use, but having poked about the ruby files for AWSDevTools, it doesn't look to be an option.
Next step would be to extend the main
aws.elasticbeanstalk.push plugin and add it as a command line arg. Thats for another day...