DEV Community

n350071πŸ‡―πŸ‡΅
n350071πŸ‡―πŸ‡΅

Posted on • Edited on

extract_credentials_provider': Cannot load `Rails.config.active_storage.service`: (Aws::Sigv4::Errors::MissingCredentialsError)

Check followings

seting to use credential.yml.enc with master.key in production

config/environments/production.rb

# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
config.require_master_key = true

setting the credential.yml.enc

EDITOR="vim" rails credentials:edit

(you may need to install vim)

Dockerfile

## install vim
RUN apt-get update && apt-get install apt-file -y && apt-file update && apt-get install vim -y

active_storage setting

config/environments/production.rb

config.active_storage.service = :amazon

config/storage.yml

amazon:
  service: S3
  access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
  secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
  region: xxxxxxxxxxxxxxxxxx
  bucket: xxxxxxxxxxxxxxxxxx

Make it sure works on Rails console(local

[1] pry(main)> Rails.application.credentials.dig(:aws, :access_key_id)
"xxxxxxxxxxxxxx"

switch the setting of the strage strategy on Development

to make sure S3 setting is right.

If it works completely, the problem must be in Heroku.

  # Store uploaded files on the local file system (see config/storage.yml for options).
  # config.active_storage.service = :local
  config.active_storage.service = :amazon

put the value of master.key into Heroku config

heroku config:set RAILS_MASTER_KEY=`cat config/master.key`

Top comments (2)

Collapse
 
n350071 profile image
n350071πŸ‡―πŸ‡΅

Oh, I'm sorry. I forgot to mention the option -a.

heroku [command] -a [app-name]

If you already added your heroku git on your git remote repositories, you can omit the option -a.

git remote -v
heroku  https://git.heroku.com/eventer-prototype.git (fetch)
heroku  https://git.heroku.com/eventer-prototype.git (push)
origin  git@github.com:n350071/eventer.git (fetch)
origin  git@github.com:n350071/eventer.git (push)

I will also remove the -a option from this post to avoid making confusing.

Collapse
 
n350071 profile image
n350071πŸ‡―πŸ‡΅

I use Mac OS X. cat path/to/file.key with backquote works on bash. But I'm not sure it works on Windows.
Perhaps, You'd better type the dos command instead, or use the signature directly.