How to set composer flag --no-dev for Amazon AWS deployment - amazon-web-services

I'm trying to deploy my Symfony 3 app on Amazon AWS Elastic beanstalk. I'm creating a folder ebextentions in root dir. In this dir I'm add a composer.config file which contains such code:
options_settings:
aws:elasticbeanstalk:container:php:phpini:
composer_options: --no-dev
but it doesn't work for me.
So, what config and where should I make for deploy project without developer requirements?

I just run into this same issue..
checking the eb-activity.log the --no-dev argument wasn't getting passed.
Here's what worked for me:
option_settings:
- namespace: aws:elasticbeanstalk:container:php:phpini
option_name: composer_options
value: --no-dev
The Amazon documentation seems misleading / incorrect..
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_PHP.container.html#php-namespaces

Assuming you did put the config file in .ebextensions instead of ebextensions, the real issue is that the options_settings key is a misspelling. It should actually be option_settings:
option_settings:
aws:elasticbeanstalk:container:php:phpini:
composer_options: --no-dev
Here's the relevant documentation for reference.

The problem is that your folder name is wrong. You are using ebextentions when the file should be named .ebextentions (there is a dot at the beginning).
See this answer for a full example.

Related

.ebextensions .config file not working on Beanstalk

I need to change this setting on my AutoScaling group in my Beanstalk environment:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environmentconfig-autoscaling-healthchecktype.html
I'm doing exactly like the example shows, but it just doesn't work. Nothing happens.
The file content:
Resources:
AWSEBAutoScalingGroup:
Type: "AWS::AutoScaling::AutoScalingGroup"
Properties:
HealthCheckType: ELB
HealthCheckGracePeriod: 300
The structure:
my_project/
.ebextensions/
autoscaling.config
src/
...
Is there any log where I can check if the file is even being read or not?
If you use eb deploy to deploy your changed code, it will not deploy your local code, but your last git commit.
You can try to find something in the logs in /var/log, for example in eb-engine.log or messages, or even in the system logs ($ journalctl), if you configured to be able to ssh into the machine.
You can also use the web console to download the logs (like this demo link).
If you don't find something, can you give some more information about the platform (java, node.js, python) and the way you are deploying?
Bye,
Dirk
Okay I found the problem. I'm using Green/Blue environments to deploy my application, so in the process of uploading new changes to the environment they were being made to the Green Env that was being terminated after.
In order for the new config to work I had to rebuild the Blue env.
From now on all the new deploys will have the new config.

Setting static file in elastic beanstalk

Trying to have django look for static files in the right directory, when hosting with elastic beanstalk.
Config file:
option_settings:
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "static"
Getting error message:
ERROR Invalid option specification (Namespace: 'aws:elasticbeanstalk:container:python:staticfiles', OptionName: '/static/'): Unknown configuration setting.
Tried following code from the documentation as a test.
option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: production.settings
aws:elasticbeanstalk:container:python:staticfiles:
/html: statichtml
/images: staticimages
Getting the same 'unknown configuration settings' error.
It seems you are using Amazon Linux 2? If yes, then it does not support the aws:elasticbeanstalk:container:python:staticfiles.
From docs:
Configuring static files using the
aws:elasticbeanstalk:container:python:staticfiles namespace is only
supported on Amazon Linux AMI Python platform versions
The answer for Amazon Linux 2 is to change:
aws:elasticbeanstalk:container:python:staticfiles:
/html: statichtml
/images: staticimages
to
aws:elasticbeanstalk:environment:proxy:staticfiles:
/html: statichtml
/images: staticimages

AWS Elastic Beanstalk ERROR: InvalidParameterValueError

