Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get arn of EC2 instance in AWS

How do I get the arn of ec2 instance in AWS. I am trying to use resource tag api to add the tags to an EC2 instance. Resource tag api requires arn for all the resources.

How do I fetch that ?

like image 977
MeghP Avatar asked Dec 17 '19 09:12

MeghP


People also ask

How do I find my Arn on AWS ec2?

Open the Amazon Connect console at https://console.aws.amazon.com/connect/ . On the instances page, choose the instance alias. The instance alias is also your instance name, which appears in your Amazon Connect URL. On the Account overview page, in the Distribution settings section, you can see the full instance ARN.

How do I find my Arn?

To find the Amazon Resource Name (ARN) of the KMS key, choose the key ID or alias. The key ARN appears in the General Configuration section.

How do I get an AWS resource Arn?

To get an ARN from the AWS Management Console, navigate to the resource you want an ARN for, and view the details for that resource. For example, you can get the ARN for a DB instance from the Configuration tab of the DB instance details, as shown following.

What is ARN number in AWS?

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.


1 Answers

You can "build" it yourself:

arn:aws:ec2:<REGION>:<ACCOUNT_ID>:instance/<instance-id>.

For this purpose, I think you can even use * as <REGION> and <ACCOUNT_ID>, and it will work.

To retrieve the <instance_id> you can use the Console or the CLI, or from within the instance itself with ec2metadata --instance-id

like image 51
Ay0 Avatar answered Oct 08 '22 15:10

Ay0