EC2 / Client / delete_launch_template_versions

delete_launch_template_versions#

EC2.Client.delete_launch_template_versions(**kwargs)#

Deletes one or more versions of a launch template.

You can’t delete the default version of a launch template; you must first assign a different version as the default. If the default version is the only version for the launch template, you must delete the entire launch template using DeleteLaunchTemplate.

You can delete up to 200 launch template versions in a single request. To delete more than 200 versions in a single request, use DeleteLaunchTemplate, which deletes the launch template and all of its versions.

For more information, see Delete a launch template version in the Amazon EC2 User Guide.

See also: AWS API Documentation

Request Syntax

response = client.delete_launch_template_versions(
    DryRun=True|False,
    LaunchTemplateId='string',
    LaunchTemplateName='string',
    Versions=[
        'string',
    ]
)
Parameters:
  • DryRun (boolean) – 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.

  • LaunchTemplateId (string) –

    The ID of the launch template.

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

  • LaunchTemplateName (string) –

    The name of the launch template.

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

  • Versions (list) –

    [REQUIRED]

    The version numbers of one or more launch template versions to delete. You can specify up to 200 launch template version numbers.

    • (string) –

Return type:

dict

Returns:

Response Syntax

{
    'SuccessfullyDeletedLaunchTemplateVersions': [
        {
            'LaunchTemplateId': 'string',
            'LaunchTemplateName': 'string',
            'VersionNumber': 123
        },
    ],
    'UnsuccessfullyDeletedLaunchTemplateVersions': [
        {
            'LaunchTemplateId': 'string',
            'LaunchTemplateName': 'string',
            'VersionNumber': 123,
            'ResponseError': {
                'Code': 'launchTemplateIdDoesNotExist'|'launchTemplateIdMalformed'|'launchTemplateNameDoesNotExist'|'launchTemplateNameMalformed'|'launchTemplateVersionDoesNotExist'|'unexpectedError',
                'Message': 'string'
            }
        },
    ]
}

Response Structure

  • (dict) –

    • SuccessfullyDeletedLaunchTemplateVersions (list) –

      Information about the launch template versions that were successfully deleted.

      • (dict) –

        Describes a launch template version that was successfully deleted.

        • LaunchTemplateId (string) –

          The ID of the launch template.

        • LaunchTemplateName (string) –

          The name of the launch template.

        • VersionNumber (integer) –

          The version number of the launch template.

    • UnsuccessfullyDeletedLaunchTemplateVersions (list) –

      Information about the launch template versions that could not be deleted.

      • (dict) –

        Describes a launch template version that could not be deleted.

        • LaunchTemplateId (string) –

          The ID of the launch template.

        • LaunchTemplateName (string) –

          The name of the launch template.

        • VersionNumber (integer) –

          The version number of the launch template.

        • ResponseError (dict) –

          Information about the error.

          • Code (string) –

            The error code.

          • Message (string) –

            The error message, if applicable.

Examples

This example deletes the specified launch template version.

response = client.delete_launch_template_versions(
    LaunchTemplateId='lt-0abcd290751193123',
    Versions=[
        '1',
    ],
)

print(response)

Expected Output:

{
    'SuccessfullyDeletedLaunchTemplateVersions': [
        {
            'LaunchTemplateId': 'lt-0abcd290751193123',
            'LaunchTemplateName': 'my-template',
            'VersionNumber': 1,
        },
    ],
    'UnsuccessfullyDeletedLaunchTemplateVersions': [
    ],
    'ResponseMetadata': {
        '...': '...',
    },
}