MissingCredentialsError on a simple S3 bucket rails app

Hello,

I am able to upload an image to S3 in a rails app when in development.

However when I deployed my app to Render I get the follower error message: Aws::Sigv4::Errors::MissingCredentialsError (missing credentials, provide credentials with one of the following options::access_key_id and :secret_access_key :credentials :credentials_provider).

I am manually deploying my app and I do not use render.yml.

I have set the environment variables ACCESS_KEY_ID, SECRET_ACCESS_KEY, and SECRET_BASE_KEY via the Render Dashboard.

Below is my storage.yml file
test:
service: Disk
root: <%= Rails.root.join(“tmp/storage”) %>

I used S3 as store to test out my settings and I can upload to S3 from my development environment

local:
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: us-east-2
bucket: dennis-testing-rails

Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)

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: us-east-2
bucket: dennis-testing-rails

I added this section on the off chance that Render was looking for something under the heading or ‘production’

production:
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: us-east-2
bucket: dennis-testing-rails

Any guidance will be appreciated.

Dennis

Hi,

I am replying to my own post. I found the solution. The key is to use AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY rather than ACCESS_KEY_ID and SECRET_ACCESS_KEY. So that is different than my development environment which was happy with ACCESS_KEY_ID and SECRET_ACCESS_KEY.

I got the idea of using the AWS_ prefixed environment variable names from the question: Cannot load security credentials for AWS SDK. I think my previous attempts at searching for an answer on this forum were hindered by my including “rails” in my search terms. Going with just “AWS” got me on the path to finding the solution.

If someone could comment on why the environment variables changed names going from Development to Production I would greatly appreciate it.

Thanks,
Dennis

Hi there,

Glad to hear you found a solution to your issue.

It looks like you’re mixing environment variables an Rails credentials, so maybe something was misconfigured for production? I wouldn’t know for sure.

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.