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