Why can't I write a file with .ebextensions on Elastic Beanstalk?
Asked Answered
T

1

5

I can't write a file with .ebextensions in /etc/httpd/conf.d/elasticbeanstalk. I need to write a vhost.conf to add subdomains. I am on I tried many ways : write the file with "files:..."

files:
  "/etc/httpd/conf.d/elasticbeanstalk":
    mode: "000777"
    owner: root
    group: root
    encoding: plain
    content: |
      NameVirtualHost *:80
  
      <VirtualHost *:80>
        ServerName api.domain.com
        DocumentRoot "/var/app/current/api/"
        <Directory "/var/app/current/api">
          AllowOverride All
          Require all Granted
        </Directory>
      </VirtualHost>

Then i tried to write this file in temporary directory and copy it with a command to /etc/httpd/conf.d/elasticbeanstalk

files:
  "/home/ec2-user/vhost.conf":
    mode: "000777"
    owner: root
    group: root
    encoding: plain
    content: |
      NameVirtualHost *:80

      <VirtualHost *:80>
        ServerName api.domain.com
        DocumentRoot "/var/app/current/api/"
        <Directory "/var/app/current/api">
          AllowOverride All
          Require all Granted
        </Directory>
      </VirtualHost>

container_commands:
  00_chmod:
    command: "sudo chmod 777 /etc/httpd/conf.d/elasticbeanstalk"
  01_rewrite:
    command: "sudo mv -f /home/ec2-user/vhost.conf /etc/httpd/conf.d/elasticbeanstalk/vhost.conf"
  02_apache:
    command: "sudo apachectl restart"

Not working too. So I checked some infos on ec2 instance with SSH. The file is create in /home/ec2-user but not in the apache folder. What am i doing wrong ? I can't create files in /etc/httpd/conf.d/elasticbeanstalk without chmod the directory (SSH).

I am on PHP 7.4 running on 64bit Amazon Linux 2/3.1.1 (proxy apache not nginx), I have the exact same directory .ebextension with same files on an other instance for an other application but on PHP 7.2 running on 64bit Amazon Linux/2.9.10, and it's working on this one ! what the difference betwwen those 2 env ?

EDIT : I have no error in logs, all commands are executed !

Thank you for any help !

Tehuantepec answered 15/9, 2020 at 17:6 Comment(0)
T
10

Ok i found solution ! On platform 3.X we have to put this configaration in .platform folders, no more in .ebextensions folder. This can help : https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.migration-al.html

Tehuantepec answered 15/9, 2020 at 18:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.