0

I'm trying to store images from my Node.js Backend to an AWS S3 Bucket. The app is hosted on heroku. This works perfectly fine in my local environment but once I deploy the app to heroku with gitlab CI/CD, I get the following error:

Missing credentials in config, if using AWS_CONFIG_FILE, set 
AWS_SDK_LOAD_CONFIG=1","errno":"ECONNREFUSED","code":"CredentialsError","syscall":"connect"

On my local environment I store the API Keys in an .env file like this:

BUCKET_NAME=XYZ
AWS_KEY_ID=XYZ
AWS_ACCESS_KEY=XYZ

and my Node server gets the variables like this:

const s3 = new AWS.S3({
 accessKeyId: process.env.AWS_KEY_ID,
 secretAccessKey: process.env.AWS_ACCESS_KEY
});
const BUCKET_NAME = process.env.BUCKET_NAME

This works in my local environment. On Gitlab, I store the same variables with the exact same names enter image description here

but I get the above error when I try to store a file.

2

1 Answer 1

0

The env vars need to be present on your Heroku instance.

Sign up to request clarification or add additional context in comments.

3 Comments

I have ENV vars for my Database connection as well, and they are defined in gitlab and work well on heroku.. Why would the AWS vars don't work the same way?
I'm not sure why it works for your DB. Your server runs on Heroku therefore it's Heroku that makes the env vars available to Node.js, not Gitlab.
Thanks, that worked (heroku config:set GITHUB_USERNAME=joesmith from heroku doku)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.