Prerequisite: ElasticBeanstalk
Usecase:
Application code was using default server timezone and requirement was to have specific timezone in place and application was hosted on AWS PAAS i.e elasticbeanstalk.
There are two ways that you could run custom script on elasticbeanstalk platform before the deployment[1].
- Platform hook scripts
- .ebextensions configuration file
- It will change the default timezone to US/Eastern timezone
Application source bundle:
.
├── .ebextensions
│ └── timezone.config
│ └── nginx-settings.config
├── .elasticbeanstalk
│ └── config.yml
├── .gitignore
├── app.js
├── cron.yaml
├── index.html
└── package.json
The contents of 'timezone.config' should be as follows in YAML format :
commands:
command block:
command: |
link=$(readlink -f /etc/localtime)
if [[ $link != "/usr/share/zoneinfo/US/Eastern" ]]; then
ln -f -s /usr/share/zoneinfo/US/Eastern /etc/localtime
echo "Time Zone US/Eastern"
fi
The contents of 'nginx-settings.config' should be as follows in YAML format :
files:
"/etc/nginx/conf.d/nginx-settings.conf":
mode: "00644"
owner: "root"
group: "root"
content: |
client_max_body_size 10M;
container_commands:
01_restart_nginx:
command: "sudo service nginx restart"
0 Comments