I've got an express service that is trying to write an object to an s3 bucket but I'm getting the following error:
Missing credentials in config
I'm assuming my AWS role locally which sets my credentials in .aws/credentials
then in my Dockerfile I am copying them into my container.
RUN mkdir "/home/node/.aws" && touch "/home/node/.aws/config" && touch "/home/node/.aws/credentials"
RUN echo "${AWS_CREDENTIALS}" > "/home/node/.aws/credentials"
The documentation says:
The SDK automatically detects AWS credentials set as variables in your environment and uses them for SDK requests, eliminating the need to manage credentials in your application. The environment variables that you set to provide your credentials are:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_SESSION_TOKEN (optional)
So I don't have to manually manage my credentials when using the sdk?
Currently the code for writing to the s3 bucket:
import s3 from 'aws-sdk/clients/s3';
const s3Client = new s3({region: process.env['region']});
async upload() {
const params = {
Bucket: process.env['bucket'],
Key: 'test.json',
Body: somejsonfile
}
const res = s3Client.upload(params).promise();
return results;
}