Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon Elastic Beanstalk - Change Timezone

I´m running an EC2 instance through AWS Elastic Beanstalk. Unfortunately it has the incorrect timezone - it´s 2 hours earlier than it should be, because timezone is set to UTC. What I need is GMT+1.

Is there a way to set up the .ebextensions configuration, in order to force the EC2 instance to use the right timezone?

like image 569
tomraithel Avatar asked Aug 20 '14 08:08

tomraithel


People also ask

How do I change my AWS timezone?

On the AWS Elemental Server web interface, go to the Settings page and choose General. In Timezone, choose your required time zone. Choose Update.

Does AWS use UTC time?

This service uses a fleet of satellite-connected and atomic reference clocks in each AWS Region to deliver accurate current time readings of the Coordinated Universal Time (UTC) global standard. The Amazon Time Sync Service automatically smooths any leap seconds that are added to UTC.


2 Answers

Yes, you can.

Just create a file /.ebextensions/00-set-timezone.config with following content

commands:   set_time_zone:     command: ln -f -s /usr/share/zoneinfo/Australia/Sydney /etc/localtime 

This is assuming your are using default Amazon Linux AMI image. If you use some other Linux distribution, just change the command to whatever it requires to set timezone in that Linux.

like image 172
victorx Avatar answered Sep 25 '22 02:09

victorx


This is a response from the aws Support Business and this works!

---- Original message ----

How can I change the timezone of an enviroment or rather to the instances of the enviroment in Elastic Beasntalk to UTC/GMT -3 hours (Buenos Aires, Argentina)? I´m currently using Amazon Linux 2016.03. Thanks in advance for your help. Regards.

---------- Response ----------

Hello,Thank you for contacting AWS support regarding modifying your Elastic Beanstalk instances time zone to use UTC/GMT -3 hours (Buenos Aires, Argentina), please see below on steps on how to perform this modification.

The below example shows how to modify timezone for Elastic Beanstalk environment using .ebextensions for Amazon Linux OS:

  1. Create .ebextensions folder in the root of your application
  2. Create a .config file for example 00-set-timezone.config file and add the below content in yaml formatting.

    container_commands:   01changePHP:     command: sed -i '/PHP_DATE_TIMEZONE/ s/UTC/America\/Argentina\/Buenos_Aires/' /etc/php.d/environment.ini   01achangePHP:     command: sed -i '/aws.php_date_timezone/ s/UTC/America\/Argentina\/Buenos_Aires/' /etc/php.d/environment.ini   02change_AWS_PHP:     command: sed -i '/PHP_DATE_TIMEZONE/ s/UTC/America\/Argentina\/Buenos_Aires/' /etc/httpd/conf.d/aws_env.conf   03php_ini_set:     command: sed -i '/date.timezone/ s/UTC/America\/Argentina\/Buenos_Aires/' /etc/php.ini commands:   01remove_local:     command: "rm -rf /etc/localtime"   02link_Buenos_Aires:     command: "ln -s /usr/share/zoneinfo/America/Argentina/Buenos_Aires /etc/localtime"   03restart_http:     command: sudo service httpd restart 
  3. Deploy application to Elastic Beanstalk including the .ebextensions and the timezone will change as per the above.

I hope that helps

Regards!

like image 39
Jesús Díaz Avatar answered Sep 25 '22 02:09

Jesús Díaz