Skip to content

Commit

Permalink
feat(nestjs-storage): Support IAM AWS S3 Credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
tsangste committed Sep 12, 2024
1 parent 6402b1a commit 1912ae1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions libs/nestjs-storage/src/storage.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import { StorageService } from './services/storage.service'
provide: S3Client,
inject: [ConfigService],
useFactory: (config: ConfigService) => {
const accessKeyId = config.get<string>('AWS_ACCESS_KEY_ID')
const secretAccessKey = config.get<string>('AWS_SECRET_ACCESS_KEY')
const credentials = accessKeyId && secretAccessKey ? { accessKeyId, secretAccessKey } : null

return new S3Client({
region: config.get<string>('AWS_REGION', 'eu-west-2'),
credentials: {
accessKeyId: config.get<string>('AWS_ACCESS_KEY_ID', ''),
secretAccessKey: config.get<string>('AWS_SECRET_ACCESS_KEY', '')
}
credentials,
})
}
},
Expand Down

0 comments on commit 1912ae1

Please sign in to comment.