time_sleep (Resource)

Manages a resource that delays creation and/or destruction, typically for further resources. This prevents cross-platform compatibility and destroy-time issues with using the local-exec provisioner.

Example Usage

Delay Create Usage

# DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
from constructs import Construct
from cdktf import TerraformStack
#
# Provider bindings are generated by running `cdktf get`.
# See https://cdk.tf/provider-generation for more details.
#
from imports.null.resource import Resource
from imports.time.sleep import Sleep
class MyConvertedCode(TerraformStack):
    def __init__(self, scope, name):
        super().__init__(scope, name)
        null_resource_previous = Resource(self, "previous")
        wait30_seconds = Sleep(self, "wait_30_seconds",
            create_duration="30s",
            depends_on=[null_resource_previous]
        )
        Resource(self, "next",
            depends_on=[wait30_seconds]
        )

Delay Destroy Usage

# DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
from constructs import Construct
from cdktf import TerraformStack
#
# Provider bindings are generated by running `cdktf get`.
# See https://cdk.tf/provider-generation for more details.
#
from imports.null.resource import Resource
from imports.time.sleep import Sleep
class MyConvertedCode(TerraformStack):
    def __init__(self, scope, name):
        super().__init__(scope, name)
        null_resource_previous = Resource(self, "previous")
        wait30_seconds = Sleep(self, "wait_30_seconds",
            depends_on=[null_resource_previous],
            destroy_duration="30s"
        )
        Resource(self, "next",
            depends_on=[wait30_seconds]
        )

Triggers Usage

# DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
from constructs import Construct
from cdktf import Token, Fn, TerraformStack
#
# Provider bindings are generated by running `cdktf get`.
# See https://cdk.tf/provider-generation for more details.
#
from imports.aws.db_subnet_group import DbSubnetGroup
from imports.aws.ram_resource_association import RamResourceAssociation
from imports.time.sleep import Sleep
class MyConvertedCode(TerraformStack):
    def __init__(self, scope, name):
        super().__init__(scope, name)
        example = RamResourceAssociation(self, "example",
            resource_arn=Token.as_string(aws_subnet_example.arn),
            resource_share_arn=Token.as_string(aws_ram_resource_share_example.arn)
        )
        ram_resource_propagation = Sleep(self, "ram_resource_propagation",
            create_duration="60s",
            triggers={
                "subnet_arn": example.resource_arn,
                "subnet_id": Token.as_string(aws_subnet_example.id)
            }
        )
        aws_db_subnet_group_example = DbSubnetGroup(self, "example_2",
            name="example",
            subnet_ids=[
                Token.as_string(
                    Fn.lookup_nested(ram_resource_propagation.triggers, ["\"subnet_id\""]))
            ]
        )
        # This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.
        aws_db_subnet_group_example.override_logical_id("example")

Schema

Optional

Read-Only

Import

This resource can be imported with the create_duration and destroy_duration, separated by a comma (,).

e.g. For 30 seconds create duration with no destroy duration:

terraform import time_sleep.example 30s,

e.g. For 30 seconds destroy duration with no create duration:

terraform import time_sleep.example ,30s

The triggers argument cannot be imported.