Skip to content

Commit a41041e

Browse files
authored
[FYST-2147] Utilize the correct s3 buckets for active storage (#40)
* Add staging config (copy of prod with s3 difference -- will refactor) * Add heroku environment configs * Add aws-sdk-s3 for active storage * Remove env specific configuration, rather use production config for all env & differentiate s3 storage based on env * Only utilize ENV["S3_BUCKET_ENV"] to determine which bucket is being used
1 parent c8be1a1 commit a41041e

4 files changed

Lines changed: 27 additions & 2 deletions

File tree

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ gem "solid_cache"
2828
gem "solid_queue"
2929
gem "solid_cable"
3030

31+
gem "aws-sdk-s3", require: false
32+
3133
# Reduces boot times through caching; required in config/boot.rb
3234
gem "bootsnap", require: false
3335

Gemfile.lock

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ GEM
8989
ast (2.4.3)
9090
autoprefixer-rails (10.4.21.0)
9191
execjs (~> 2)
92+
aws-eventstream (1.2.0)
93+
aws-partitions (1.851.0)
94+
aws-sdk-core (3.186.0)
95+
aws-eventstream (~> 1, >= 1.0.2)
96+
aws-partitions (~> 1, >= 1.651.0)
97+
aws-sigv4 (~> 1.5)
98+
jmespath (~> 1, >= 1.6.1)
99+
aws-sdk-kms (1.72.0)
100+
aws-sdk-core (~> 3, >= 3.184.0)
101+
aws-sigv4 (~> 1.1)
102+
aws-sdk-s3 (1.136.0)
103+
aws-sdk-core (~> 3, >= 3.181.0)
104+
aws-sdk-kms (~> 1)
105+
aws-sigv4 (~> 1.6)
106+
aws-sigv4 (1.6.1)
107+
aws-eventstream (~> 1, >= 1.0.2)
92108
base64 (0.3.0)
93109
bcrypt_pbkdf (1.1.1)
94110
bcrypt_pbkdf (1.1.1-arm64-darwin)
@@ -179,6 +195,7 @@ GEM
179195
jbuilder (2.13.0)
180196
actionview (>= 5.0.0)
181197
activesupport (>= 5.0.0)
198+
jmespath (1.6.2)
182199
jquery-rails (4.6.0)
183200
rails-dom-testing (>= 1, < 3)
184201
railties (>= 4.2.0)
@@ -459,6 +476,7 @@ PLATFORMS
459476
x86_64-linux-musl
460477

461478
DEPENDENCIES
479+
aws-sdk-s3
462480
bootsnap
463481
brakeman
464482
capybara

config/environments/production.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
2222
# config.asset_host = "http://assets.example.com"
2323

24-
# Store uploaded files on the local file system (see config/storage.yml for options).
25-
config.active_storage.service = :local
24+
config.active_storage.service = :s3
2625

2726
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
2827
config.assume_ssl = true

config/storage.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,9 @@ local:
3232
# service: Mirror
3333
# primary: local
3434
# mirrors: [ amazon, google, microsoft ]
35+
36+
# AWS credentials and S3_BUCKET come from the AWS fargate service module via OpenTofu for staging/production
37+
# AWS credentials and S3_BUCKET for heroku environment are defined via Config Vars on the heroku pya pipeline
38+
s3:
39+
service: S3
40+
bucket: <%= ENV["S3_BUCKET"] %>

0 commit comments

Comments
 (0)