HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //usr/local/aws-cli/v2/dist/awscli/examples/ec2/modify-instance-metadata-options.rst
**Example 1: To enable IMDSv2**

The following ``modify-instance-metadata-options`` example configures the use of IMDSv2 on the specified instance. ::

    aws ec2 modify-instance-metadata-options \
        --instance-id i-1234567898abcdef0 \
        --http-tokens required \
        --http-endpoint enabled

Output::

    {
        "InstanceId": "i-1234567898abcdef0",
        "InstanceMetadataOptions": {
            "State": "pending",
            "HttpTokens": "required",
            "HttpPutResponseHopLimit": 1,
            "HttpEndpoint": "enabled"
        }
    }

For more information, see `Instance metadata and user data <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html>`__ in the *Amazon Elastic Compute Cloud User Guide for Linux Instances*.
 
**Example 2: To disable instance metadata**

The following ``modify-instance-metadata-options`` example disables the use of all versions of instance metadata on the specified instance. ::

    aws ec2 modify-instance-metadata-options \
        --instance-id i-1234567898abcdef0 \
        --http-endpoint disabled

Output::

    {
        "InstanceId": "i-1234567898abcdef0",
        "InstanceMetadataOptions": {
            "State": "pending",
            "HttpTokens": "required",
            "HttpPutResponseHopLimit": 1,
            "HttpEndpoint": "disabled"
        }
    }

For more information, see `Instance metadata and user data <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html>`__ in the *Amazon Elastic Compute Cloud User Guide for Linux Instances*.

**Example 3: To enable instance metadata IPv6 endpoint for your instance**

The following ``modify-instance-metadata-options`` example shows you how to turn on the IPv6 endpoint for the instance metadata service. ::

    aws ec2 modify-instance-metadata-options \
        --instance-id i-1234567898abcdef0 \
        --http-protocol-ipv6 enabled \
        --http-endpoint enabled

Output::

    {
        "InstanceId": "i-1234567898abcdef0",
        "InstanceMetadataOptions": {
            "State": "pending",
            "HttpTokens": "required",
            "HttpPutResponseHopLimit": 1,
            "HttpEndpoint": "enabled",
            HttpProtocolIpv6": "enabled"
        }
    }

By default, the IPv6 endpoint is disabled. This is true even if you have launched an instance into an IPv6-only subnet. The IPv6 endpoint for IMDS is only accessible on instances built on the Nitro System. For more information, see `Instance metadata and user data <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html>`__ in the *Amazon Elastic Compute Cloud User Guide for Linux Instances*.