AWS Elastic Beanstalk how to get.ebextensions to write to /etc/httpd/conf.d/ the conf files inside?

671 views Asked by At

Trying to add .conf files to /etc/httpd/conf.d/ directory on the E2 instance from elastic beanstalk during deployment of Elastic Beanstalk Application. I've added the .ebextensions directory with a .config file that is defined as follows:

files:
  "/etc/php.d/project.ini" :
    mode: "000644"
    owner: root
    group: root
    content: |
      max_input_vars = 10000
      upload_max_filesize = 256M
      post_max_size = 256M

container_commands:
  01_enable_mod_deflate:
    command: "cp .ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf"
  02_enable_mod_expires:
    command: "cp .ebextensions/enable_mod_expires.conf /etc/httpd/conf.d/enable_mod_expires.conf"
  03_secure_wordpress:
    command: "cp .ebextensions/secure_wordpress.conf /etc/httpd/conf.d/secure_wordpress.conf"
  04_restart_apache:
    command: "sudo apachectl restart"

the .conf files are all in the .ebextensions folder, but they are not getting copied over, which is causing an issue with .htaccess in the root of the wordpress site. The error that is being generated looks like this:

Command 01_enable_mod_deflate (cp /var/app/current/.ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf) failed 2020-10-05 13:45:59,944 [ERROR] Error encountered during build of postbuild_0_Benefits_Bridge_2: Command 01_enable_mod_deflate failed Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config CloudFormationCarpenter(config, self._auth_config).build(worklog) File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build changes['commands'] = CommandTool().apply(self._config.commands) File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply raise ToolError(u"Command %s failed" % name) ToolError: Command 01_enable_mod_deflate failed

Not sure what any of that even means, but it's generating the same error for each file. What is wrong here? I just spun up a new instance of Elastic Beanstalk and shouldn't this work by default? Is there an issue with the Instance or something? The site is generating a 500 error because of the .htaccess file in the root, but if I remove it, than only the homepage loads and all other pages give 404 errors. I need these .conf files added to the /etc/httpd/conf.d/ directory of all instances, but they aren't added at all to any of the instances because of the error above, which I have no idea how to fix, or if this is an issue with the instance which is the default that gets created with Elastic Beanstalk?

How to fix this problem? I've restarted the Environment, but that didn't help. I'm a bit hestitant to Rebuild the Environment since that will wipe out the database that is connected to the application and not sure if that would help any.

1

There are 1 answers

2
Edu_Godoy On

You are probably using Amazon Linux 2 that changed the location of configuration files for proxy (NGINX or Apache). Put your proxy configuration files under .platform instead of .ebextensions: Ex:

|____wp-signup.php
|____.platform
| |____httpd
| | |____conf.d
| | | |____http-redirect.conf

More details in the documentation:

Migrating your Elastic Beanstalk Linux application to Amazon Linux 2