Skip to content

create_generated_template async

create_generated_template(
    *,
    config_overrides: Optional[AsyncCloudFormationClientConfig] = None,
    resources: Optional[ResourceDefinitions] = None,
    generated_template_name: Optional[GeneratedTemplateName] = None,
    stack_name: Optional[StackName] = None,
    template_configuration: Optional[TemplateConfiguration] = None,
) -> CreateGeneratedTemplateOutput

Creates a template from existing resources that are not already managed with CloudFormation. You can check the status of the template generation using the DescribeGeneratedTemplate API action.

Parameters:

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

    An optional list of resources to be included in the generated template.

    If no resources are specified,the template will be created without any resources. Resources can be added to the template using the UpdateGeneratedTemplate API action.

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

    The name assigned to the generated template.

  • stack_name (Optional[StackName], default: None ) –

    An optional name or ARN of a stack to use as the base stack for the generated template.

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

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

Raises:

  • AlreadyExistsException –

    The resource with the name requested already exists.

  • ConcurrentResourcesLimitExceededException –

    No more than 5 generated templates can be in an InProgress or Pending status at one time. This error is also returned if a generated template that is in an InProgress or Pending status is attempted to be updated or deleted.

  • LimitExceededException –

    The quota for the resource has already been reached.

    For information about resource and stack limitations, see CloudFormation quotas in the CloudFormation User Guide.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

To create a generated template This example creates a generated template with a resources file.

>>> await client.create_generated_template(resources=[{'ResourceType': 'AWS::S3::Bucket', 'ResourceIdentifier': {'BucketName': 'jazz-bucket'}}, {'ResourceType': 'AWS::EC2::DHCPOptions', 'ResourceIdentifier': {'DhcpOptionsId': 'random-id123'}}], generated_template_name='JazzyTemplate')
Source code in docs_src/capo_cloudformation/_services/async_cloud_formation.py
async def create_generated_template(
    self,
    *,
    config_overrides: Optional[AsyncCloudFormationClientConfig] = None,
    resources: Optional[
        "capo_cloudformation.types.resource_definitions.ResourceDefinitions"
    ] = None,
    generated_template_name: Optional[
        "capo_cloudformation.types.generated_template_name.GeneratedTemplateName"
    ] = None,
    stack_name: Optional["capo_cloudformation.types.stack_name.StackName"] = None,
    template_configuration: Optional[
        "capo_cloudformation.types.template_configuration.TemplateConfiguration"
    ] = None,
) -> "capo_cloudformation.types.create_generated_template_output.CreateGeneratedTemplateOutput":
    """<p>Creates a template from existing resources that are not already managed with CloudFormation. You can check the status of the template generation using the <code>DescribeGeneratedTemplate</code> API action.</p>

    Args:
        resources: <p>An optional list of resources to be included in the generated template.</p> <p>If no resources are specified,the template will be created without any resources. Resources can be added to the template using the <code>UpdateGeneratedTemplate</code> API action.</p>
        generated_template_name: <p>The name assigned to the generated template.</p>
        stack_name: <p>An optional name or ARN of a stack to use as the base stack for the generated 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.concurrent_resources_limit_exceeded_exception.ConcurrentResourcesLimitExceededException: <p>No more than 5 generated templates can be in an <code>InProgress</code> or <code>Pending</code> status at one time. This error is also returned if a generated template that is in an <code>InProgress</code> or <code>Pending</code> status is attempted to be updated or deleted.</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 create a generated template
        This example creates a generated template with a resources file.

        >>> await client.create_generated_template(resources=[{'ResourceType': 'AWS::S3::Bucket', 'ResourceIdentifier': {'BucketName': 'jazz-bucket'}}, {'ResourceType': 'AWS::EC2::DHCPOptions', 'ResourceIdentifier': {'DhcpOptionsId': 'random-id123'}}], generated_template_name='JazzyTemplate')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudformation.types.create_generated_template_input.CreateGeneratedTemplateInput]",
    ) -> AsyncOperationResponse[
        "capo_cloudformation.types.create_generated_template_output.CreateGeneratedTemplateOutput"
    ]:
        import capo_cloudformation._operations.cloud_formation.create_generated_template

        (
            output,
            http_response,
        ) = await capo_cloudformation._operations.cloud_formation.create_generated_template.async_create_generated_template(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateGeneratedTemplate")
    )
    input_: capo_cloudformation.types.create_generated_template_input.CreateGeneratedTemplateInput = {}
    if resources is not None:
        input_["resources"] = resources
    if generated_template_name is not None:
        input_["generated_template_name"] = generated_template_name
    if stack_name is not None:
        input_["stack_name"] = stack_name
    if template_configuration is not None:
        input_["template_configuration"] = template_configuration

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