Detects whether a stack's actual configuration differs, or has drifted, from its expected configuration, as defined in the stack template and any values specified as template parameters. For each resource in the stack that supports drift detection, CloudFormation compares the actual configuration of the resource with its expected template configuration. Only resource properties explicitly defined in the stack template are checked for drift. A stack is considered to have drifted if one or more of its resources differ from their expected template configurations. For more information, see Detect unmanaged configuration changes to stacks and resources with drift detection.
Use DetectStackDrift to detect drift on all supported resources for a given stack, or DetectStackResourceDrift to detect drift on individual resources.
For a list of stack resources that currently support drift detection, see Resource type support for imports and drift detection.
DetectStackDrift can take up to several minutes, depending on the number of resources contained within the stack. Use DescribeStackDriftDetectionStatus to monitor the progress of a detect stack drift operation. Once the drift detection operation has completed, use DescribeStackResourceDrifts to return drift information about the stack and its resources.
When detecting drift on a stack, CloudFormation doesn't detect drift on any nested stacks belonging to that stack. Perform DetectStackDrift directly on the nested stack itself.
Parameters:
-
stack_name
(Optional[StackNameOrId], default:
None
)
–
The name of the stack for which you want to detect drift.
-
logical_resource_ids
(Optional[LogicalResourceIds], default:
None
)
–
The logical names of any resources you want to use as filters.
Raises:
Source code in docs_src/capo_cloudformation/_services/async_cloud_formation.py
| async def detect_stack_drift(
self,
*,
config_overrides: Optional[AsyncCloudFormationClientConfig] = None,
stack_name: Optional[
"capo_cloudformation.types.stack_name_or_id.StackNameOrId"
] = None,
logical_resource_ids: Optional[
"capo_cloudformation.types.logical_resource_ids.LogicalResourceIds"
] = None,
) -> "capo_cloudformation.types.detect_stack_drift_output.DetectStackDriftOutput":
"""<p>Detects whether a stack's actual configuration differs, or has <i>drifted</i>, from its expected configuration, as defined in the stack template and any values specified as template parameters. For each resource in the stack that supports drift detection, CloudFormation compares the actual configuration of the resource with its expected template configuration. Only resource properties explicitly defined in the stack template are checked for drift. A stack is considered to have drifted if one or more of its resources differ from their expected template configurations. For more information, see <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-drift.html">Detect unmanaged configuration changes to stacks and resources with drift detection</a>.</p> <p>Use <code>DetectStackDrift</code> to detect drift on all supported resources for a given stack, or <a>DetectStackResourceDrift</a> to detect drift on individual resources.</p> <p>For a list of stack resources that currently support drift detection, see <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-supported-resources.html">Resource type support for imports and drift detection</a>.</p> <p> <code>DetectStackDrift</code> can take up to several minutes, depending on the number of resources contained within the stack. Use <a>DescribeStackDriftDetectionStatus</a> to monitor the progress of a detect stack drift operation. Once the drift detection operation has completed, use <a>DescribeStackResourceDrifts</a> to return drift information about the stack and its resources.</p> <p>When detecting drift on a stack, CloudFormation doesn't detect drift on any nested stacks belonging to that stack. Perform <code>DetectStackDrift</code> directly on the nested stack itself.</p>
Args:
stack_name: <p>The name of the stack for which you want to detect drift.</p>
logical_resource_ids: <p>The logical names of any resources you want to use as filters.</p>
Raises:
capo_cloudformation.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_cloudformation.types.detect_stack_drift_input.DetectStackDriftInput]",
) -> AsyncOperationResponse[
"capo_cloudformation.types.detect_stack_drift_output.DetectStackDriftOutput"
]:
import capo_cloudformation._operations.cloud_formation.detect_stack_drift
(
output,
http_response,
) = await capo_cloudformation._operations.cloud_formation.detect_stack_drift.async_detect_stack_drift(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("DetectStackDrift")
)
input_: capo_cloudformation.types.detect_stack_drift_input.DetectStackDriftInput = {}
if stack_name is not None:
input_["stack_name"] = stack_name
if logical_resource_ids is not None:
input_["logical_resource_ids"] = logical_resource_ids
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|