ec2-metadata | easy interface to query the EC2 metadata API | AWS library

 by   adamchainz Python Version: 2.13.0 License: MIT

kandi X-RAY | ec2-metadata Summary

kandi X-RAY | ec2-metadata Summary

ec2-metadata is a Python library typically used in Cloud, AWS, Amazon S3 applications. ec2-metadata has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. However ec2-metadata build file is not available. You can install using 'pip install ec2-metadata' or download it from GitHub, PyPI.

An easy interface to query the EC2 metadata API, with caching.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              ec2-metadata has a low active ecosystem.
              It has 102 star(s) with 29 fork(s). There are 7 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 2 open issues and 17 have been closed. On average issues are closed in 317 days. There are 2 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of ec2-metadata is 2.13.0

            kandi-Quality Quality

              ec2-metadata has 0 bugs and 0 code smells.

            kandi-Security Security

              ec2-metadata has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              ec2-metadata code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              ec2-metadata is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              ec2-metadata releases are not available. You will need to build from source code and install.
              Deployable package is available in PyPI.
              ec2-metadata has no build file. You will be need to create the build yourself to build the component from source.
              It has 881 lines of code, 153 functions and 5 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed ec2-metadata and discovered the below as its top functions. This is intended to give you an instant insight into ec2-metadata implemented functionality, and help decide if they suit your requirements.
            • Returns an instance of the spot instance
            • Make a GET request
            • Ensure the token has expired
            • Get the instance identity document
            • Public hostname
            • Return public IPv4 address
            • A list of IPv6 cidr blocks
            • Return the IP address of the subnet
            • A list of IPv4 CIDR blocks
            • Returns the IPv4 CIDR block
            • Return the user data
            • List of IPv6s
            • The kernel s kernel id
            • The public host name
            • List of public ipv4s
            • Returns the iam info
            • List of subnet s ipv6
            • Return the placement zone id of this placement
            • List of ipv4 associations
            • Returns the target lifecycle state
            • Return IAM security credentials
            • Get network interfaces
            Get all kandi verified functions for this library.

            ec2-metadata Key Features

            No Key Features are available at this moment for ec2-metadata.

            ec2-metadata Examples and Code Snippets

            No Code Snippets are available at this moment for ec2-metadata.

            Community Discussions

            QUESTION

            Using IMDS (v2) with token inside docker on EC2
            Asked 2022-Apr-15 at 13:11

            I'd like to use IMDSv2 inside a container running on an EC2 instance.

            I want to use the tokens because they are required in my metadata options:

            ...

            ANSWER

            Answered 2022-Apr-15 at 13:11

            I order to access IMDSv2 metadata from a docker container, you must increase the hop limit for IMDSv2 in the instance metadata configuration. From the aws docs:

            In a container environment, if the hop limit is 1, the IMDSv2 response does not return because going to the container is considered an additional network hop. To avoid the process of falling back to IMDSv1 and the resultant delay, in a container environment we recommend that you set the hop limit to 2

            To change the hop limit, you can use modify-instance-metadata-options in awscli:

            Source https://stackoverflow.com/questions/71884350

            QUESTION

            Getting AWS Availability Zone saved in bash script variable
            Asked 2022-Feb-21 at 03:06

            Using a shell script, I'm looking to get the current AZ where the instance is located.

            Here is what I've tried but obviously HOST_NAME is not a command. How do I save the current AZ in a HOST_NAME variable?

            ...

            ANSWER

            Answered 2022-Feb-21 at 03:06

            You can't have spaces in HOST_NAME = . It should eb:

            Source https://stackoverflow.com/questions/71199641

            QUESTION

            How to run command line commands in the .ebextensions folder for elastic beanstalk?
            Asked 2021-Dec-09 at 13:31

            I have a few commands that I need to run on start-up of a new Elastic Beanstalk instance. How do I structure the .config file so that the commands run on boot-up of a new instance. These are the comamnds that I need ran:

            ...

            ANSWER

            Answered 2021-Dec-09 at 00:03

            To run those multiple commands as one, you can do the following:

            Source https://stackoverflow.com/questions/70281968

            QUESTION

            s3fs: How to mount S3 buckets on AWS EC2 instances behind proxy, using IMDS v2
            Asked 2021-Sep-08 at 15:54

            We are having some trouble to mount an AWS S3 bucket (using s3fs v1.90) into an AWS EC2 instance which:

            • is running Ubuntu 18.04
            • requires IMDS v2 session tokens
            • is behind a proxy

            The HTTP response code returned by the curl lib is "417 - Expectation Failed" (more details below). I found some hints on the www that the 417 error might relate to our proxy config, see:
            HTTP POST Returns Error: 417 "Expectation Failed."
            https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019LuWSAU

            This makes me believe that our NO_PROXY config is not being picked up by s3fs, but I'm really not sure...

            Anyway, this is what we've tried to do in order to mount the bucket:

            ...

            ANSWER

            Answered 2021-Sep-08 at 15:54

            QUESTION

            Get Instance 'Name' Tag via Python script once IMDSv2 is enabled
            Asked 2021-Jun-15 at 06:10

            I would like to understand how to fetch an EC2's 'Name' tag value once version 2 of the Instance Metadata Service is enforced over version 1.

            When I tried to describe_instances under an ec2 client via boto3 my requests returned access denied.

            I created the following code to access an EC2's metadata:

            ...

            ANSWER

            Answered 2021-Jun-15 at 06:10

            The Access Denied error indicates that AWS has rejected your call to DescribeInstances().

            If an IAM Role has been assigned to the instance, then add the ec2:DescribeInstances permission to the IAM Role. The Amazon EC2 Instance Metadata Service will be used to retrieve credentials for IAM Role.

            If you are using credentials from an IAM User, the add the permission to that IAM User.

            Tags are not provided by the Instance Metadata service.

            Source https://stackoverflow.com/questions/67976552

            QUESTION

            execution of salt cmd.run has different behaviors if it's CLI vs through state files. what's the difference?
            Asked 2021-Mar-16 at 06:11

            I'm trying to set a variable TOKEN with a value of a IMDSv2 (AWS instance metadata) token to get an instance IP address.

            Executing a set of commands through the salt CLI yields desired results: Here's the command below:

            ...

            ANSWER

            Answered 2021-Mar-16 at 06:11

            As per the documentation, the cmd.run does not process commands through Shell by default. Quoting a "Warning" from the above link:

            This function does not process commands through a shell unless the python_shell flag is set to True. This means that any shell-specific functionality such as 'echo' or the use of pipes, redirection or &&, should either be migrated to cmd.shell or have the python_shell=True flag set here.

            So there are two options:

            • Instead of using cmd.run use cmd.shell. E.g.:

            Source https://stackoverflow.com/questions/66647807

            QUESTION

            How to get AWS OpsWorks instance id within an instance?
            Asked 2020-Aug-20 at 07:11

            Following is the way to get OpsWorks instance id of my current instance:

            ...

            ANSWER

            Answered 2020-Aug-20 at 07:11

            On Amazon Linux 2, the ID is in /etc/aws/opsworks/instance-agent.yml

            Thus you could get it:

            Source https://stackoverflow.com/questions/63499692

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install ec2-metadata

            You can install using 'pip install ec2-metadata' or download it from GitHub, PyPI.
            You can use ec2-metadata like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install ec2-metadata

          • CLONE
          • HTTPS

            https://github.com/adamchainz/ec2-metadata.git

          • CLI

            gh repo clone adamchainz/ec2-metadata

          • sshUrl

            git@github.com:adamchainz/ec2-metadata.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular AWS Libraries

            localstack

            by localstack

            og-aws

            by open-guides

            aws-cli

            by aws

            awesome-aws

            by donnemartin

            amplify-js

            by aws-amplify

            Try Top Libraries by adamchainz

            django-cors-headers

            by adamchainzPython

            django-htmx

            by adamchainzJavaScript

            django-upgrade

            by adamchainzPython

            blacken-docs

            by adamchainzPython

            django-mysql

            by adamchainzPython