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
import { Construct } from "constructs";
import { TerraformStack } from "cdktf";
/*
 * Provider bindings are generated by running `cdktf get`.
 * See https://cdk.tf/provider-generation for more details.
 */
import { Resource } from "./.gen/providers/null/resource";
import { Sleep } from "./.gen/providers/time/sleep";
class MyConvertedCode extends TerraformStack {
  constructor(scope: Construct, name: string) {
    super(scope, name);
    const nullResourcePrevious = new Resource(this, "previous", {});
    const wait30Seconds = new Sleep(this, "wait_30_seconds", {
      createDuration: "30s",
      dependsOn: [nullResourcePrevious],
    });
    new Resource(this, "next", {
      dependsOn: [wait30Seconds],
    });
  }
}

Delay Destroy Usage

// DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
import { Construct } from "constructs";
import { TerraformStack } from "cdktf";
/*
 * Provider bindings are generated by running `cdktf get`.
 * See https://cdk.tf/provider-generation for more details.
 */
import { Resource } from "./.gen/providers/null/resource";
import { Sleep } from "./.gen/providers/time/sleep";
class MyConvertedCode extends TerraformStack {
  constructor(scope: Construct, name: string) {
    super(scope, name);
    const nullResourcePrevious = new Resource(this, "previous", {});
    const wait30Seconds = new Sleep(this, "wait_30_seconds", {
      dependsOn: [nullResourcePrevious],
      destroyDuration: "30s",
    });
    new Resource(this, "next", {
      dependsOn: [wait30Seconds],
    });
  }
}

Triggers Usage

// DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
import { Construct } from "constructs";
import { Token, Fn, TerraformStack } from "cdktf";
/*
 * Provider bindings are generated by running `cdktf get`.
 * See https://cdk.tf/provider-generation for more details.
 */
import { DbSubnetGroup } from "./.gen/providers/aws/db-subnet-group";
import { RamResourceAssociation } from "./.gen/providers/aws/ram-resource-association";
import { Sleep } from "./.gen/providers/time/sleep";
class MyConvertedCode extends TerraformStack {
  constructor(scope: Construct, name: string) {
    super(scope, name);
    const example = new RamResourceAssociation(this, "example", {
      resourceArn: Token.asString(awsSubnetExample.arn),
      resourceShareArn: Token.asString(awsRamResourceShareExample.arn),
    });
    const ramResourcePropagation = new Sleep(this, "ram_resource_propagation", {
      createDuration: "60s",
      triggers: {
        subnet_arn: example.resourceArn,
        subnet_id: Token.asString(awsSubnetExample.id),
      },
    });
    const awsDbSubnetGroupExample = new DbSubnetGroup(this, "example_2", {
      name: "example",
      subnetIds: [
        Token.asString(
          Fn.lookupNested(ramResourcePropagation.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.*/
    awsDbSubnetGroupExample.overrideLogicalId("example");
  }
}

Schema

Optional

Read-Only

Import

This resource can be imported with the createDuration and destroyDuration, 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.