Get $50+ off for Black Friday!

We've moved discussions to Discord

Digital Ocean Spaces for Storage?

Dan Tappin •
Can you use (without jumping through many hoops) Spaces for storage in Jumpstart?
Chris Oliver •
Yep! Just add this to config/storage.yml:

digital_ocean:
  service: S3
  access_key_id: <SPACES_KEY>
  secret_access_key: <SPACES_SECRET_KEY>
  region: nyc3
  bucket: <SPACES_NAME>
  endpoint: 'https://nyc3.digitaloceanspaces.com'

Adjust all those values to match your Spaces configuration and you can then change your app to use "digital_ocean".

  config.active_storage.service = :digital_ocean
Dan Tappin •
👍
Dan Weaver •
Chris Oliver  Does the same go for Wasabi too? They also have an S3-compatible interface.
Dan Tappin •
Don't forget:

gem 'aws-sdk-s3'

Also I was easily confused by the 'Endpoint' link at the top of the Spaces name.  I mistakenly copied that one for the config.

It should be the one below:

"The endpoint is used to configure 3rd party clients, which may refer to it by other names such as the S3 Endpoint or Server."


Chris Oliver •
Dan Weaver yeah probably. Never used it though.
Brian Carpenter •
I'm having an issue getting Digital Ocean spaces working.  It seems that the credentials cant be found in my deployment.  I'm a few hours in and can't figure out what the issue is.  

Does anyone have any thoughts or see something I'm missing?



Puma log file:
Unable to load application: Aws::Sigv4::Errors::MissingCredentialsError: missing credentials, provide credentials with one of the following options:
Feb 05 03:33:25:   - :access_key_id and :secret_access_key
Feb 05 03:33:25:   - :credentials
Feb 05 03:33:25:   - :credentials_provider


Gem file
gem 'aws-sdk-s3'

config/storage.yml

digitalocean_spaces:
  service: S3
  access_key_id: <%= Rails.application.credentials.dig(:digitalocean_spaces, :access_key_id) %>
  secret_access_key: <%= Rails.application.credentials.dig(:digitalocean_spaces, :secret_access_key) %>
  region: nyc3
  endpoint: 'https://nyc3.digitaloceanspaces.com'
  bucket: foobar-bucket

environments/production.rb
config.active_storage.service = :digitalocean_spaces

credentials.ymc.enc

digitalocean_spaces:
  access_key_id: foobar
  secret_access_key: secretfoobar


Chris Oliver •
If you have a config/credentials/production.yml.enc it will take precedence. You should always use that anyways to keep credentials separate for each environment. 👍
Brian Carpenter •
Thanks, this was my issue.  Was not using the --environment flag when editing the credentials file.
Notifications
You’re not receiving notifications from this thread.