How can I override the log rotation configuration file for Nginx on AWS Elastic Beanstalk?

108 views Asked by At

I have an Elastic Beanstalk project where I am utilizing S3 log rotation for my environment. I would like to modify the "/etc/logrotate.elasticbeanstalk.hourly/logrotate.elasticbeanstalk.nginx.conf" file as I need to apply custom log rotation settings.

I am trying the command below in my .ebextension/02_log_settings.config file, but it is not working at all. I am unable to override the initial file located at "/etc/logrotate.elasticbeanstalk.hourly/logrotate.elasticbeanstalk.nginx.conf".

02_log_settings.config file:

files:

  # log rotate nginx logs
  "/etc/logrotate.elasticbeanstalk.hourly/logrotate.elasticbeanstalk.nginx.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
      /var/log/nginx/* {
        su root root
        size 10M
        rotate 14
        missingok
        compress
        notifempty
        copytruncate
        dateext
        dateformat %Y%m%d%H  
        olddir /var/log/nginx/rotated
      }      
0

There are 0 answers