EC2 / Client / describe_instance_attribute

describe_instance_attribute#

EC2.Client.describe_instance_attribute(**kwargs)#

Describes the specified attribute of the specified instance. You can specify only one attribute at a time. Valid attribute values are: instanceType | kernel | ramdisk | userData | disableApiTermination | instanceInitiatedShutdownBehavior | rootDeviceName | blockDeviceMapping | productCodes | sourceDestCheck | groupSet | ebsOptimized | sriovNetSupport

See also: AWS API Documentation

Request Syntax

response = client.describe_instance_attribute(
    DryRun=True|False,
    InstanceId='string',
    Attribute='instanceType'|'kernel'|'ramdisk'|'userData'|'disableApiTermination'|'instanceInitiatedShutdownBehavior'|'rootDeviceName'|'blockDeviceMapping'|'productCodes'|'sourceDestCheck'|'groupSet'|'ebsOptimized'|'sriovNetSupport'|'enaSupport'|'enclaveOptions'|'disableApiStop'
)
Parameters:
  • DryRun (boolean) – Checks whether you have the required permissions for the operation, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • InstanceId (string) –

    [REQUIRED]

    The ID of the instance.

  • Attribute (string) –

    [REQUIRED]

    The instance attribute.

    Note: The enaSupport attribute is not supported at this time.

Return type:

dict

Returns:

Response Syntax

{
    'BlockDeviceMappings': [
        {
            'DeviceName': 'string',
            'Ebs': {
                'AttachTime': datetime(2015, 1, 1),
                'DeleteOnTermination': True|False,
                'Status': 'attaching'|'attached'|'detaching'|'detached',
                'VolumeId': 'string',
                'AssociatedResource': 'string',
                'VolumeOwnerId': 'string'
            }
        },
    ],
    'DisableApiTermination': {
        'Value': True|False
    },
    'EnaSupport': {
        'Value': True|False
    },
    'EnclaveOptions': {
        'Enabled': True|False
    },
    'EbsOptimized': {
        'Value': True|False
    },
    'InstanceId': 'string',
    'InstanceInitiatedShutdownBehavior': {
        'Value': 'string'
    },
    'InstanceType': {
        'Value': 'string'
    },
    'KernelId': {
        'Value': 'string'
    },
    'ProductCodes': [
        {
            'ProductCodeId': 'string',
            'ProductCodeType': 'devpay'|'marketplace'
        },
    ],
    'RamdiskId': {
        'Value': 'string'
    },
    'RootDeviceName': {
        'Value': 'string'
    },
    'SourceDestCheck': {
        'Value': True|False
    },
    'SriovNetSupport': {
        'Value': 'string'
    },
    'UserData': {
        'Value': 'string'
    },
    'DisableApiStop': {
        'Value': True|False
    },
    'Groups': [
        {
            'GroupId': 'string',
            'GroupName': 'string'
        },
    ]
}

