How can I copy a config file to an AWS EB deployment? - amazon-web-services

I have set up a Node.js / express app and I am using aws eb to deploy.
That is how my config is set up to be environment specific. However, I don't want to put my config.prod.json in my source control. How can I get that put up to my deployed application?

You can use .ebextensions folder to add some commands to copy additional files from anywhere. More info:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html

Related

Upadate Elastic Beanstalk environment and ebextensions files

I have an elastic beanstalk environment that the first upload I used with ebextensions to configure all the configurations.
Now, If I want to update the environment again (only change the code) the ebextensions stay the same,
I need to insert the ebextensions into the zip file that I upload to update the beanstalk environment?
Or I can ignore the ebextensions and upload the zip as is?
I create the zip file using Visual Studio and I put the ebextensions inside the code.
Thanks
It depends on what is in your .ebextensions. For example, if you just install some rpm packages, then they will still be installed. But generally you would always include the config files anyway, as EB can deploy your application to new instances and then entire configuration has to be re-done from scratch.

How AWS EB works for each deployment?

I have a project in EB linked with codePipline from Github, and I have some files inside my project in .ebextensions & .platform folders
My question is: Does AWS Elastic Beanstalk deploy these files each time I deploy a new version to EB or just one time?
How EB worked behind the sense!?
the .ebextensions and .platform folders need to be part of your application code. So if you're using the CodePipeline Elastic Beanstalk deployment task, the input artefact needs to have these folders. This also allows to include these files in your versioning system.
How EB deploys new servers, depends on how you have configured it to deploy the application. You can find more information in the EB development guide.

Boto3 Deploy to Elastic-beanstalk not reading Config files

I am using boto3 to deploy my environment to elastic beanstalk using the create_environment function. I have my configuration files in the .elasticbeanstalk folder but the deploy doesn't seem to be using them. When I deploy the same environment using the eb client it works exactly as wanted. Any suggestions?
I figured this out.
boto3 uses the aws api, which does not read the configuration files but rather reads a json configuration option (called option_settings). These allow you to configure all of your post-ec2-deploy settings (Everything you can change from the elastic beanstalk configuration page).
However, if you want to adjust configuration for what your ec2 instance has installed before your application runs (things like package installs, file creation, etc.) then you will have to create an aws image of a ec2 instance you like, and then reference that image id from the option_settings.
obviously the eb client does all of the above for you by reading the configuration files.

What files are needed for the AWS EB CLI 3.x tools?

I've recently switched from old AWS EB CLI tools (2.6.4) to the current ones (3.0.10) and am wondering how to ensure that my project's configuration is migrated, and what configuration files I should keep.
I've run (the new version of) eb init and now have, in my project's .elasticbeanstalk directory, a new file
config.yml
along with several ones that were there before
config
optionsettings.sitetest-develop-env
optionsettings.sitetest-env
which of these are still needed; which can I delete; and what steps to I need to take to ensure that all of the old settings have been migrated to (and to the right place for) the 3.x AWS EB CLI tools?
#BMW's answer is very clear and good, but I thought I would provide a more condensed version.
The only file the EB CLI 3.x needs is the config.yml in the .elasticbeanstalk folder
While 3.x will attempt to read your 2.x configurations and port them over, it is not needed. 3.x will also pull down settings from any running environments. Therefore the cleanest way to upgrade to 3.x is to create a new directory and use EB init. It will sync with your existing application and environment(s).
I used the latest version (3.x) directly and didn't realise the difference between eb 2.6.x and EB CLI 3.x at beginning. Thanks to raise this question (+1) .
Here is what I got from AWS Elastic Beanstalk documents.
Old version is called eb 2.6.x, new version is called EB CLI 3.x, the configuration difference between these versions has been explained clearly by this url
EB Command Line Interface
EB is a command line interface (CLI) for AWS Elastic Beanstalk that you can use to deploy applications quickly and more easily. AWS Elastic Beanstalk supports eb 2.6.x and EB CLI 3.x. You can use EB CLI 3.x to manage environments that you launched using eb 2.6.x or earlier versions of eb. EB CLI will automatically retrieve settings from an environment created using eb if the environment is running. Unlike eb, EB CLI does not store option settings locally.
Why you have these folder/files (such as config, optionsettings.sitetest-develop-env, optionsettings.sitetest-envin) in your environment, here is the explanation Eb Operations, that's only for eb 2.6.x
You can use a configuration file in an .ebextensions/.conf* directory to configure some of the same settings that are in an .elasticbeanstalk/optionsettings file. However, the values for the settings in .elasticbeanstalk/optionsettings will take precedence over anything in .ebextensions/*.conf if the settings are configured in both. Additionally, any option setting that is specified using the API, including through eb, cannot later be changed in an environment using .ebextensions configuration files.
Finally, answer your question. If you have upgraded the version to EB CLI 3.x, then you can clean these files, but you still need keep config.yml, it is created when eb init in EB CLI 3.x.

How do I go about creating Elastic Beanstalk configuration files?

I am looking for advice about how I should approach the problem of creating Elastic Beanstalk configuration files.
How do I go about constructing an Elastic Beanstalk configuration files?
How do I know what to include or not include?
Do I construct it by hand using the template reference or are they typically generated by a configuration tool?
You can modify the configuration of Elastic Beanstalk environments in multiple ways.
One way is to place a folder with the name .ebextensions inside your app source zip. Inside this folder you can have one or more files with a .config extension. Files will be processed in the alphabetical order of their name. These files are formatted using YAML syntax.
These files allow you to control lots of configuration options for your beanstalk environments.
This page explains various things you can configure using ebextensions (assuming you are on a linux environment). You can read about ebextensions on Windows here. On this page you will find information on how different parts of your environment configuration can be controlled, e.g. you can install packages on your instances, you can create files, you can run shell commands on your instances during deployment, you can control settings of your environment etc.
You can also control option_settings for your environment using these config files. You can read more details about what option settings are supported here.
You can also modify properties of AWS resources like load balancer, auto scaling groups etc. created by beanstalk or you can create new resources like DynamoDB tables using ebextensions. Documentation on how to create or modify resources is available here.