Skip to content

Commit

Permalink
fix: Accomodate server to use IAM Roles
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Jan 16, 2023
1 parent 1e1449d commit f15ca2d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/S3/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { env, utils, Log } from 'decentraland-commons'

const ACCESS_KEY = env.get('AWS_ACCESS_KEY', '')
const ACCESS_SECRET = env.get('AWS_ACCESS_SECRET', '')
if (!ACCESS_KEY || !ACCESS_SECRET) {
if ((ACCESS_KEY && !ACCESS_SECRET) || (!ACCESS_KEY && ACCESS_SECRET)) {
throw new Error(
'You need to add an AWS key and secret to your env file. Check the .env.example file'
'The ACCESS_KEY and ACCESS_SECRET credentials must be provided at the same time.'
)
}

Expand Down Expand Up @@ -36,9 +36,14 @@ export type ACLValues = typeof ACL[keyof typeof ACL]

const log = new Log('s3')

let config: AWS.S3.ClientConfiguration = {
accessKeyId: ACCESS_KEY,
secretAccessKey: ACCESS_SECRET,
let config: AWS.S3.ClientConfiguration = {}

if (ACCESS_KEY && ACCESS_SECRET) {
config = {
...config,
accessKeyId: ACCESS_KEY,
secretAccessKey: ACCESS_SECRET,
}
}

if (STORAGE_URL) {
Expand Down

0 comments on commit f15ca2d

Please sign in to comment.