Response Structure

  • (dict) –

    Describes an instance attribute.

    • BlockDeviceMappings (list) –

      The block device mapping of the instance.

      • (dict) –

        Describes a block device mapping.

        • DeviceName (string) –

          The device name (for example, /dev/sdh or xvdh).

        • Ebs (dict) –

          Parameters used to automatically set up EBS volumes when the instance is launched.

          • AttachTime (datetime) –

            The time stamp when the attachment initiated.

          • DeleteOnTermination (boolean) –

            Indicates whether the volume is deleted on instance termination.

          • Status (string) –

            The attachment state.

          • VolumeId (string) –

            The ID of the EBS volume.

          • AssociatedResource (string) –

            The ARN of the Amazon ECS or Fargate task to which the volume is attached.

          • VolumeOwnerId (string) –

            The ID of the Amazon Web Services account that owns the volume.

            This parameter is returned only for volumes that are attached to Fargate tasks.

    • DisableApiTermination (dict) –

      If the value is true, you can’t terminate the instance through the Amazon EC2 console, CLI, or API; otherwise, you can.

      • Value (boolean) –

        The attribute value. The valid values are true or false.

    • EnaSupport (dict) –

      Indicates whether enhanced networking with ENA is enabled.

      • Value (boolean) –

        The attribute value. The valid values are true or false.

    • EnclaveOptions (dict) –

      To enable the instance for Amazon Web Services Nitro Enclaves, set this parameter to true; otherwise, set it to false.

      • Enabled (boolean) –

        If this parameter is set to true, the instance is enabled for Amazon Web Services Nitro Enclaves; otherwise, it is not enabled for Amazon Web Services Nitro Enclaves.

    • EbsOptimized (dict) –

      Indicates whether the instance is optimized for Amazon EBS I/O.

      • Value (boolean) –

        The attribute value. The valid values are true or false.

    • InstanceId (string) –

      The ID of the instance.

    • InstanceInitiatedShutdownBehavior (dict) –

      Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).

      • Value (string) –

        The attribute value. The value is case-sensitive.

    • InstanceType (dict) –

      The instance type.

      • Value (string) –

        The attribute value. The value is case-sensitive.

    • KernelId (dict) –

      The kernel ID.

      • Value (string) –

        The attribute value. The value is case-sensitive.

    • ProductCodes (list) –

      A list of product codes.

      • (dict) –

        Describes a product code.

        • ProductCodeId (string) –

          The product code.

        • ProductCodeType (string) –

          The type of product code.

    • RamdiskId (dict) –

      The RAM disk ID.

      • Value (string) –

        The attribute value. The value is case-sensitive.

    • RootDeviceName (dict) –

      The device name of the root device volume (for example, /dev/sda1).

      • Value (string) –

        The attribute value. The value is case-sensitive.

    • SourceDestCheck (dict) –

      Enable or disable source/destination checks, which ensure that the instance is either the source or the destination of any traffic that it receives. If the value is true, source/destination checks are enabled; otherwise, they are disabled. The default value is true. You must disable source/destination checks if the instance runs services such as network address translation, routing, or firewalls.

      • Value (boolean) –

        The attribute value. The valid values are true or false.

    • SriovNetSupport (dict) –

      Indicates whether enhanced networking with the Intel 82599 Virtual Function interface is enabled.

      • Value (string) –

        The attribute value. The value is case-sensitive.

    • UserData (dict) –

      The user data.

      • Value (string) –

        The attribute value. The value is case-sensitive.

    • DisableApiStop (dict) –

      To enable the instance for Amazon Web Services Stop Protection, set this parameter to true; otherwise, set it to false.

      • Value (boolean) –

        The attribute value. The valid values are true or false.

    • Groups (list) –

      The security groups associated with the instance.

      • (dict) –

        Describes a security group.

        • GroupId (string) –

          The ID of the security group.

        • GroupName (string) –

          The name of the security group.

Examples

This example describes the instance type of the specified instance.

response = client.describe_instance_attribute(
    Attribute='instanceType',
    InstanceId='i-1234567890abcdef0',
)

print(response)

Expected Output:

{
    'InstanceId': 'i-1234567890abcdef0',
    'InstanceType': {
        'Value': 't1.micro',
    },
    'ResponseMetadata': {
        '...': '...',
    },
}

This example describes the disableApiTermination attribute of the specified instance.

response = client.describe_instance_attribute(
    Attribute='disableApiTermination',
    InstanceId='i-1234567890abcdef0',
)

print(response)

Expected Output:

{
    'DisableApiTermination': {
        'Value': 'false',
    },
    'InstanceId': 'i-1234567890abcdef0',
    'ResponseMetadata': {
        '...': '...',
    },
}

This example describes the blockDeviceMapping attribute of the specified instance.

response = client.describe_instance_attribute(
    Attribute='blockDeviceMapping',
    InstanceId='i-1234567890abcdef0',
)

print(response)

Expected Output:

{
    'BlockDeviceMappings': [
        {
            'DeviceName': '/dev/sda1',
            'Ebs': {
                'AttachTime': datetime(2013, 5, 17, 22, 42, 34, 4, 137, 0),
                'DeleteOnTermination': True,
                'Status': 'attached',
                'VolumeId': 'vol-049df61146c4d7901',
            },
        },
        {
            'DeviceName': '/dev/sdf',
            'Ebs': {
                'AttachTime': datetime(2013, 9, 10, 23, 7, 0, 1, 253, 0),
                'DeleteOnTermination': False,
                'Status': 'attached',
                'VolumeId': 'vol-049df61146c4d7901',
            },
        },
    ],
    'InstanceId': 'i-1234567890abcdef0',
    'ResponseMetadata': {
        '...': '...',
    },
}