Is there an equivalent of
curl http://169.254.169.254/latest/meta-data/instance-id
with boto3 to obtain the current running instance instance-id in python?
There is no api for it, no. There is InstanceMetadataFetcher
, but it is currently only used to fetch IAM roles for authentication.
Any sort of GET
should serve you though. Botocore uses the python requests
library which is quite nice.
import requests
response = requests.get('http://169.254.169.254/latest/meta-data/instance-id')
instance_id = response.text