HEX
Server: Apache
System: Linux vps-cdc32557.vps.ovh.ca 5.15.0-156-generic #166-Ubuntu SMP Sat Aug 9 00:02:46 UTC 2025 x86_64
User: hanode (1017)
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/lib/python3/dist-packages/awscli/examples/ec2/modify-instance-attribute.rst
**Example 1: To modify the instance type**

The following ``modify-instance-attribute`` example modifies the instance type of the specified instance. The instance must be in the ``stopped`` state. ::

    aws ec2 modify-instance-attribute \
        --instance-id i-1234567890abcdef0 \
        --instance-type "{\"Value\": \"m1.small\"}"

This command produces no output.

**Example 2: To enable enhanced networking on an instance**

The following ``modify-instance-attribute`` example enables enhanced networking for the specified instance. The instance must be in the ``stopped`` state. ::

    aws ec2 modify-instance-attribute \
        --instance-id i-1234567890abcdef0 \
        --sriov-net-support simple

This command produces no output.

**Example 3: To modify the sourceDestCheck attribute**

The following ``modify-instance-attribute`` example sets the ``sourceDestCheck`` attribute of the specified instance to ``true``. The instance must be in a VPC. ::

  aws ec2 modify-instance-attribute --instance-id i-1234567890abcdef0 --source-dest-check "{\"Value\": true}"

This command produces no output.

**Example 4: To modify the deleteOnTermination attribute of the root volume**

The following ``modify-instance-attribute`` example sets the ``deleteOnTermination`` attribute for the root volume of the specified Amazon EBS-backed instance to ``false``. By default, this attribute is ``true`` for the root volume.

Command::

  aws ec2 modify-instance-attribute \
    --instance-id i-1234567890abcdef0 \
    --block-device-mappings "[{\"DeviceName\": \"/dev/sda1\",\"Ebs\":{\"DeleteOnTermination\":false}}]"

This command produces no output.

**Example 5: To modify the user data attached to an instance**

The following ``modify-instance-attribute`` example adds the contents of the file ``UserData.txt`` as the UserData for the specified instance. 

Contents of original file ``UserData.txt``::

    #!/bin/bash
    yum update -y
    service httpd start
    chkconfig httpd on

The contents of the file must be base64 encoded. The first command converts the text file to base64 and saves it as a new file.

Linux/macOS version of the command::

    base64 UserData.txt > UserData.base64.txt

This command produces no output.

Windows version of the command::

    certutil -encode UserData.txt tmp.b64 && findstr /v /c:- tmp.b64 > UserData.base64.txt

Output::

    Input Length = 67
    Output Length = 152
    CertUtil: -encode command completed successfully.
    
Now you can reference that file in the CLI command that follows::

    aws ec2 modify-instance-attribute \
        --instance-id=i-09b5a14dbca622e76 \
        --attribute userData --value file://UserData.base64.txt

This command produces no output.

For more information, see `User Data and the AWS CLI <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html#user-data-api-cli>`__ in the *EC2 User Guide*.