Skip to content

update_generated_template

update_generated_template(
    *,
    config_overrides: Optional[CloudFormationClientConfig] = None,
    generated_template_name: Optional[GeneratedTemplateName] = None,
    new_generated_template_name: Optional[GeneratedTemplateName] = None,
    add_resources: Optional[ResourceDefinitions] = None,
    remove_resources: Optional[JazzLogicalResourceIds] = None,
    refresh_all_resources: Optional[RefreshAllResources] = None,
    template_configuration: Optional[TemplateConfiguration] = None,
) -> UpdateGeneratedTemplateOutput

Updates a generated template. This can be used to change the name, add and remove resources, refresh resources, and change the DeletionPolicy and UpdateReplacePolicy settings. You can check the status of the update to the generated template using the DescribeGeneratedTemplate API action.

Parameters:

  • generated_template_name (Optional[GeneratedTemplateName], default: None ) –

    The name or Amazon Resource Name (ARN) of a generated template.

  • new_generated_template_name (Optional[GeneratedTemplateName], default: None ) –

    An optional new name to assign to the generated template.

  • add_resources (Optional[ResourceDefinitions], default: None ) –

    An optional list of resources to be added to the generated template.

  • remove_resources (Optional[JazzLogicalResourceIds], default: None ) –

    A list of logical ids for resources to remove from the generated template.

  • refresh_all_resources (Optional[RefreshAllResources], default: None ) –

    If true, update the resource properties in the generated template with their current live state. This feature is useful when the resource properties in your generated a template does not reflect the live state of the resource properties. This happens when a user update the resource properties after generating a template.

  • template_configuration (Optional[TemplateConfiguration], default: None ) –

    The configuration details of the generated template, including the DeletionPolicy and UpdateReplacePolicy.

Raises:

Examples:

To add resources to a generated template This example adds resources to a generated template

>>> client.update_generated_template(generated_template_name='JazzyTemplate', add_resources=[{'ResourceType': 'AWS::S3::Bucket', 'ResourceIdentifier': {'BucketName': 'jazz-bucket'}}, {'ResourceType': 'AWS::EC2::DHCPOptions', 'ResourceIdentifier': {'DhcpOptionsId': 'random-id123'}}])
To update a generated template's name
This example updates a generated template with a new name.
>>> client.update_generated_template(generated_template_name='JazzyTemplate', new_generated_template_name='JazzierTemplate')
To remove resources from a generated template
This example removes resources from a generated template
>>> client.update_generated_template(generated_template_name='JazzyTemplate', remove_resources=['LogicalResourceId1', 'LogicalResourceId2'])
Source code in docs_src/capo_cloudformation/_services/cloud_formation.py
def update_generated_template(
    self,
    *,
    config_overrides: Optional[CloudFormationClientConfig] = None,
    generated_template_name: Optional[
        "capo_cloudformation.types.generated_template_name.GeneratedTemplateName"
    ] = None,
    new_generated_template_name: Optional[
        "capo_cloudformation.types.generated_template_name.GeneratedTemplateName"
    ] = None,
    add_resources: Optional[
        "capo_cloudformation.types.resource_definitions.ResourceDefinitions"
    ] = None,
    remove_resources: Optional[
        "capo_cloudformation.types.jazz_logical_resource_ids.JazzLogicalResourceIds"
    ] = None,
    refresh_all_resources: Optional[
        "capo_cloudformation.types.refresh_all_resources.RefreshAllResources"
    ] = None,
    template_configuration: Optional[
        "capo_cloudformation.types.template_configuration.TemplateConfiguration"
    ] = None,
) -> "capo_cloudformation.types.update_generated_template_output.UpdateGeneratedTemplateOutput":
    """<p>Updates a generated template. This can be used to change the name, add and remove resources, refresh resources, and change the <code>DeletionPolicy</code> and <code>UpdateReplacePolicy</code> settings. You can check the status of the update to the generated template using the <code>DescribeGeneratedTemplate</code> API action.</p>

    Args:
        generated_template_name: <p>The name or Amazon Resource Name (ARN) of a generated template.</p>
        new_generated_template_name: <p>An optional new name to assign to the generated template.</p>
        add_resources: <p>An optional list of resources to be added to the generated template.</p>
        remove_resources: <p>A list of logical ids for resources to remove from the generated template.</p>
        refresh_all_resources: <p>If <code>true</code>, update the resource properties in the generated template with their current live state. This feature is useful when the resource properties in your generated a template does not reflect the live state of the resource properties. This happens when a user update the resource properties after generating a template.</p>
        template_configuration: <p>The configuration details of the generated template, including the <code>DeletionPolicy</code> and <code>UpdateReplacePolicy</code>.</p>

    Raises:
        capo_cloudformation.errors.already_exists_exception.AlreadyExistsException: <p>The resource with the name requested already exists.</p>
        capo_cloudformation.errors.generated_template_not_found_exception.GeneratedTemplateNotFoundException: <p>The generated template was not found.</p>
        capo_cloudformation.errors.limit_exceeded_exception.LimitExceededException: <p>The quota for the resource has already been reached.</p> <p>For information about resource and stack limitations, see <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html">CloudFormation quotas</a> in the <i>CloudFormation User Guide</i>.</p>
        capo_cloudformation.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To add resources to a generated template
        This example adds resources to a generated template

        >>> client.update_generated_template(generated_template_name='JazzyTemplate', add_resources=[{'ResourceType': 'AWS::S3::Bucket', 'ResourceIdentifier': {'BucketName': 'jazz-bucket'}}, {'ResourceType': 'AWS::EC2::DHCPOptions', 'ResourceIdentifier': {'DhcpOptionsId': 'random-id123'}}])
        To update a generated template's name
        This example updates a generated template with a new name.

        >>> client.update_generated_template(generated_template_name='JazzyTemplate', new_generated_template_name='JazzierTemplate')
        To remove resources from a generated template
        This example removes resources from a generated template

        >>> client.update_generated_template(generated_template_name='JazzyTemplate', remove_resources=['LogicalResourceId1', 'LogicalResourceId2'])
    """

    def _handler(
        req: "OperationRequest[capo_cloudformation.types.update_generated_template_input.UpdateGeneratedTemplateInput]",
    ) -> OperationResponse[
        "capo_cloudformation.types.update_generated_template_output.UpdateGeneratedTemplateOutput"
    ]:
        import capo_cloudformation._operations.cloud_formation.update_generated_template

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateGeneratedTemplate")
    )
    input_: capo_cloudformation.types.update_generated_template_input.UpdateGeneratedTemplateInput = {}
    if generated_template_name is not None:
        input_["generated_template_name"] = generated_template_name
    if new_generated_template_name is not None:
        input_["new_generated_template_name"] = new_generated_template_name
    if add_resources is not None:
        input_["add_resources"] = add_resources
    if remove_resources is not None:
        input_["remove_resources"] = remove_resources
    if refresh_all_resources is not None:
        input_["refresh_all_resources"] = refresh_all_resources
    if template_configuration is not None:
        input_["template_configuration"] = template_configuration

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