-
Notifications
You must be signed in to change notification settings - Fork 737
fix(cwl): Pass in active credentials when creating CWL client for LiveTail #5993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ import { | |
| LiveTailSessionUpdate, | ||
| StartLiveTailResponseStream, | ||
| } from '@aws-sdk/client-cloudwatch-logs' | ||
| import { getLogger, ToolkitError } from '../../../shared' | ||
| import { getLogger, globals, ToolkitError } from '../../../shared' | ||
| import { uriToKey } from '../cloudWatchLogsUtils' | ||
|
|
||
| export async function tailLogGroup( | ||
|
|
@@ -25,12 +25,16 @@ export async function tailLogGroup( | |
| if (!wizardResponse) { | ||
| throw new CancellationError('user') | ||
| } | ||
|
|
||
| const awsCredentials = await globals.awsContext.getCredentials() | ||
| if (awsCredentials === undefined) { | ||
| throw new ToolkitError('Failed to start LiveTail session: credentials are undefined.') | ||
| } | ||
| const liveTailSessionConfig: LiveTailSessionConfiguration = { | ||
| logGroupArn: wizardResponse.regionLogGroupSubmenuResponse.data, | ||
| logStreamFilter: wizardResponse.logStreamFilter, | ||
| logEventFilterPattern: wizardResponse.filterPattern, | ||
| region: wizardResponse.regionLogGroupSubmenuResponse.region, | ||
| awsCredentials: awsCredentials, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would it make sense to call
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I explored that. But ran into an issue. We currently build & set the CWL client on the Something I just considered is that we could maybe construct and set the CWL client only when
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We usually add a |
||
| } | ||
| const session = new LiveTailSession(liveTailSessionConfig) | ||
| if (registry.has(uriToKey(session.uri))) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with how this works under the hood. Will it fall back to default credentials if nobody is logged into the toolkit? Or does it require someone to be logged in? If so, maybe we should re-direct them to login with credentials if they do not exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have no selected credential, the explorer side bar will prompt you to add/select one.

If the selected credential is expired, it will say that, and give you an option to re-authenticate.

If your credential is expired/unselected and you try to select TailLogGroup from the command palette, this first picker to select a LogGroup will show

[Error loading Items] Toolkit is not logged in.