generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 15
feat: Extract resource arn and remote resource access key for cross-account support #192
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f1fe3a7
Extract arn and account access key
blairhyy-amazon 896204c
Generate cross-account metric attributes
blairhyy-amazon 1c92ea9
Add contract tests
blairhyy-amazon 6a4bfe1
improve data checking; update queue url & arn parser
blairhyy-amazon 2b61ba8
lint
blairhyy-amazon 4d29de0
update sql parser to split only once
blairhyy-amazon d28721d
remove length check for account id & move resource extraction into ar…
blairhyy-amazon 0ffb21f
add parseArn helper function; address minor comments
blairhyy-amazon df21b74
add docstring & refactor isAccountId
blairhyy-amazon a73648a
lint & update unit test
blairhyy-amazon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
38 changes: 38 additions & 0 deletions
38
aws-distro-opentelemetry-node-autoinstrumentation/src/regional-resource-arn-parser.ts
This file contains hidden or 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,38 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { AttributeValue } from '@opentelemetry/api'; | ||
| import { isAccountId } from './utils'; | ||
|
|
||
| export class RegionalResourceArnParser { | ||
| /** Parses ARN with formats: | ||
| * arn:partition:service:region:account-id:resource-type/resource-id or | ||
| * arn:partition:service:region:account-id:resource-type:resource-id | ||
| */ | ||
| private static parseArn(arn: AttributeValue | undefined): string[] | undefined { | ||
| if (typeof arn !== 'string') return undefined; | ||
| const parts = arn.split(':'); | ||
| return parts.length >= 6 && parts[0] === 'arn' && isAccountId(parts[4]) ? parts : undefined; | ||
| } | ||
|
|
||
| public static getAccountId(arn: AttributeValue | undefined): string | undefined { | ||
| return this.parseArn(arn)?.[4]; | ||
| } | ||
|
|
||
| public static getRegion(arn: AttributeValue | undefined): string | undefined { | ||
| return this.parseArn(arn)?.[3]; | ||
| } | ||
|
|
||
| public static extractDynamoDbTableNameFromArn(arn: AttributeValue | undefined): string | undefined { | ||
| return this.extractResourceNameFromArn(arn)?.replace('table/', ''); | ||
| } | ||
|
|
||
| public static extractKinesisStreamNameFromArn(arn: AttributeValue | undefined): string | undefined { | ||
| return this.extractResourceNameFromArn(arn)?.replace('stream/', ''); | ||
| } | ||
|
|
||
| public static extractResourceNameFromArn(arn: AttributeValue | undefined): string | undefined { | ||
| const parts = this.parseArn(arn); | ||
| return parts?.[parts.length - 1]; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.