aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
2.98k stars 560 forks source link

util-arn-parser: Add logic for extracting resource name from various ARN formats #5966

Closed AlJohri closed 3 months ago

AlJohri commented 3 months ago

Describe the feature

This ticket is to bump https://github.com/aws/aws-sdk-js-v3/issues/4243 again as I have run into the exact same use case.

Use Case

I am parsing ECS Service ARNs like arn:aws:ecs:us-east-1:890277807768:service/ecs-all-greek-to-me-beta-us-east-1/DataNode-default-63-idx-1-us-east-1-beta-20240404-163815-770Z.

I want to get the service name and I expected running the following code to work:

import { parse } from '@aws-sdk/util-arn-parser';
parse(arn).resource

However, it only gives me:

service/ecs-all-greek-to-me-beta-us-east-1/DataNode-default-63-idx-1-us-east-1-beta-20240404-163815-770Z

Where as I expected it to give me:

DataNode-default-63-idx-1-us-east-1-beta-20240404-163815-770Z

Proposed Solution

No response

Other Information

No response

Acknowledgements

SDK version used

3.420.0

Environment details (OS name and version, etc.)

AL2

RanVaknin commented 3 months ago

Hi @AlJohri ,

Thanks for reaching out. I have raised this with the team once again and we have decided not the extend the functionality of the arn parser.

Right now the arn parser extracts the resource group so for example arn:partition:service:region:account-id:resource-type/resource-id will result in resource-type/resource-id, which serves its purpose for internal use.

You will be better equipped extracting the part you need from the arn string yourself because you know your specific use case yourself better.

Thanks, Ran~

github-actions[bot] commented 2 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.