Skip to content

NLog - log to different Account than other AWS Services use. #311

Answered by gwilczura
gwilczura asked this question in Q&A
Discussion options

You must be logged in to vote

I managed to solve my own issue :)

Most important part - I have removed from environmaneVariables the AWS_PROFILE.

I have added in appsettings.json:

  "Aws": {
    "DefaultProfile": "localstack",
    "LogsProfile": "my-other-profile"
  }

For the SNS, SQS and Secrets I'm now using code like this:

  var chain = new CredentialProfileStoreChain();
  var credentialsResult = chain.TryGetAWSCredentials(awsOptions.DefaultProfile, out var awsCredentials);

and for the NLog now the standard configuration works.
I have it now in code:

var profile = awsOptions.LogsProfile;

var awsTarget = new AWSTarget()
{
    LogGroup = "some-log-group",
    Region = region.SystemName,
    Profile = profile
};

An…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gwilczura
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant