Skip to content

get_launch_template_data

get_launch_template_data(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    dry_run: Optional[Boolean] = None,
    instance_id: Optional[InstanceId] = None,
) -> GetLaunchTemplateDataResult

Retrieves the configuration data of the specified instance. You can use this data to create a launch template.

This action calls on other describe actions to get instance information. Depending on your instance configuration, you may need to allow the following actions in your IAM policy: DescribeSpotInstanceRequests, DescribeInstanceCreditSpecifications, DescribeVolumes, and DescribeInstanceAttribute. Or, you can allow describe* depending on your instance requirements.

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.

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

    The ID of the instance.

Raises:

Examples:

To get the launch template data for an instance This example gets the launch template data for the specified instance.

>>> client.get_launch_template_data(instance_id='0123d646e8048babc')
Source code in docs_src/capo_ec2/_services/ec2.py
def get_launch_template_data(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    instance_id: Optional["capo_ec2.types.instance_id.InstanceId"] = None,
) -> "capo_ec2.types.get_launch_template_data_result.GetLaunchTemplateDataResult":
    """<p>Retrieves the configuration data of the specified instance. You can use this data to create a launch template. </p> <p>This action calls on other describe actions to get instance information. Depending on your instance configuration, you may need to allow the following actions in your IAM policy: <code>DescribeSpotInstanceRequests</code>, <code>DescribeInstanceCreditSpecifications</code>, <code>DescribeVolumes</code>, and <code>DescribeInstanceAttribute</code>. Or, you can allow <code>describe*</code> depending on your instance requirements.</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>
        instance_id: <p>The ID of the instance.</p>

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

    Examples:
        To get the launch template data for an instance
        This example gets the launch template data for the specified instance.

        >>> client.get_launch_template_data(instance_id='0123d646e8048babc')
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.get_launch_template_data_request.GetLaunchTemplateDataRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.get_launch_template_data_result.GetLaunchTemplateDataResult"
    ]:
        import capo_ec2._operations.amazon_ec2.get_launch_template_data

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

    def _redact_output(
        output: "capo_ec2.types.get_launch_template_data_result.GetLaunchTemplateDataResult",
    ) -> dict[str, Any]:
        import capo_ec2.types.get_launch_template_data_result

        return capo_ec2.types.get_launch_template_data_result.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("GetLaunchTemplateData", redact_output=_redact_output),
    )
    input_: capo_ec2.types.get_launch_template_data_request.GetLaunchTemplateDataRequest = {}
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if instance_id is not None:
        input_["instance_id"] = instance_id

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