Skip to content

Commit

Permalink
Updating configuration to work in local dev environments (#1778)
Browse files Browse the repository at this point in the history
Co-authored-by: Hector Correa <[email protected]>
Co-authored-by: Hector Correa <[email protected]>
  • Loading branch information
3 people authored Apr 22, 2024
1 parent 9c0afc8 commit 65e2031
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 2 additions & 8 deletions app/services/s3_query_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,12 @@ def file_url(key)
signer.presigned_url(:get_object, bucket: bucket_name, key:)
end

# There is probably a better way to fetch the current ActiveStorage configuration but we have
# not found it.
def active_storage_configuration
Rails.configuration.active_storage.service_configurations[Rails.configuration.active_storage.service.to_s]
end

def access_key_id
active_storage_configuration["access_key_id"]
S3QueryService.configuration["access_key_id"]
end

def secret_access_key
active_storage_configuration["secret_access_key"]
S3QueryService.configuration["secret_access_key"]
end

def credentials
Expand Down
8 changes: 8 additions & 0 deletions config/s3.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
production:
access_key_id: <%= ENV['AWS_S3_KEY_ID'] || 'not-used-access_key_id' %>
secret_access_key: <%= ENV['AWS_S3_SECRET_KEY'] || 'not-used-secret_access_key' %>
pre_curation:
bucket: <%= ENV['AWS_S3_PRE_CURATE_BUCKET'] || 'example-bucket' %>
region: <%= ENV['AWS_S3_PRE_CURATE_REGION'] || 'us-east-1' %>
Expand All @@ -13,6 +15,8 @@ production:
bucket: <%= ENV['AWS_S3_DSPACE_BUCKET'] || 'example-bucket' %>
region: <%= ENV['AWS_S3_DSPACE_REGION'] || 'us-east-1' %>
staging:
access_key_id: <%= ENV['AWS_S3_KEY_ID'] || 'not-used-access_key_id' %>
secret_access_key: <%= ENV['AWS_S3_SECRET_KEY'] || 'not-used-secret_access_key' %>
pre_curation:
bucket: <%= ENV['AWS_S3_PRE_CURATE_BUCKET'] || 'example-bucket' %>
region: <%= ENV['AWS_S3_PRE_CURATE_REGION'] || 'us-east-1' %>
Expand All @@ -26,6 +30,8 @@ staging:
bucket: <%= ENV['AWS_S3_DSPACE_BUCKET'] || 'example-bucket' %>
region: <%= ENV['AWS_S3_DSPACE_REGION'] || 'us-east-1' %>
development:
access_key_id: <%= ENV['AWS_S3_KEY_ID'] || 'not-used-access_key_id' %>
secret_access_key: <%= ENV['AWS_S3_SECRET_KEY'] || 'not-used-secret_access_key' %>
pre_curation:
bucket: <%= ENV['AWS_S3_PRE_CURATE_BUCKET'] || 'example-bucket' %>
region: <%= ENV['AWS_S3_PRE_CURATE_REGION'] || 'us-east-1' %>
Expand All @@ -39,6 +45,8 @@ development:
bucket: <%= ENV['AWS_S3_DSPACE_BUCKET'] || 'example-bucket' %>
region: <%= ENV['AWS_S3_DSPACE_REGION'] || 'us-east-1' %>
test:
access_key_id: 'not-used-access_key_id'
secret_access_key: 'not-used-secret_access_key'
pre_curation:
bucket: 'example-bucket'
region: 'us-east-1'
Expand Down

0 comments on commit 65e2031

Please sign in to comment.