boto3 equivalent to boto.utils.get_instance_metadata()?

后端 未结 2 958
面向向阳花
面向向阳花 2021-01-01 10:40

In regular boto 2.38 I used to access instance metadata (e.g. get current stack-name), through boto\'s

boto.utils.get_instance_metadata()

2条回答
  •  悲&欢浪女
    2021-01-01 11:26

    You could use the third-party library ec2-metadata.

    Here an example from the docs showing how to get your EC2 region:

      pip install ec2-metadata
    
      >>> from ec2_metadata import ec2_metadata
      >>> print(ec2_metadata.region)
      us-east-1
    

提交回复
热议问题