Skip to content

validate_template

validate_template(
    *,
    config_overrides: Optional[CloudFormationClientConfig] = None,
    template_body: Optional[TemplateBody] = None,
    template_url: Optional[TemplateURL] = None,
) -> ValidateTemplateOutput

Validates a specified template. CloudFormation first checks if the template is valid JSON. If it isn't, CloudFormation checks if the template is valid YAML. If both these checks fail, CloudFormation returns a template validation error.

Parameters:

  • template_body (Optional[TemplateBody], default: None ) –

    Structure that contains the template body with a minimum length of 1 byte and a maximum length of 51,200 bytes.

    Conditional: You must pass TemplateURL or TemplateBody. If both are passed, only TemplateBody is used.

  • template_url (Optional[TemplateURL], default: None ) –

    The URL of a file that contains the template body. The URL must point to a template (max size: 1 MB) that is located in an Amazon S3 bucket or a Systems Manager document. The location for an Amazon S3 bucket must start with https://.

    Conditional: You must pass TemplateURL or TemplateBody. If both are passed, only TemplateBody is used.

Raises:

Source code in docs_src/capo_cloudformation/_services/cloud_formation.py
def validate_template(
    self,
    *,
    config_overrides: Optional[CloudFormationClientConfig] = None,
    template_body: Optional[
        "capo_cloudformation.types.template_body.TemplateBody"
    ] = None,
    template_url: Optional[
        "capo_cloudformation.types.template_url.TemplateURL"
    ] = None,
) -> "capo_cloudformation.types.validate_template_output.ValidateTemplateOutput":
    """<p>Validates a specified template. CloudFormation first checks if the template is valid JSON. If it isn't, CloudFormation checks if the template is valid YAML. If both these checks fail, CloudFormation returns a template validation error.</p>

    Args:
        template_body: <p>Structure that contains the template body with a minimum length of 1 byte and a maximum length of 51,200 bytes.</p> <p>Conditional: You must pass <code>TemplateURL</code> or <code>TemplateBody</code>. If both are passed, only <code>TemplateBody</code> is used.</p>
        template_url: <p>The URL of a file that contains the template body. The URL must point to a template (max size: 1 MB) that is located in an Amazon S3 bucket or a Systems Manager document. The location for an Amazon S3 bucket must start with <code>https://</code>.</p> <p>Conditional: You must pass <code>TemplateURL</code> or <code>TemplateBody</code>. If both are passed, only <code>TemplateBody</code> is used.</p>

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

    def _handler(
        req: "OperationRequest[capo_cloudformation.types.validate_template_input.ValidateTemplateInput]",
    ) -> OperationResponse[
        "capo_cloudformation.types.validate_template_output.ValidateTemplateOutput"
    ]:
        import capo_cloudformation._operations.cloud_formation.validate_template

        output, http_response = (
            capo_cloudformation._operations.cloud_formation.validate_template.validate_template(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ValidateTemplate")
    )
    input_: capo_cloudformation.types.validate_template_input.ValidateTemplateInput = {}
    if template_body is not None:
        input_["template_body"] = template_body
    if template_url is not None:
        input_["template_url"] = template_url

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