This repository has been archived on 2024-09-11. You can view files and clone it, but cannot push or open issues or pull requests.
svrjs-blog-newsletter/cronjob/node_modules/@aws-sdk/util-endpoints/dist-es/lib/aws/parseArn.js
2024-05-26 22:54:55 +02:00

15 lines
497 B
JavaScript

export const parseArn = (value) => {
const segments = value.split(":");
if (segments.length < 6)
return null;
const [arn, partition, service, region, accountId, ...resourceId] = segments;
if (arn !== "arn" || partition === "" || service === "" || resourceId[0] === "")
return null;
return {
partition,
service,
region,
accountId,
resourceId: resourceId[0].includes("/") ? resourceId[0].split("/") : resourceId,
};
};