Skip to content

modify_instance_cpu_options

modify_instance_cpu_options(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    instance_id: Optional[InstanceId] = None,
    core_count: Optional[Integer] = None,
    threads_per_core: Optional[Integer] = None,
    nested_virtualization: Optional[NestedVirtualizationSpecification] = None,
    dry_run: Optional[Boolean] = None,
) -> ModifyInstanceCpuOptionsResult

By default, all vCPUs for the instance type are active when you launch an instance. When you configure the number of active vCPUs for the instance, it can help you save on licensing costs and optimize performance. The base cost of the instance remains unchanged.

The number of active vCPUs equals the number of threads per CPU core multiplied by the number of cores. The instance must be in a Stopped state before you make changes.

Some instance type options do not support this capability. For more information, see Supported CPU options in the Amazon EC2 User Guide.

Parameters:

  • instance_id (Optional[InstanceId], default: None ) –

    The ID of the instance to update.

  • core_count (Optional[Integer], default: None ) –

    The number of CPU cores to activate for the specified instance.

  • threads_per_core (Optional[Integer], default: None ) –

    The number of threads to run for each CPU core.

  • nested_virtualization (Optional[NestedVirtualizationSpecification], default: None ) –

    Indicates whether to enable or disable nested virtualization for the instance. When nested virtualization is enabled, Virtual Secure Mode (VSM) is automatically disabled for the 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 is UnauthorizedOperation.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def modify_instance_cpu_options(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    instance_id: Optional["capo_ec2.types.instance_id.InstanceId"] = None,
    core_count: Optional["capo_ec2.types.integer.Integer"] = None,
    threads_per_core: Optional["capo_ec2.types.integer.Integer"] = None,
    nested_virtualization: Optional[
        "capo_ec2.types.nested_virtualization_specification.NestedVirtualizationSpecification"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.modify_instance_cpu_options_result.ModifyInstanceCpuOptionsResult":
    """<p>By default, all vCPUs for the instance type are active when you launch an instance. When you configure the number of active vCPUs for the instance, it can help you save on licensing costs and optimize performance. The base cost of the instance remains unchanged.</p> <p>The number of active vCPUs equals the number of threads per CPU core multiplied by the number of cores. The instance must be in a <code>Stopped</code> state before you make changes.</p> <note> <p>Some instance type options do not support this capability. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/cpu-options-supported-instances-values.html">Supported CPU options</a> in the <i>Amazon EC2 User Guide</i>.</p> </note>

    Args:
        instance_id: <p>The ID of the instance to update.</p>
        core_count: <p>The number of CPU cores to activate for the specified instance.</p>
        threads_per_core: <p>The number of threads to run for each CPU core.</p>
        nested_virtualization: <p>Indicates whether to enable or disable nested virtualization for the instance. When nested virtualization is enabled, Virtual Secure Mode (VSM) is automatically disabled for the instance.</p>
        dry_run: <p>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 <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.modify_instance_cpu_options_request.ModifyInstanceCpuOptionsRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.modify_instance_cpu_options_result.ModifyInstanceCpuOptionsResult"
    ]:
        import capo_ec2._operations.amazon_ec2.modify_instance_cpu_options

        output, http_response = (
            capo_ec2._operations.amazon_ec2.modify_instance_cpu_options.modify_instance_cpu_options(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ModifyInstanceCpuOptions")
    )
    input_: capo_ec2.types.modify_instance_cpu_options_request.ModifyInstanceCpuOptionsRequest = {}
    if instance_id is not None:
        input_["instance_id"] = instance_id
    if core_count is not None:
        input_["core_count"] = core_count
    if threads_per_core is not None:
        input_["threads_per_core"] = threads_per_core
    if nested_virtualization is not None:
        input_["nested_virtualization"] = nested_virtualization
    if dry_run is not None:
        input_["dry_run"] = dry_run

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output