Skip to content

modify_launch_template async

modify_launch_template(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    dry_run: Optional[Boolean] = None,
    client_token: Optional[String] = None,
    launch_template_id: Optional[LaunchTemplateId] = None,
    launch_template_name: Optional[LaunchTemplateName] = None,
    default_version: Optional[String] = None,
) -> ModifyLaunchTemplateResult

Modifies a launch template. You can specify which version of the launch template to set as the default version. When launching an instance, the default version applies when a launch template version is not specified.

Parameters:

  • dry_run (Optional[Boolean], default: None ) –

    Checks whether you have the required permissions for the action, 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.

  • client_token (Optional[String], default: None ) –

    Unique, case-sensitive identifier you provide to ensure the idempotency of the request. If a client token isn't specified, a randomly generated token is used in the request to ensure idempotency.

    For more information, see Ensuring idempotency.

    Constraint: Maximum 128 ASCII characters.

  • launch_template_id (Optional[LaunchTemplateId], default: None ) –

    The ID of the launch template.

    You must specify either the launch template ID or the launch template name, but not both.

  • launch_template_name (Optional[LaunchTemplateName], default: None ) –

    The name of the launch template.

    You must specify either the launch template ID or the launch template name, but not both.

  • default_version (Optional[String], default: None ) –

    The version number of the launch template to set as the default version.

Raises:

Examples:

To change the default version of a launch template This example specifies version 2 as the default version of the specified launch template.

>>> await client.modify_launch_template(launch_template_id='lt-0abcd290751193123', default_version='2')
Source code in docs_src/capo_ec2/_services/async_ec2.py
async def modify_launch_template(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    launch_template_id: Optional[
        "capo_ec2.types.launch_template_id.LaunchTemplateId"
    ] = None,
    launch_template_name: Optional[
        "capo_ec2.types.launch_template_name.LaunchTemplateName"
    ] = None,
    default_version: Optional["capo_ec2.types.string.String"] = None,
) -> "capo_ec2.types.modify_launch_template_result.ModifyLaunchTemplateResult":
    """<p>Modifies a launch template. You can specify which version of the launch template to set as the default version. When launching an instance, the default version applies when a launch template version is not specified.</p>

    Args:
        dry_run: <p>Checks whether you have the required permissions for the action, 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>
        client_token: <p>Unique, case-sensitive identifier you provide to ensure the idempotency of the request. If a client token isn't specified, a randomly generated token is used in the request to ensure idempotency.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring idempotency</a>.</p> <p>Constraint: Maximum 128 ASCII characters.</p>
        launch_template_id: <p>The ID of the launch template.</p> <p>You must specify either the launch template ID or the launch template name, but not both.</p>
        launch_template_name: <p>The name of the launch template.</p> <p>You must specify either the launch template ID or the launch template name, but not both.</p>
        default_version: <p>The version number of the launch template to set as the default version.</p>

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

    Examples:
        To change the default version of a launch template
        This example specifies version 2 as the default version of the specified launch template.

        >>> await client.modify_launch_template(launch_template_id='lt-0abcd290751193123', default_version='2')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.modify_launch_template_request.ModifyLaunchTemplateRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.modify_launch_template_result.ModifyLaunchTemplateResult"
    ]:
        import capo_ec2._operations.amazon_ec2.modify_launch_template

        (
            output,
            http_response,
        ) = await capo_ec2._operations.amazon_ec2.modify_launch_template.async_modify_launch_template(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ModifyLaunchTemplate")
    )
    input_: capo_ec2.types.modify_launch_template_request.ModifyLaunchTemplateRequest = {}
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if launch_template_id is not None:
        input_["launch_template_id"] = launch_template_id
    if launch_template_name is not None:
        input_["launch_template_name"] = launch_template_name
    if default_version is not None:
        input_["default_version"] = default_version

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output