Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring AWS Elastic Beanstalk Timezone for Auto Scaling

I have a single instance server deployed on AWS - Elastic Beanstalk that needs timezone configuration, and I changed the timezone as logging into the EC2 environment with ssh, and update it with the linux commands listed below;

sudo rm /etc/localtime
sudo ln -sf /usr/share/zoneinfo/Europe/Istanbul /etc/localtime
sudo reboot

Everything is fine as the server is running as a single instance. The problem arose as I wanted to use Auto Scaling, Load Balancing feature. On single instance, updating the timezone on linux AMI is fine, but on auto scaling mode, because that the instances are created/destroyed/recreated according to the threshold metrics, all the configuration is lost.

My simple question is, how can I change/configure the timezone for an auto scalable, load balancing mode in AWS Elastic Beanstalk ?

like image 400
Levent Divilioglu Avatar asked Dec 09 '22 02:12

Levent Divilioglu


2 Answers

you can configure the newly starting server with ebextensions.
Here's an example that works for me. Add the following command into the file .ebextensions/timezone.config:

commands:
    set_time_zone:
        command: ln -f -s /usr/share/zoneinfo/US/Pacific /etc/localtime 
like image 174
Tal Avatar answered Apr 30 '23 00:04

Tal


The answers here only managed to work for me partially (I had errors deploying when using the answers above). After some modifications, the following worked for me. I believe it has something to do with "cwd" and "permissions".

commands:
  0000_0remove_localtime:
    command: rm -rf /etc/localtime
  0000_1change_clock:
    command: sed -i 's/UTC/Asia\/Singapore/g' /etc/sysconfig/clock
    cwd: /etc/sysconfig
  0000_2link_singapore_timezone:
    command: ln -f -s /usr/share/zoneinfo/Asia/Singapore /etc/localtime
    cwd: /etc
like image 32
Tikiboy Avatar answered Apr 29 '23 23:04

Tikiboy