AWS Elastic Beanstalk deploy to multiple applications - amazon-web-services

I'm try to describe my situation:
Have multiple AWS account, credentials is located under ~/.aws/credential
To swich to other account I'm typing:
eb init -i --profile name
Now to deploy code to accounts I must every time switch to other acc. How I can organize .ebextensions to have possibility to deploy to 10 AWS acc without switching between profiles ?

You don't need to do eb init every time. You can deploy with arguments, eb deploy --profile profile_name.
If you setup your .elasticbeanstalk/config file something like this you can have different profiles and branches for different environments without using arguments.
branch-defaults:
develop:
environment: env-develop
profile: eb-profile
master:
environment: env-master
profile: eb-profile2
global:
application_name: env_name
default_ec2_keyname: key_name
default_platform: Python 2.7
default_region: ap-southeast-1
sc: git
I haven't tried this, but if you call eb deploy environment_name --profile eb-profile3 that is linked to somewhere else it should deploy there with your branch and global specific settings (profile overriden).
eb deploy <environment name> overrides the environment name.
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-deploy.html
I have only read this briefly, but maybe this can help you as well.
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebcli-compose.html

Related

How to solve CircleCI ERROR: This directory has not been set up with the EB CLI please use eb init?

I have a pipeline, that deploys my backend into aws elastic beanstalk.
i get this error
"ERROR: This directory has not been set up with the EB CLI"
even though my build folder has .elasticbeanstalk folder that has config.yml (my environment)
But it can't see it for some reason and asks me to use eb init
is there a way to solve it or a way to make eb init extract the environment from my config.yml?
i tried to eb init my-api --platform node.js --region us-east-1
but it brought me different set of errors

Upgrade an elasticbeanstalk platform from 3.6 to 3.7 Linux 2

I have an existing AWS elastic beanstalk flask application that deploys from circleci. The application is a python app, and has been running fine under AWS EB platform, "64bit Amazon Linux 2018.03 v2.9.10 running Python 3.6". This platform is deprecated.
I want to update this platform from the command line. My (possibly errant) thinking is that I should be able to do this by modifying the local .elasticbeanstalk/config.yml, which was created via eb init and is how I deploy the app (via eb deploy. My attempt at modifying the config.yml file looks like this:
branch-defaults:
master:
environment: env-name
global:
application_name: app-name
default_ec2_keyname: keyname
default_platform: Python 3.7 running on 64bit Amazon Linux 2
default_region: us-east-2
profile: eb-cli
repository: null
sc: null
But this does not change the existing environment. Might be because i set the global.default_platform to something new and ... of course, this is NOT a new env, but one that I want to update. Is there a way to set the platform that must be used for this EB app? Do I need to delete the original env to do the update? Is there any reference guide for this file (I could not find one)?
Thx for any pointers!

AWS EBS - How to pull environment name into .ebextensions script

I have a grails app that I deploy to AWS Elastic Beanstalk through Jenkins. I want to add a splunk forwarder to my project so I can keep track of my logs outside of AWS and set up easy notifications.
The problem is, I have multiple environments of the app running (dev, pre-prod, prod, etc), which is fine because you can just change the environment name for the forwarded and be able to easily sort through that in Splunk.
However, the same .ebextensions file has to be used between all the environments, no I need a way to set the environment name to whatever AWS has the name as. Is there a way I can easily do this that I'm overlooking?
Start of the script:
container_commands:
01install-splunk:
command: /usr/local/bin/install-splunk.sh
02set-splunk-outputs:
command: /usr/local/bin/set_splunk_outputs.sh
env:
SPLUNK_SERVER_HOST: "splunk.host"
03add-inputs-to-splunk:
command: /usr/local/bin/add-inputs-to-splunk.sh
env:
ENVIRONMENT_NAME: "Development"
cwd: /root
ignoreErrors: false
That ENVIRONMENT_NAME variable I'm setting that's passed to the 3rd script is what I want to be able to change based on what environment is being deployed. Can I set this in Jenkins or pull it through AWS somehow?
You can try below steps:
Configure your AWS Elasticbeanstalk environment with the environment variable
ENVIRONMENT_NAME = 'Development' or 'QA' or 'Prod'
please refer aws-official-docs for same.
Then update config as below:
container_commands:
01install-splunk:
command: /usr/local/bin/install-splunk.sh
02set-splunk-outputs:
command: /usr/local/bin/set_splunk_outputs.sh
env:
SPLUNK_SERVER_HOST: "splunk.host"
03add-inputs-to-splunk:
command: /usr/local/bin/add-inputs-to-splunk.sh
env:
ENVIRONMENT_NAME: "$ENVIRONMENT_NAME"
cwd: /root
ignoreErrors: false
Hope this should work for you.

Deploying to separate accounts with aws cli

I have two aws accounts : production and staging. I'm using aws-cli v3 to deploy via GIT to my production environment using eb deploy
I want to be able to deploy to my staging environment regularly from my develop branch and when it comes to deploying a release I want to be able to deploy from my newly created release branch to my production environment.
I already have my ~/.aws/config file with my two account key sets (staging and production), and would like to be able to do something like:
eb deploy --profile staging
and
eb deploy --profile production
Is it necessary to have the two environments under the same account and use eb use production-env and eb use staging-env?
A similar question has already been answered here
Also it does look like the eb command does support profiles
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-cmd-commands.html
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-cmd-commands.html#eb3-cmd-options

Is it possible to control the URL for an Elastic Beanstalk instance when using eb create?

When I use eb create to create a new Elastic Beanstalk environment as so:
eb create myappbeta
...the resulting URL contains an auto-generated part:
myappbeta-epjmudtzjs.elasticbeanstalk.com
When I create the environment through the Web console I get the chance to control the URL, so I can just have:
myappbeta.elasticbeanstalk.com
Is there any way to do this using eb create?
My .elasticbeanstalk/config.yml is:
branch-defaults:
default:
environment: myappprod
deploy:
artifact: myapp/target/scala-2.10/myapp_2.10-0.1-SNAPSHOT.war
global:
application_name: myapp
default_ec2_keyname: abc
default_platform: 64bit Amazon Linux 2014.03 v1.0.4 running Tomcat 7 Java 7
default_region: us-east-1
profile: null
sc: null
I have also tried with a CNAME setting in a saved configuration:
CName: myappbeta
But still it doesn't work... and generates an auto generated part.
You can use eb create --cname <CNAME_PREFIX> to control the CNAME for your environment.
Reference: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-create.html