Added IAM support
This commit is contained in:
21
src/util/breakdown-arn.ts
Normal file
21
src/util/breakdown-arn.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
export type ArnParts = {
|
||||
service: string;
|
||||
region: string;
|
||||
accountId: string;
|
||||
identifier: string;
|
||||
}
|
||||
|
||||
export const breakdownArn = (arn: string): ArnParts => {
|
||||
if (!arn.startsWith('arn')) {
|
||||
throw new Error('Invalid arn');
|
||||
}
|
||||
|
||||
const [_arn, _aws, service, region, accountId, ...identifierData] = arn.split(':');
|
||||
|
||||
return {
|
||||
service,
|
||||
region,
|
||||
accountId,
|
||||
identifier: identifierData.join(':'),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user