AWS System Environmental Variables how-to? - amazon-web-services

My Grails application is currently using System.env.MY_SYS_PROP and it does not work when I set the params via Beanstalk Environment Properties which get passed to the Application.
System.getProperty("MY_SYS_PROP") works but I'd like to keep the app as is with access to the properties via System.env.MY_SYS_PROP
How do I set the System Environmental properties on AWS Beanstalk instance via config files?

I would recommend using the Elastic Beanstalk environment properties as this is more flexible since it keeps the configuration external to the WAR package.
However, if you must use environment variables, you can use the Elastic Beanstalk option_settings mechanism to set environment variables when container instances are created.
For Grails you can check out the Grails Elastic Beanstalk plugin (I am the author) that will be supporting this feature in the upcoming 0.3 release.

Related

Hooks in Elastic Beanstalk V3.0.1 (Amazon Linux 2) for configuration updates

As described in the AWS docs there are platform hooks for elastic beanstalk EBS for the deployment process: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html
But what can I do, to run a script each time someone changes the EBS configuration, e. g. an environment property?
If you look at the current docs here:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html, under Platform hooks -> Configuration deployment platform hooks, it explains:
A configuration deployment occurs when you make configuration changes that only update environment instances without recreating them.
And further:
To provide hooks that run during a configuration deployment, place them under the .platform/confighooks directory in your source bundle
So adding a Configuration deployment platform hook in this way should execute each time an environment property is changed.
Unfortunately there is no way to do this currently:
https://github.com/aws/elastic-beanstalk-roadmap/issues/15#issuecomment-616843537

Elastic Beanstalk environment variable that points to file

I understand how to set environment variables in Elastic Beanstalk, but how do I make these variables point to files of my choice?
S3, bundling the target file in my JAR, and other AWS services are all options for me.
Context: I am trying to use google-apps-clj, a Clojure library for using certain Google applications. One requirement of using google-apps-clj is that a JSON configuration file exists and that there is an environment variable (GOOGLE_APPLICATION_CREDENTIALS) that points to it (optionally, the file could exist at ~/.config/gcloud/application_default_credentials.json without such an environment variable). My Clojure app is running on AWS Elastic Beanstalk, and I use lein-beanstalk to automate some of the boring stuff.

Elastic Beanstalk Moded Environment variables

I have a IIS web application that I want to deploy to a UAT environment as well as a PROD environment. The application has quite a few setting that need to change based on the environment the environment.
What's the best way to set this up so that:
When I press F5 / use the local development web server I can select which env I want to emulate.
Mark an EC2 environment as UAT or PROD and have it apply a given set of settings easily.
I have read through all the .ebextensions documentation and can't quite find an elegant solution. I must be missing something here.

Elastic Beanstalk maintain the changes made directly via ssh for new instances?

When the app autoscale, the previous modifications made in first instance will be kept in new instances?
You will need to add configuration settings to your application archive so that each instance is configured the same way when it is brought online. This is done by creating a folder in your application called .ebextensions. You place files in that folder with the .config extenstion. These should be yaml format.
Check these docs for more information:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html
Linux specific (I assume Linux since you mention SSH):
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
No, elastic beanstalk will start a new server using a fresh AMI and your latest deployed application code.
It is considered bad practice to change the instance using SSH login, as it may be replaced at any time by Elastic Beanstalk.
If you'd like to change something in the instance, you can either use a custom AMI (not fun) or create an .ebextensions folder and put some configuration shell scripts there (see documentation).

Using the JetBrains AWS Elastic Beanstalk integration plugin

I'm using the excellent JetBrains AWS Elastic Beanstalk integration plugin (in PyCharm) but have a few related questions on how to accomplish things and how it integrates with the behavior of AWS's eb command line tool:
Is there a way to take advantage of EB's association between git branches and EB environments? The plugin doesn't seem to use this mapping and instead uses the environment specified in the run configuration dialog.
The URL that the application given as being "available at" is wrong. Is this a known bug? Is it something that I can fix?
Is there any way to have multiple run configurations for a given deployment (e.g. with different environment names)? Right now whenever I change the environment in one of my run configurations for a deployment, the other run configurations also switch to that environment.