diff --git a/packages/util-endpoints/src/lib/aws/parseArn.spec.ts b/packages/util-endpoints/src/lib/aws/parseArn.spec.ts index 3b715868c92fe..16e0342dae985 100644 --- a/packages/util-endpoints/src/lib/aws/parseArn.spec.ts +++ b/packages/util-endpoints/src/lib/aws/parseArn.spec.ts @@ -74,6 +74,16 @@ describe(parseArn.name, () => { resourceId: ["myTopic"], }, ], + [ + "arn:aws:s3:us-west-2:123456789012:my:folder/my:file", + { + partition: "aws", + service: "s3", + region: "us-west-2", + accountId: "123456789012", + resourceId: ["my", "folder", "my", "file"], + }, + ], ]; it.each(VALID_TEST_CASES)("returns for valid arn %s", (input: string, outout: EndpointARN) => { diff --git a/packages/util-endpoints/src/lib/aws/parseArn.ts b/packages/util-endpoints/src/lib/aws/parseArn.ts index 99ce11f55c654..2c6078b647b57 100644 --- a/packages/util-endpoints/src/lib/aws/parseArn.ts +++ b/packages/util-endpoints/src/lib/aws/parseArn.ts @@ -17,9 +17,7 @@ export const parseArn = (value: string): EndpointARN | null => { if (arn !== "arn" || partition === "" || service === "" || resourcePath.join(ARN_DELIMITER) === "") return null; - const resourceId = resourcePath[0].includes(RESOURCE_DELIMITER) - ? resourcePath[0].split(RESOURCE_DELIMITER) - : resourcePath; + const resourceId = resourcePath.map((resource) => resource.split(RESOURCE_DELIMITER)).flat(); return { partition,