modify_instance_attribute
async
¶
modify_instance_attribute(
*,
config_overrides: Optional[AsyncEC2ClientConfig] = None,
source_dest_check: Optional[AttributeBooleanValue] = None,
enclave_options: Optional[EnclaveOptionsRequest] = None,
disable_api_stop: Optional[AttributeBooleanValue] = None,
dry_run: Optional[Boolean] = None,
instance_id: Optional[InstanceId] = None,
attribute: Optional[InstanceAttributeName] = None,
value: Optional[ModifyInstanceAttributeValue] = None,
block_device_mappings: Optional[InstanceBlockDeviceMappingSpecificationList] = None,
disable_api_termination: Optional[AttributeBooleanValue] = None,
instance_type: Optional[AttributeValue] = None,
kernel: Optional[AttributeValue] = None,
ramdisk: Optional[AttributeValue] = None,
user_data: Optional[SecureBlobAttributeValue] = None,
instance_initiated_shutdown_behavior: Optional[AttributeValue] = None,
groups: Optional[GroupIdStringList] = None,
ebs_optimized: Optional[AttributeBooleanValue] = None,
sriov_net_support: Optional[AttributeValue] = None,
ena_support: Optional[AttributeBooleanValue] = None,
) -> None
Modifies the specified attribute of the specified instance. You can specify only one attribute at a time.
Note: Using this action to change the security groups associated with an elastic network interface (ENI) attached to an instance can result in an error if the instance has more than one ENI. To change the security groups associated with an ENI attached to an instance that has multiple ENIs, we recommend that you use the ModifyNetworkInterfaceAttribute action.
To modify some attributes, the instance must be stopped. For more information, see Modify a stopped instance in the Amazon EC2 User Guide.
Parameters:
-
source_dest_check(Optional[AttributeBooleanValue], default:None) –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 istrue. You must disable source/destination checks if the instance runs services such as network address translation, routing, or firewalls. -
enclave_options(Optional[EnclaveOptionsRequest], default:None) –Enables or disables the instance for Amazon Web Services Nitro Enclaves. For more information, see the Amazon Web Services Nitro Enclaves User Guide.
-
disable_api_stop(Optional[AttributeBooleanValue], default:None) –Indicates whether an instance is enabled for stop protection. For more information, see Enable stop protection for your instance.
-
dry_run(Optional[Boolean], default:None) –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 isUnauthorizedOperation. -
instance_id(Optional[InstanceId], default:None) –The ID of the instance.
-
attribute(Optional[InstanceAttributeName], default:None) –The name of the attribute to modify.
When changing the instance type: If the original instance type is configured for configurable bandwidth, and the desired instance type doesn't support configurable bandwidth, first set the existing bandwidth configuration to
defaultusing the ModifyInstanceNetworkPerformanceOptions operation.You can modify the following attributes only:
disableApiTermination|instanceType|kernel|ramdisk|instanceInitiatedShutdownBehavior|blockDeviceMapping|userData|sourceDestCheck|groupSet|ebsOptimized|sriovNetSupport|enaSupport|nvmeSupport|disableApiStop|enclaveOptions -
value(Optional[ModifyInstanceAttributeValue], default:None) –A new value for the attribute. Use only with the
kernel,ramdisk,userData,disableApiTermination, orinstanceInitiatedShutdownBehaviorattribute. -
block_device_mappings(Optional[InstanceBlockDeviceMappingSpecificationList], default:None) –Modifies the
DeleteOnTerminationattribute for volumes that are currently attached. The volume must be owned by the caller. If no value is specified forDeleteOnTermination, the default istrueand the volume is deleted when the instance is terminated. You can't modify theDeleteOnTerminationattribute for volumes that are attached to Amazon Web Services-managed resources.To add instance store volumes to an Amazon EBS-backed instance, you must add them when you launch the instance. For more information, see Update the block device mapping when launching an instance in the Amazon EC2 User Guide.
-
disable_api_termination(Optional[AttributeBooleanValue], default:None) –Enable or disable termination protection for the instance. If the value is
true, you can't terminate the instance using the Amazon EC2 console, command line interface, or API. You can't enable termination protection for Spot Instances. -
instance_type(Optional[AttributeValue], default:None) –Changes the instance type to the specified value. For more information, see Instance types in the Amazon EC2 User Guide. If the instance type is not valid, the error returned is
InvalidInstanceAttributeValue. -
kernel(Optional[AttributeValue], default:None) –Changes the instance's kernel to the specified value. We recommend that you use PV-GRUB instead of kernels and RAM disks. For more information, see PV-GRUB.
-
ramdisk(Optional[AttributeValue], default:None) –Changes the instance's RAM disk to the specified value. We recommend that you use PV-GRUB instead of kernels and RAM disks. For more information, see PV-GRUB.
-
user_data(Optional[SecureBlobAttributeValue], default:None) –Changes the instance's user data to the specified value. User data must be base64-encoded. Depending on the tool or SDK that you're using, the base64-encoding might be performed for you. For more information, see Work with instance user data.
-
instance_initiated_shutdown_behavior(Optional[AttributeValue], default:None) –Specifies whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).
-
groups(Optional[GroupIdStringList], default:None) –Replaces the security groups of the instance with the specified security groups. You must specify the ID of at least one security group, even if it's just the default security group for the VPC.
-
ebs_optimized(Optional[AttributeBooleanValue], default:None) –Specifies whether the instance is optimized for Amazon EBS I/O. This optimization provides dedicated throughput to Amazon EBS and an optimized configuration stack to provide optimal EBS I/O performance. This optimization isn't available with all instance types. Additional usage charges apply when using an EBS Optimized instance.
-
sriov_net_support(Optional[AttributeValue], default:None) –Set to
simpleto enable enhanced networking with the Intel 82599 Virtual Function interface for the instance.There is no way to disable enhanced networking with the Intel 82599 Virtual Function interface at this time.
This option is supported only for HVM instances. Specifying this option with a PV instance can make it unreachable.
-
ena_support(Optional[AttributeBooleanValue], default:None) –Set to
trueto enable enhanced networking with ENA for the instance.This option is supported only for HVM instances. Specifying this option with a PV instance can make it unreachable.
Raises:
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To enable enhanced networking This example enables enhanced networking for the specified stopped instance.
>>> await client.modify_instance_attribute(instance_id='i-1234567890abcdef0', ena_support={'Value': True})
To modify the instance type
This example modifies the instance type of the specified stopped instance.
>>> await client.modify_instance_attribute(instance_id='i-1234567890abcdef0', instance_type={'Value': 'm5.large'})
Source code in docs_src/capo_ec2/_services/async_ec2.py
50772 50773 50774 50775 50776 50777 50778 50779 50780 50781 50782 50783 50784 50785 50786 50787 50788 50789 50790 50791 50792 50793 50794 50795 50796 50797 50798 50799 50800 50801 50802 50803 50804 50805 50806 50807 50808 50809 50810 50811 50812 50813 50814 50815 50816 50817 50818 50819 50820 50821 50822 50823 50824 50825 50826 50827 50828 50829 50830 50831 50832 50833 50834 50835 50836 50837 50838 50839 50840 50841 50842 50843 50844 50845 50846 50847 50848 50849 50850 50851 50852 50853 50854 50855 50856 50857 50858 50859 50860 50861 50862 50863 50864 50865 50866 50867 50868 50869 50870 50871 50872 50873 50874 50875 50876 50877 50878 50879 50880 50881 50882 50883 50884 50885 50886 50887 50888 50889 50890 50891 50892 50893 50894 50895 50896 50897 50898 50899 50900 50901 50902 50903 50904 50905 50906 50907 50908 50909 50910 50911 50912 50913 50914 50915 50916 50917 50918 50919 50920 50921 50922 50923 50924 50925 50926 50927 50928 50929 | |