While using command - eb deploy
I am getting below error. YAML is fine syntax wise
ERROR: InvalidParameterValueError - Each option setting in configuration file .ebextensions/environ-
v1.config in application version app-4c59-191023_045651 must be a map. Update each option setting in the configuration file.
.config file in .ebextensions folder which is in root of project
option_settings:
aws:elasticbeanstalk:application:environment:
PORT:8081
NODE_ENV:development
aws:autoscaling:launchconfiguration:
SecurityGroups:launch-123
I ran into the same issue running the AWS Deploy a Django App to Elastic Beanstalk (the tutorial does not seem to be up to date).
This AWS page has some info on the latest option setting formatting
It helped me resolve my issue which I think in your case would be including spaces after "PORT: ", "NODE_ENV: ", etc.
Also using an IDE that will highlight different words/parts of the file helped me understand how things were getting recognized.
have you tried double quotes in .config file like
"aws:elasticbeanstalk:application:environment":
instead of
aws:elasticbeanstalk:application:environment:
and, respectively,
"aws:autoscaling:launchconfiguration":
instead of
aws:autoscaling:launchconfiguration:

AWS Elastic Beanstalk .ebextensions' config_options not being used

I am using .git to deploy eb (PHP), and in the root folder, I've created folder .ebextensions and a file options.config with content
config_options:
aws:elasticbeanstalk:container:php:phpini:
document_root: /laravel/public
However, in the /var/log/eb-activity.log and I find the document_root is never being set
++ export PHP_DOCUMENT_ROOT=
++ PHP_DOCUMENT_ROOT=
In the S3 package I find the .ebextensions is bundled, so what can I do to debug this?
The docs state using option_settings rather than config_options (node.js, python and ruby examples use it, however the PHP specific example is for config_options)
option_settings:
- namespace: 'aws:elasticbeanstalk:container:php:phpini':
option_name: document_root
value: /laravel/public
or shorthand YAML as you are using
option_settings:
aws:elasticbeanstalk:container:php:phpini:
document_root: /laravel/public
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions-optionsettings.html
Also a simple thing but is the .ebextensions folder in the source root and the options.config in the .ebextensions folder? http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions.html
This is an old issue (the link) but as it is said in this link:
Having said that, we were concerned when a number of our customers
began reporting issues with setting the Document Root environment
configuration. Many of these environments were inexplicably "going
red" and failing to update correctly under certain conditions. After
some digging, we discovered that while the configuration settings were
being written correctly during a configuration update, they weren't
being written correctly when a new instance was launched (via Auto
Scaling, the AWS Toolkit for Eclipse, or otherwise).
I think your problem is not the configuration, but may be the AMI you are using, which AMI is it? The updated AMI version is:
Amazon Linux 2012.03
Could you please verify your AMI version? Maybe you are using an old custom one?
EDIT
Also in this link, it says there is a document root configuration in the AWS EB PHP console:
To access the configuration options for your PHP environment
1) Open the Elastic Beanstalk console.
2) Navigate to the management console for your environment.
3) Choose Configuration.
4) In the Software Configuration section, choose Edit.
PHP Settings
Document root – The folder that contains your site's default page. If
your welcome page is not at the root of your source bundle, specify
the folder that contains it relative to the root path. For example,
/public if the welcome page is in a folder named public.
Maybe you can configure it from the dashboard?

AWS No Environment found for EnvironmentName = 'name-env'

Why might I be seeing this error after I run git aws.push?
remote: error: Unable to deploy application version: No Environment found for EnvironmentName = 'reco-api-env'.
When I grep my flask app's directory for EnvironmentName, I see this:
./.elasticbeanstalk/config:6:EnvironmentName=name-env
./.git/AWSDevTools/aws/elastic_beanstalk_config.rb:36: :environment_name => "EnvironmentName",
I had similar symptoms when I manually updated default_region from us-west-2 to us-west-1. Reverting back fixed the issue.
I suspect you missed a step in the process. You need to use eb start before doing git aws.push.
I was using eb create to setup a new environment where the name differed from what I had started with in /.elasticbeanstalk/config.yml
Once I updated the environment reference to the one one I meant to target, eb commands started working as expected.
I had this issue too. For me, it was because I had outdated credentials in my ~/.aws/config file. Fixing that solved the problem.