Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to look up an amazon resource using the Amazon Resource Name (ARN) as an identifier?

With respect to an Amazon Resource Name (ARN) the AWS documentation states that:

Amazon Resource Names (ARNs) uniquely identify AWS resources. We require an ARN when you need to specify a resource unambiguously across all of AWS, such as in IAM policies, Amazon Relational Database Service (Amazon RDS) tags, and API calls.

http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html

Question

Is it possible to look up a specific AWS resource using the ARN as an identifier?

For example if I was to use the SDK would it be possible to do something along the lines of:

Instance instance = AmazonResourceName.find(arnId); // look up via ARN?

If this is not possible, then the question becomes:

*What is the recommended approach for finding an AWS resources using the API? and What are the identifiers available for look up? *

Thanks

like image 794
BOWS Avatar asked Jul 28 '16 19:07

BOWS


People also ask

What is Amazon resource name Arn?

Amazon Resource Names (ARNs) uniquely identify AWS resources. We require an ARN when you need to specify a resource unambiguously across all of AWS, such as in IAM policies, Amazon Relational Database Service (Amazon RDS) tags, and API calls.

How do I find my Amazon resource Name?

Getting AWS Role arn You can get the arn of the IAM role from the cli as explained in the above section. If you go to IAM –> Role –> Your role from the web console, you can view the arn as shown below. Note: If you are working with an ec2 instance, you might need the instance profile arn with the IAM policies.

How do I find the Arn of a resource?

You can get the ARN of an RDS resource using the AWS management console, RDS API, or AWS command-line interface. If you are using the AWS management console, you have to navigate to the resource you need the ARN for and click on the details of that resource.


1 Answers

Have you looked at the AmazonEc2Client docs?

It has a describeInstances(DescribeInstancesRequest describeInstancesRequest) method that I think might suit your needs because the DescribeInstancesRequest can be set with ids as shown in the docs. This is untested but might be a good place to start.

like image 52
Guy Grin Avatar answered Oct 09 '22 04:10

Guy Grin