modify_instance_attribute
¶
modify_instance_attribute(
*,
config_overrides: Optional[EC2ClientConfig] = 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.
>>> 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.
>>> client.modify_instance_attribute(instance_id='i-1234567890abcdef0', instance_type={'Value': 'm5.large'})
Source code in docs_src/capo_ec2/_services/ec2.py
50077 50078 50079 50080 50081 50082 50083 50084 50085 50086 50087 50088 50089 50090 50091 50092 50093 50094 50095 50096 50097 50098 50099 50100 50101 50102 50103 50104 50105 50106 50107 50108 50109 50110 50111 50112 50113 50114 50115 50116 50117 50118 50119 50120 50121 50122 50123 50124 50125 50126 50127 50128 50129 50130 50131 50132 50133 50134 50135 50136 50137 50138 50139 50140 50141 50142 50143 50144 50145 50146 50147 50148 50149 50150 50151 50152 50153 50154 50155 50156 50157 50158 50159 50160 50161 50162 50163 50164 50165 50166 50167 50168 50169 50170 50171 50172 50173 50174 50175 50176 50177 50178 50179 50180 50181 50182 50183 50184 50185 50186 50187 50188 50189 50190 50191 50192 50193 50194 50195 50196 50197 50198 50199 50200 50201 50202 50203 50204 50205 50206 50207 50208 50209 50210 50211 50212 50213 50214 50215 50216 50217 50218 50219 50220 50221 50222 50223 50224 50225 50226 50227 50228 50229 50230 50231 50232 50233 | |