21

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)?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Jeff
  • 35,755
  • 15
  • 108
  • 220
  • What is your exact goal? Are you using `AWS CloudFormation` to manage your resources? If so, you could give [`describe-stack-resources`](http://docs.aws.amazon.com/cli/latest/reference/cloudformation/describe-stack-resources.html) a try. – MaiKaY Jun 20 '17 at 16:03
  • 1
    so I describe stack resources. Now I want to get resource info for each of those. How could I without a switch statement on the resource type to determine the API call to make? – Jeff Jun 20 '17 at 19:58

1 Answers1

6

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
Max Hanglin
  • 186
  • 1
  • 5