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.
If the template doesn't exist, a ValidationError is returned.
Parameters:
-
stack_name
(Optional[StackName], default:
None
)
–
The name or the unique stack ID that's associated with the stack, which aren't always interchangeable:
-
change_set_name
(Optional[ChangeSetNameOrId], default:
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.
-
template_stage
(Optional[TemplateStage], default:
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.
Raises:
-
ChangeSetNotFoundException
–
The specified change set name or ID doesn't exit. To view valid change sets for a stack, use the ListChangeSets operation.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_cloudformation/_services/cloud_formation.py
| def get_template(
self,
*,
config_overrides: Optional[CloudFormationClientConfig] = None,
stack_name: Optional["capo_cloudformation.types.stack_name.StackName"] = None,
change_set_name: Optional[
"capo_cloudformation.types.change_set_name_or_id.ChangeSetNameOrId"
] = None,
template_stage: Optional[
"capo_cloudformation.types.template_stage.TemplateStage"
] = None,
) -> "capo_cloudformation.types.get_template_output.GetTemplateOutput":
"""<p>Returns the template body for a specified stack. You can get the template for running or deleted stacks.</p> <p>For deleted stacks, <code>GetTemplate</code> returns the template for up to 90 days after the stack has been deleted.</p> <note> <p>If the template doesn't exist, a <code>ValidationError</code> is returned.</p> </note>
Args:
stack_name: <p>The name or the unique stack ID that's associated with the stack, which aren't always interchangeable:</p> <ul> <li> <p>Running stacks: You can specify either the stack's name or its unique stack ID.</p> </li> <li> <p>Deleted stacks: You must specify the unique stack ID.</p> </li> </ul>
change_set_name: <p>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 <code>StackName</code>.</p>
template_stage: <p>For templates that include transforms, the stage of the template that CloudFormation returns. To get the user-submitted template, specify <code>Original</code>. To get the template after CloudFormation has processed all transforms, specify <code>Processed</code>.</p> <p>If the template doesn't include transforms, <code>Original</code> and <code>Processed</code> return the same template. By default, CloudFormation specifies <code>Processed</code>.</p>
Raises:
capo_cloudformation.errors.change_set_not_found_exception.ChangeSetNotFoundException: <p>The specified change set name or ID doesn't exit. To view valid change sets for a stack, use the <code>ListChangeSets</code> operation.</p>
capo_cloudformation.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_cloudformation.types.get_template_input.GetTemplateInput]",
) -> OperationResponse[
"capo_cloudformation.types.get_template_output.GetTemplateOutput"
]:
import capo_cloudformation._operations.cloud_formation.get_template
output, http_response = (
capo_cloudformation._operations.cloud_formation.get_template.get_template(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("GetTemplate")
)
input_: capo_cloudformation.types.get_template_input.GetTemplateInput = {}
if stack_name is not None:
input_["stack_name"] = stack_name
if change_set_name is not None:
input_["change_set_name"] = change_set_name
if template_stage is not None:
input_["template_stage"] = template_stage
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|