user1650281
user1650281

Reputation: 195

How to read metadata of one EC2 instance in another EC2 instance

In a multinode scenario, where there is one master EC2 instances and multiple EC2 worker instances, is there a way to read the metadata of worker instances by the master instance?. What is the best way to do it?. Can it be done just with Python script?.

Mainly interested in getting the interruption-notice of spot instances.

Upvotes: 0

Views: 388

Answers (1)

Asdfg
Asdfg

Reputation: 12213

If you are asking about reading metadata of an instance from other instance using https://169.254.169.254 then the simple answer is No. You cannot do that.

However, everything that is exposed in the meta-data can be accessed using AWS SDK.

interruption-notice for the Spot Instance is published as Cloudwatch event or you can query describe-spot-instance-requests and filter with the instance id. ( I have not done it but it looks like it is possible to do so). You will get the Status in the output. https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-spot-instance-requests.html

Upvotes: 1

Related Questions