-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add log group glob support. Fixes #3
- Loading branch information
Showing
5 changed files
with
127 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
release: | ||
.PHONY: build | ||
build: | ||
npm run build | ||
|
||
.PHONY: test | ||
test: | ||
npm test | ||
|
||
.PHONY: release | ||
release: build test | ||
|
||
.PHONY: publish | ||
publish: | ||
npm publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { | ||
CloudWatchLogsClient, | ||
DescribeLogGroupsCommand, | ||
DescribeLogGroupsCommandOutput | ||
} from "@aws-sdk/client-cloudwatch-logs"; | ||
|
||
export const getLogGroupsByPrefix = async(logGroupPrefix: string, client: CloudWatchLogsClient): Promise<string[]> => { | ||
const logGroups: string[] = []; | ||
|
||
let response: DescribeLogGroupsCommandOutput = { | ||
$metadata: {} | ||
}; | ||
do { | ||
response = await client.send(new DescribeLogGroupsCommand({ | ||
logGroupNamePrefix: logGroupPrefix, | ||
nextToken: response.nextToken | ||
})); | ||
|
||
const matchingLogGroups = response.logGroups; | ||
if (!matchingLogGroups) { | ||
throw new Error(`No log groups found for prefix ${logGroupPrefix}`); | ||
} | ||
|
||
logGroups.push(...matchingLogGroups.map(g => g.logGroupName!)); | ||
} while (response.nextToken) | ||
|
||
return logGroups; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters