Jeff
Jeff

Reputation: 36583

AWS API Get Any Resource By ARN

I have a bunch AWS resource ARNs. I can easily write a switch/case statement on the namespace of the ARN and call the appropriate describeXYZ method on the correct AWS API class to get the resource details. But is there a way of taking any arbitrary ARN and getting a description for it? Something like aws.describeResource({arn:myArn}, callback)?

Upvotes: 21

Views: 6524

Answers (1)

Max Hanglin
Max Hanglin

Reputation: 306

I don't know what description exactly you are looking for, I don't know of the existence of such service. However, the ARN itself includes some information that could or could not be helpful to you, if you parse it, you could get at least:

  • Service
  • Region
  • Account ID
  • Type of Resource
  • Resource Name

For example

arn:aws:iot:us-west-2:27401367543654:policy/MyApplicationDefaultPolicy
         ^      ^          ^           ^                ^
         |      |          |           |                |
      Service Region   AccountID  ResourceType     ResourceName

Sorry if this is not enough, is the best I can think of right now.

From here you can get a more detailed description: http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#genref-arns

arn:partition:service:region:account-id:resource
arn:partition:service:region:account-id:resourcetype/resource
arn:partition:service:region:account-id:resourcetype:resource

Upvotes: 6

Related Questions