Skip to content

Commit 6c15df4

Browse files
committed
bugfix: split awn arn correctly
1 parent 30e7914 commit 6c15df4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/server/utils/wallets/awsKmsArn.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
* Split an AWS KMS ARN into its parts.
33
*/
44
export function splitAwsKmsArn(arn: string) {
5+
// arn:aws:kms:<region>:<account-id>:key/<key-id>
56
const parts = arn.split(":");
7+
const keyId = parts[parts.length - 1].split("/")[1];
8+
9+
if (!keyId) {
10+
throw new Error("Invalid AWS KMS ARN");
11+
}
612

713
if (parts.length < 6) {
814
throw new Error("Invalid AWS KMS ARN");
@@ -11,7 +17,7 @@ export function splitAwsKmsArn(arn: string) {
1117
return {
1218
region: parts[3],
1319
accountId: parts[4],
14-
keyId: parts[parts.length - 1],
20+
keyId,
1521
};
1622
}
1723

0 commit comments

Comments
 (0)