question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to set aws credentials in v3.2.0

See original GitHub issue
const logger = winston.createLogger({
   transports: [
      new WinstonCloudWatch({
         name: `/my-log/${stage}`,
         logGroupName: `/aws/s3/${repoName}`,
         logStreamName: 'log-stream',
         awsRegion: 'ap-northeast-2',
         awsAccessKeyId: stage === 'prod' ? process.env.PROD_ACCESS_KEY_ID : process.env.DEV_ACCESS_KEY_ID,
         awsSecretKey: stage === 'prod' ? process.env.PROD_SECRET_ACCESS_KEY : process.env.DEV_SECRET_ACCESS_KEY
      })
   ]
})

In winston-cloudwatch v3.1.1 with aws-sdk v2 you could set the awsAccessKeyId, awsSecretKey options. However, in winston-cloudwatch v3.2.0 using aws-sdk v3, even setting the awsAccessKeyId and awsSecretKey options causes the credentials error as shown below.

image

You’re probably looking at the credentials set in your .aws/credentials file. I want to be able to set the awsAccessKeyId and awsSecretKey in the winston-cloudwatch option, without the .aws/credentials file.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
nikhilrajaramcommented, Jun 22, 2022

I have been able to circumvent this by specifying the CloudWatchLogsClientConfig directly though awsOptions

new WinstonCloudWatch({
  ...,
  awsOptions: {
    credentials: {
      accessKeyId,
      secretAccessKey,
    },
    region,
  }
})
1reaction
lazywithclasscommented, Jul 19, 2022

Done https://github.com/lazywithclass/winston-cloudwatch/blob/master/README.md#credentials

Thanks for the help everyone, it’s much appreciated!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting Credentials in Node.js - AWS SDK for JavaScript
Credentials that are explicitly set through the service-client constructor. Environment variables. The shared credentials file. Credentials loaded from the ECS ...
Read more >
Issues - GitHub
aws /credentials that refers to a role_arn and another source_profile, v3 of the SDK fails to assume the role where-as v2 of the...
Read more >
How to set credentials in AWS SDK v3 JavaScript?
I was trying to dig up my code that I have. I'll post it to see where I'm going wrong. · 1. Also,...
Read more >
How to fix the profile support in the AWS JS SDK v3
Two months ago, AWS released the v3 of the Javascript SDK. ... For example, this is a set of credentials configured for the...
Read more >
Setup AWS credentials and configuration
If you used option 2 or option 3 then you have put your credentials into files that will be used by the AWS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found