Rails configurations in S3

Amrit Pal Singh
1 min readFeb 28, 2021

Rails configurations (database.yml, config.yml, etc.) are well defined and powerful tools. If the same configurations are used across multiple projects it becomes a pain to edit and manage the same files in multiple repositories.

Well in such cases it makes sense to store the configurations in one place and all the projects use this location to get the configurations. We chose to store these files in S3.

Step 1

Store files in S3.

Step 2

Create a new config file config/file_locations.yml in the project which stores the locations of other configuration files which are stored in S3.

This file specifies the bucket from which you want to fetch the configurations and key and local file path of the configuration files.

Step 3

Add gem ‘aws-sdk’ to Gemfile and run bundle install.

Step 4

Add the above code in “config/application.rb”. This code downloads the config files before the rails server runs.

--

--

Amrit Pal Singh

Cloud Software Engineer | Product Development | I write about Tech and Travel | Profile https://bit.ly/3dNxaiK | Golang Web Dev Course - https://bit.ly/go-gin