Skip to content

wait_until_stack_exists async

wait_until_stack_exists(
    *,
    max_wait_time: float,
    min_delay: float = 5,
    max_delay: float = 120,
    config_overrides: Optional[AsyncCloudFormationClientConfig] = None,
    stack_name: Optional[StackName] = None,
    next_token: Optional[NextToken] = None,
) -> DescribeStacksOutput

Wait for stack_exists.

Parameters:

  • max_wait_time (float) –

    Maximum total seconds to wait before raising WaiterTimeoutError.

  • min_delay (float, default: 5 ) –

    Minimum seconds between operation attempts (spec default 2).

  • max_delay (float, default: 120 ) –

    Maximum seconds between operation attempts (spec default 120).

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

    If you don't pass a parameter to StackName, the API returns a response that describes all resources in the account, which can impact performance. This requires ListStacks and DescribeStacks permissions.

    Consider using the ListStacks API if you're not passing a parameter to StackName.

    The IAM policy below can be added to IAM policies when you want to limit resource-level permissions and avoid returning a response when no parameter is sent in the request:

    { "Version": "2012-10-17", "Statement": [{ "Effect": "Deny", "Action": "cloudformation:DescribeStacks", "NotResource": "arn:aws:cloudformation:::stack//" }] }

    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.

  • next_token (Optional[NextToken], default: None ) –

    The token for the next set of items to return. (You received this token from a previous call.)

Source code in docs_src/capo_cloudformation/_services/async_cloud_formation.py
async def wait_until_stack_exists(
    self,
    *,
    max_wait_time: float,
    min_delay: float = 5,
    max_delay: float = 120,
    config_overrides: Optional[AsyncCloudFormationClientConfig] = None,
    stack_name: Optional["capo_cloudformation.types.stack_name.StackName"] = None,
    next_token: Optional["capo_cloudformation.types.next_token.NextToken"] = None,
) -> "capo_cloudformation.types.describe_stacks_output.DescribeStacksOutput":
    """Wait for stack_exists.

    Args:
        max_wait_time: Maximum total seconds to wait before raising WaiterTimeoutError.
        min_delay: Minimum seconds between operation attempts (spec default 2).
        max_delay: Maximum seconds between operation attempts (spec default 120).
        stack_name: <note> <p>If you don't pass a parameter to <code>StackName</code>, the API returns a response that describes all resources in the account, which can impact performance. This requires <code>ListStacks</code> and <code>DescribeStacks</code> permissions.</p> <p>Consider using the <a>ListStacks</a> API if you're not passing a parameter to <code>StackName</code>.</p> <p>The IAM policy below can be added to IAM policies when you want to limit resource-level permissions and avoid returning a response when no parameter is sent in the request:</p> <p>{ "Version": "2012-10-17", "Statement": [{ "Effect": "Deny", "Action": "cloudformation:DescribeStacks", "NotResource": "arn:aws:cloudformation:*:*:stack/*/*" }] }</p> </note> <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>
        next_token: <p>The token for the next set of items to return. (You received this token from a previous call.)</p>
    """
    start = time.monotonic()
    attempt = 0
    while True:
        op_output: "capo_cloudformation.types.describe_stacks_output.DescribeStacksOutput | None" = None
        op_error: ServiceError | None = None
        try:
            op_output = await self.describe_stacks(  # noqa: F841
                config_overrides=config_overrides,
                stack_name=stack_name,
                next_token=next_token,
            )
        except ServiceError as e:
            op_error = e
        if op_output is not None:
            return op_output
        elif op_error is not None and op_error.code == "ValidationError":
            pass
        elif op_error is not None:
            raise op_error

        elapsed = time.monotonic() - start
        remaining = max_wait_time - elapsed
        if remaining <= 0:
            raise WaiterTimeoutError("stack_exists", max_wait_time)
        delay = min(max_delay, min_delay * (2**attempt))
        delay = random.uniform(min_delay, delay)
        delay = min(delay, remaining)
        await anysleep(delay)
        attempt += 1