Skip to content

CloudFormation  >  Operations  >  get_template

get_template

Operation

get_template async

get_template(input: GetTemplateInput, plugins: list[Plugin] | None = None) -> GetTemplateOutput

Returns the template body for a specified stack. You can get the template for running or deleted stacks.

For deleted stacks, GetTemplate returns the template for up to 90 days after the stack has been deleted.

Note

If the template doesn't exist, a ValidationError is returned.

Parameters:

Name Type Description Default
input GetTemplateInput

An instance of GetTemplateInput.

required
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None

Returns:

Type Description
GetTemplateOutput

An instance of GetTemplateOutput.

Input

GetTemplateInput dataclass

Bases: _SerdeShape

The input for a GetTemplate action.

Attributes

change_set_name class-attribute instance-attribute
change_set_name: str | None = ...

The name or Amazon Resource Name (ARN) of a change set for which CloudFormation returns the associated template. If you specify a name, you must also specify the StackName.

stack_name class-attribute instance-attribute
stack_name: str | None = ...

The name or the unique stack ID that's associated with the stack, which aren't always interchangeable:

  • Running stacks: You can specify either the stack's name or its unique stack ID.

  • Deleted stacks: You must specify the unique stack ID.

template_stage class-attribute instance-attribute
template_stage: str | None = ...

For templates that include transforms, the stage of the template that CloudFormation returns. To get the user-submitted template, specify Original. To get the template after CloudFormation has processed all transforms, specify Processed.

If the template doesn't include transforms, Original and Processed return the same template. By default, CloudFormation specifies Processed.

Output

GetTemplateOutput dataclass

Bases: _SerdeShape

The output for GetTemplate action.

Attributes

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.

stages_available class-attribute instance-attribute
stages_available: list[str] | None = ...

The stage of the template that you can retrieve. For stacks, the Original and Processed templates are always available. For change sets, the Original template is always available. After CloudFormation finishes creating the change set, the Processed template becomes available.

template_body class-attribute instance-attribute
template_body: str | None = ...

Structure that contains the template body.

CloudFormation returns the same template that was used when the stack was created.