EC2 describe instances

    0

    0

    AWS and boto3 recipes for Python

    The code imports the boto3 library. Next, it creates an instance of the EC2 object. Finally, it calls the describe_instances() method on the EC2 object, passing in the instance as the first argument.

    The describe_instances() method returns a dictionary containing information about the specified instance. In this case, the method returns a dictionary containing the following keys:

    Name: The name of the instance

    State: The state of the instance

    AMI: The Amazon Elastic Compute Cloud (Amazon EC2) instance ID

    availability_zone: The Availability Zone the instance is located in

    region: The region of the world where the instance is located

    ami_id: The Amazon Elastic Compute Cloud (Amazon EC2) instance ID

    The list of attributes returned by the describe_instances() method is broad, but some of the more important attributes include the name, state, availability zone, and region of the instance.

    Library: boto3

    import boto3
    
    import boto3
    
    ec2 = boto3.client('ec2')
    response = ec2.describe_instances()
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.