Elastic beanstalk Nigix Configuration for Golang app - amazon-web-services

I am following standard EBS config structure to override NGINX configuration as below. .ebextensions/nginx/conf.d/rate-limit.conf .ebextensions/nginx/conf.d/elasticbeanstalk/error429.conf
Not able to see the changes after deployment. Even when I SSH to the respective ec2 I dont see the expected files in
/etc/nginx/ or /etc/nginx/conf.d/elasticbeanstalk/
folder structure -
.ebextensions
.elasticbeanstalk
main.go
... ...etc

Related

Elastic Beanstalk - EFS Failing to Mount on deployment - Device or resource busy

I am following the AWS tutorial that tells us how to mount EFS system to elastic beanstalk instances available at https://aws.amazon.com/premiumsupport/knowledge-center/elastic-beanstalk-mount-efs-volumes/.
I am mounting this folder inside the current folder, as it needs to be accessible by my web application as a path, e.g: public/medias. So I am mounting EFS inside my app public folder and all media will be accessible through the webserver.
The first mount is ok, but after the first deployment, it seems that elastic beanstalk is trying to remove the folder when clearing up the app/current folder for a new deployment, then the deploy fails to remove the mounted unit which is inside current with a message that can not remove directory - Device or resource busy.
It's not possible to mount EFS directories inside current folder for elastic beanstalk? Or I should consider in mounting it outside of the application folder then I could use something like symlink for accessing the files through a web server?
The reason why I am mounting this inside var/app/current/public/media is because it needs to be accessible through https://mywebsite.com/media/myImage.png => this should come from EFS.
I could consider using S3 Buckets instead but all my web application is reading files using a static path and it would be a massive work to migrate that to read from a bucket.
I had this same issue for a while and finally found the answer in this article from AWS Knowledge Center:
Important: You can't mount an Amazon EFS volume directly to the application directory because the contents of /var/app/current are moved to /var/app/current.old whenever you deploy an Elastic Beanstalk application.
The solution is to mount EFS to some other directory and create a symlink between that and your /current directory, or whatever other sub directory you are mounting to in /var/app/current.
I did this by modifying my storage-efs-mountfilesystem.config (in .ebextensions - example efs-mountfilesystem.config) to mount to /efs instead of /var/app/current/wwwroot/user_content, and added a new storage-efs-symlink.config (name it whatever you like) config file in .ebextensions that runs this command:
container_commands:
01_symlink:
command: ln -s /efs ./wwwroot/user_content
Where the first argument is what you specified as your EFS mount point, and the second argument is where your app attempts to read/write to (in my case, /var/app/current/wwwroot/user_content -> ./wwwroot/user_content).
(Note the relative path. It needs to be relative because these commands execute when the app is still in the /var/app/staging, so the /current directory doesn't exist yet. More Here.)
Here was my exact error in eb-engine.log when attempting to deploy an elastic beanstalk application with EFS mounted in /var/app/current: An error occurred during execution of command [app-deploy] - [FlipApplication]. Stop running the command. Error: remove current dir failed: unlinkat /var/app/current/wwwroot/user_content: device or resource busy
If you don't already have a .ebextensions folder, you can create it yourself and make sure it ends up in your application source bundle. More information about .ebextensions here.

WSGIPath does not exist for my Flask app on AWS EBS with CodePipeline

I am trying to deploy Airbnb's open source Knowledge Scaling Repository Application on AWS Elastic Beanstalk using CodePipeline. My pipeline is failing with an error: Your WSGIPath refers to a file that does not exist. I have configured my Pipeline through the console to look to /knowledge_repo/app/deploy/flask.py for the WSGI.
I see AWS EB documentation that seems to expect an application.py file for Flask apps, which does not exist in this repo.
What is the appropriate file path for the WSGI file for this app?
Try this:
Go to your EB enviroment > Configuration > Software > Modify and change WSGIPath.

Deploying multi-docker local setup to AWS using Elastic Beanstalk

I'm having e multi-docker setup running locally. Now, I would like to deploy that to AWS using Elastic Beanstalk.
My folder config is like this
app
/.ebextensions
composer.config
/.elasticbeanstalk
config.yml
/docker (docker-compose and additional Docker files)
docker-compose.yml
/www (root folder of application)
I already ran eb init, but I don't know how to actually deploy my local docker-compose configuration to AWS.
I read about the Dockerrun.aws.json file, should I just copy paste my docker-compose to that file? Or how does it work?
I already tried to:
zip my folder and upload it to AWS
eb create / eb deploy but then I get the following error message:
Platform Multi-container Docker 17.03.1-ce (Generic) does not appear to be valid
Thank you
I'm having a very similar issue (not using multi-container) and it appears Amazon has a bug. By selecting Docker 1.12.6 I am able to execute eb create which fails for me otherwise.
EDIT: This appears to have been a bug in the EB CLI. I upgraded and it works fine now.
I had a similar problem, looks like they had a bug and fixed it in 3.10.4, please update your eb-cli
3.10.4 (2017-07-14)
Fixed bug in solution stack determination logic for Multi-Container Docker 17.03.1-ce platform version
See here for change log and here how to update.

Where to put ebextensions config in AWS Elastic Beanstalk Docker deploy with dockerrun source bundle?

I am having trouble getting my docker elastic beanstalk deploy to read my .ebextensions/setup.config file.
The documentation for eb environment configuration says:
You can include one or more configuration files with your source bundle. Configuration files must be named with the extension .config (for example, myapp.config) and placed in an .ebextensions top-level directory in your source bundle.
However it looks like for Docker that the source bundle is not a .zip or .war file, but a .json file, e.g., the docs say to create a Dockerrun.aws.json file—and it looks like that is the source bundle?
In creating a version of the app I upload a custom Dockerrun-$VERSION.aws.json file to s3 and the run something like the following (where $APP is the versioned dockerrun json file):
aws elasticbeanstalk create-application-version \
--application-name $APP_NAME \
--version-label $VERSION \
--source-bundle S3Bucket=$S3_BUCKET,S3Key=$S3_PATH/$APP
So… how is the .ebextensions directory going to be found in the top-level directory of the source bundle when the “bundle” is just a json file that ends up building a container? (My first attempt was to just put it in the root of the project, but that didn’t work.)
If you are using a .json file for docker deploys, then you cannot use .ebextensions.
You can however create a zip that contains your .json and your .ebextension directory and everything should work. Use the zip as your deployment artifact instead of the raw json.

Can't set AWS Elastic Beanstalk static path with config file

I have a config file in my projects's .ebextensions directory containing
option_settings:
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "sitetest/static/"
but my EB environment does not change the setting for /static/ in response to this being pushed to AWS.
I can verify that other config settings in the same directory — e.g. for environment variables using
option_settings:
"aws:elasticbeanstalk:application:environment":
SOME_VAR: "foo"
or for container commands using
container_commands:
00_syncdb:
command: "python manage.py db upgrade"
leader_only: true
behave as expected.
Why isn't AWS Elastic Beanstalk's static path changing when to correspond to the setting in my config file?
The ebextensions are a lower precedence setting. What this means is that if you ever set anything in your ebextensions using the cli/console/api, the ebextension will no longer take effect.
You can remove the setting using the cli/api in order to get the ebextension to work again.
Using the EB CLI you can use eb config then remove the related line from the file.
Using the AWS CLI you can use:
aws elasticbeanstalk update-environment --environment-name MyEnvName --region us-west-2 --options-to-remove Namespace=aws:elasticbeanstalk:container:python:staticfiles,OptionName=/static/