time.Sleep
Explore with Pulumi AI
Example Usage
Delay Create Usage
import * as pulumi from "@pulumi/pulumi";
import * as _null from "@pulumi/null";
import * as time from "@pulumiverse/time";
// This resource will destroy (potentially immediately) after null_resource.next
const previous = new _null.Resource("previous", {});
const wait30Seconds = new time.Sleep("wait30Seconds", {createDuration: "30s"}, {
dependsOn: [previous],
});
// This resource will create (at least) 30 seconds after null_resource.previous
const next = new _null.Resource("next", {}, {
dependsOn: [wait30Seconds],
});
import pulumi
import pulumi_null as null
import pulumiverse_time as time
# This resource will destroy (potentially immediately) after null_resource.next
previous = null.Resource("previous")
wait30_seconds = time.Sleep("wait30Seconds", create_duration="30s",
opts = pulumi.ResourceOptions(depends_on=[previous]))
# This resource will create (at least) 30 seconds after null_resource.previous
next = null.Resource("next", opts = pulumi.ResourceOptions(depends_on=[wait30_seconds]))
package main
import (
"github.com/pulumi/pulumi-null/sdk/go/null"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumiverse/pulumi-time/sdk/go/time"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// This resource will destroy (potentially immediately) after null_resource.next
previous, err := null.NewResource(ctx, "previous", nil)
if err != nil {
return err
}
wait30Seconds, err := time.NewSleep(ctx, "wait30Seconds", &time.SleepArgs{
CreateDuration: pulumi.String("30s"),
}, pulumi.DependsOn([]pulumi.Resource{
previous,
}))
if err != nil {
return err
}
// This resource will create (at least) 30 seconds after null_resource.previous
_, err = null.NewResource(ctx, "next", nil, pulumi.DependsOn([]pulumi.Resource{
wait30Seconds,
}))
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Null = Pulumi.Null;
using Time = Pulumiverse.Time;
return await Deployment.RunAsync(() =>
{
// This resource will destroy (potentially immediately) after null_resource.next
var previous = new Null.Resource("previous");
var wait30Seconds = new Time.Sleep("wait30Seconds", new()
{
CreateDuration = "30s",
}, new CustomResourceOptions
{
DependsOn =
{
previous,
},
});
// This resource will create (at least) 30 seconds after null_resource.previous
var next = new Null.Resource("next", new()
{
}, new CustomResourceOptions
{
DependsOn =
{
wait30Seconds,
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.null.Resource;
import com.pulumi.time.Sleep;
import com.pulumi.time.SleepArgs;
import com.pulumi.null.ResourceArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
// This resource will destroy (potentially immediately) after null_resource.next
var previous = new Resource("previous");
var wait30Seconds = new Sleep("wait30Seconds", SleepArgs.builder()
.createDuration("30s")
.build(), CustomResourceOptions.builder()
.dependsOn(previous)
.build());
// This resource will create (at least) 30 seconds after null_resource.previous
var next = new Resource("next", ResourceArgs.Empty, CustomResourceOptions.builder()
.dependsOn(wait30Seconds)
.build());
}
}
resources:
# This resource will destroy (potentially immediately) after null_resource.next
previous:
type: null:Resource
wait30Seconds:
type: time:Sleep
properties:
createDuration: 30s
options:
dependson:
- ${previous}
# This resource will create (at least) 30 seconds after null_resource.previous
next:
type: null:Resource
options:
dependson:
- ${wait30Seconds}
Delay Destroy Usage
import * as pulumi from "@pulumi/pulumi";
import * as _null from "@pulumi/null";
import * as time from "@pulumiverse/time";
// This resource will destroy (at least) 30 seconds after null_resource.next
const previous = new _null.Resource("previous", {});
const wait30Seconds = new time.Sleep("wait30Seconds", {destroyDuration: "30s"}, {
dependsOn: [previous],
});
// This resource will create (potentially immediately) after null_resource.previous
const next = new _null.Resource("next", {}, {
dependsOn: [wait30Seconds],
});
import pulumi
import pulumi_null as null
import pulumiverse_time as time
# This resource will destroy (at least) 30 seconds after null_resource.next
previous = null.Resource("previous")
wait30_seconds = time.Sleep("wait30Seconds", destroy_duration="30s",
opts = pulumi.ResourceOptions(depends_on=[previous]))
# This resource will create (potentially immediately) after null_resource.previous
next = null.Resource("next", opts = pulumi.ResourceOptions(depends_on=[wait30_seconds]))
package main
import (
"github.com/pulumi/pulumi-null/sdk/go/null"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumiverse/pulumi-time/sdk/go/time"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// This resource will destroy (at least) 30 seconds after null_resource.next
previous, err := null.NewResource(ctx, "previous", nil)
if err != nil {
return err
}
wait30Seconds, err := time.NewSleep(ctx, "wait30Seconds", &time.SleepArgs{
DestroyDuration: pulumi.String("30s"),
}, pulumi.DependsOn([]pulumi.Resource{
previous,
}))
if err != nil {
return err
}
// This resource will create (potentially immediately) after null_resource.previous
_, err = null.NewResource(ctx, "next", nil, pulumi.DependsOn([]pulumi.Resource{
wait30Seconds,
}))
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Null = Pulumi.Null;
using Time = Pulumiverse.Time;
return await Deployment.RunAsync(() =>
{
// This resource will destroy (at least) 30 seconds after null_resource.next
var previous = new Null.Resource("previous");
var wait30Seconds = new Time.Sleep("wait30Seconds", new()
{
DestroyDuration = "30s",
}, new CustomResourceOptions
{
DependsOn =
{
previous,
},
});
// This resource will create (potentially immediately) after null_resource.previous
var next = new Null.Resource("next", new()
{
}, new CustomResourceOptions
{
DependsOn =
{
wait30Seconds,
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.null.Resource;
import com.pulumi.time.Sleep;
import com.pulumi.time.SleepArgs;
import com.pulumi.null.ResourceArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
// This resource will destroy (at least) 30 seconds after null_resource.next
var previous = new Resource("previous");
var wait30Seconds = new Sleep("wait30Seconds", SleepArgs.builder()
.destroyDuration("30s")
.build(), CustomResourceOptions.builder()
.dependsOn(previous)
.build());
// This resource will create (potentially immediately) after null_resource.previous
var next = new Resource("next", ResourceArgs.Empty, CustomResourceOptions.builder()
.dependsOn(wait30Seconds)
.build());
}
}
resources:
# This resource will destroy (at least) 30 seconds after null_resource.next
previous:
type: null:Resource
wait30Seconds:
type: time:Sleep
properties:
destroyDuration: 30s
options:
dependson:
- ${previous}
# This resource will create (potentially immediately) after null_resource.previous
next:
type: null:Resource
options:
dependson:
- ${wait30Seconds}
Triggers Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as time from "@pulumiverse/time";
const exampleResourceAssociation = new aws.ram.ResourceAssociation("exampleResourceAssociation", {
resourceArn: aws_subnet.example.arn,
resourceShareArn: aws_ram_resource_share.example.arn,
});
// AWS resources shared via Resource Access Manager can take a few seconds to
// propagate across AWS accounts after RAM returns a successful association.
const ramResourcePropagation = new time.Sleep("ramResourcePropagation", {
createDuration: "60s",
triggers: {
subnet_arn: exampleResourceAssociation.resourceArn,
subnet_id: aws_subnet.example.id,
},
});
const exampleSubnetGroup = new aws.rds.SubnetGroup("exampleSubnetGroup", {subnetIds: [ramResourcePropagation.triggers.apply(triggers => triggers?.subnet_id)]});
import pulumi
import pulumi_aws as aws
import pulumiverse_time as time
example_resource_association = aws.ram.ResourceAssociation("exampleResourceAssociation",
resource_arn=aws_subnet["example"]["arn"],
resource_share_arn=aws_ram_resource_share["example"]["arn"])
# AWS resources shared via Resource Access Manager can take a few seconds to
# propagate across AWS accounts after RAM returns a successful association.
ram_resource_propagation = time.Sleep("ramResourcePropagation",
create_duration="60s",
triggers={
"subnet_arn": example_resource_association.resource_arn,
"subnet_id": aws_subnet["example"]["id"],
})
example_subnet_group = aws.rds.SubnetGroup("exampleSubnetGroup", subnet_ids=[ram_resource_propagation.triggers["subnet_id"]])
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ram"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/rds"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumiverse/pulumi-time/sdk/go/time"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleResourceAssociation, err := ram.NewResourceAssociation(ctx, "exampleResourceAssociation", &ram.ResourceAssociationArgs{
ResourceArn: pulumi.Any(aws_subnet.Example.Arn),
ResourceShareArn: pulumi.Any(aws_ram_resource_share.Example.Arn),
})
if err != nil {
return err
}
// AWS resources shared via Resource Access Manager can take a few seconds to
// propagate across AWS accounts after RAM returns a successful association.
ramResourcePropagation, err := time.NewSleep(ctx, "ramResourcePropagation", &time.SleepArgs{
CreateDuration: pulumi.String("60s"),
Triggers: pulumi.StringMap{
"subnet_arn": exampleResourceAssociation.ResourceArn,
"subnet_id": pulumi.Any(aws_subnet.Example.Id),
},
})
if err != nil {
return err
}
_, err = rds.NewSubnetGroup(ctx, "exampleSubnetGroup", &rds.SubnetGroupArgs{
SubnetIds: pulumi.StringArray{
pulumi.String(ramResourcePropagation.Triggers.ApplyT(func(triggers map[string]string) (*string, error) {
return &triggers.Subnet_id, nil
}).(pulumi.StringPtrOutput)),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
using Time = Pulumiverse.Time;
return await Deployment.RunAsync(() =>
{
var exampleResourceAssociation = new Aws.Ram.ResourceAssociation("exampleResourceAssociation", new()
{
ResourceArn = aws_subnet.Example.Arn,
ResourceShareArn = aws_ram_resource_share.Example.Arn,
});
// AWS resources shared via Resource Access Manager can take a few seconds to
// propagate across AWS accounts after RAM returns a successful association.
var ramResourcePropagation = new Time.Sleep("ramResourcePropagation", new()
{
CreateDuration = "60s",
Triggers =
{
{ "subnet_arn", exampleResourceAssociation.ResourceArn },
{ "subnet_id", aws_subnet.Example.Id },
},
});
var exampleSubnetGroup = new Aws.Rds.SubnetGroup("exampleSubnetGroup", new()
{
SubnetIds = new[]
{
ramResourcePropagation.Triggers.Apply(triggers => triggers?.Subnet_id),
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ram.ResourceAssociation;
import com.pulumi.aws.ram.ResourceAssociationArgs;
import com.pulumi.time.Sleep;
import com.pulumi.time.SleepArgs;
import com.pulumi.aws.rds.SubnetGroup;
import com.pulumi.aws.rds.SubnetGroupArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var exampleResourceAssociation = new ResourceAssociation("exampleResourceAssociation", ResourceAssociationArgs.builder()
.resourceArn(aws_subnet.example().arn())
.resourceShareArn(aws_ram_resource_share.example().arn())
.build());
// AWS resources shared via Resource Access Manager can take a few seconds to
// propagate across AWS accounts after RAM returns a successful association.
var ramResourcePropagation = new Sleep("ramResourcePropagation", SleepArgs.builder()
.createDuration("60s")
.triggers(Map.ofEntries(
Map.entry("subnet_arn", exampleResourceAssociation.resourceArn()),
Map.entry("subnet_id", aws_subnet.example().id())
))
.build());
var exampleSubnetGroup = new SubnetGroup("exampleSubnetGroup", SubnetGroupArgs.builder()
.subnetIds(ramResourcePropagation.triggers().applyValue(triggers -> triggers.subnet_id()))
.build());
}
}
resources:
exampleResourceAssociation:
type: aws:ram:ResourceAssociation
properties:
resourceArn: ${aws_subnet.example.arn}
resourceShareArn: ${aws_ram_resource_share.example.arn}
# AWS resources shared via Resource Access Manager can take a few seconds to
# propagate across AWS accounts after RAM returns a successful association.
ramResourcePropagation:
type: time:Sleep
properties:
createDuration: 60s
triggers:
subnet_arn: ${exampleResourceAssociation.resourceArn}
subnet_id: ${aws_subnet.example.id}
exampleSubnetGroup:
type: aws:rds:SubnetGroup
properties:
# Read the Subnet identifier "through" the time_sleep resource to ensure a
# # proper dependency and that both will change together.
subnetIds:
- ${ramResourcePropagation.triggers.subnet_id}
Create Sleep Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Sleep(name: string, args?: SleepArgs, opts?: CustomResourceOptions);
@overload
def Sleep(resource_name: str,
args: Optional[SleepArgs] = None,
opts: Optional[ResourceOptions] = None)
@overload
def Sleep(resource_name: str,
opts: Optional[ResourceOptions] = None,
create_duration: Optional[str] = None,
destroy_duration: Optional[str] = None,
triggers: Optional[Mapping[str, str]] = None)
func NewSleep(ctx *Context, name string, args *SleepArgs, opts ...ResourceOption) (*Sleep, error)
public Sleep(string name, SleepArgs? args = null, CustomResourceOptions? opts = null)
type: time:Sleep
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args SleepArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args SleepArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args SleepArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SleepArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args SleepArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var sleepResource = new Time.Sleep("sleepResource", new()
{
CreateDuration = "string",
DestroyDuration = "string",
Triggers =
{
{ "string", "string" },
},
});
example, err := time.NewSleep(ctx, "sleepResource", &time.SleepArgs{
CreateDuration: pulumi.String("string"),
DestroyDuration: pulumi.String("string"),
Triggers: pulumi.StringMap{
"string": pulumi.String("string"),
},
})
var sleepResource = new Sleep("sleepResource", SleepArgs.builder()
.createDuration("string")
.destroyDuration("string")
.triggers(Map.of("string", "string"))
.build());
sleep_resource = time.Sleep("sleepResource",
create_duration="string",
destroy_duration="string",
triggers={
"string": "string",
})
const sleepResource = new time.Sleep("sleepResource", {
createDuration: "string",
destroyDuration: "string",
triggers: {
string: "string",
},
});
type: time:Sleep
properties:
createDuration: string
destroyDuration: string
triggers:
string: string
Sleep Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The Sleep resource accepts the following input properties:
- Create
Duration string - Time duration to delay resource creation. For example,
30s
for 30 seconds or5m
for 5 minutes. Updating this value by itself will not trigger a delay. - Destroy
Duration string - Triggers Dictionary<string, string>
- (Optional) Arbitrary map of values that, when changed, will run any creation or destroy delays again. See the main provider documentation for more information.
- Create
Duration string - Time duration to delay resource creation. For example,
30s
for 30 seconds or5m
for 5 minutes. Updating this value by itself will not trigger a delay. - Destroy
Duration string - Triggers map[string]string
- (Optional) Arbitrary map of values that, when changed, will run any creation or destroy delays again. See the main provider documentation for more information.
- create
Duration String - Time duration to delay resource creation. For example,
30s
for 30 seconds or5m
for 5 minutes. Updating this value by itself will not trigger a delay. - destroy
Duration String - triggers Map<String,String>
- (Optional) Arbitrary map of values that, when changed, will run any creation or destroy delays again. See the main provider documentation for more information.
- create
Duration string - Time duration to delay resource creation. For example,
30s
for 30 seconds or5m
for 5 minutes. Updating this value by itself will not trigger a delay. - destroy
Duration string - triggers {[key: string]: string}
- (Optional) Arbitrary map of values that, when changed, will run any creation or destroy delays again. See the main provider documentation for more information.
- create_
duration str - Time duration to delay resource creation. For example,
30s
for 30 seconds or5m
for 5 minutes. Updating this value by itself will not trigger a delay. - destroy_
duration str - triggers Mapping[str, str]
- (Optional) Arbitrary map of values that, when changed, will run any creation or destroy delays again. See the main provider documentation for more information.
- create
Duration String - Time duration to delay resource creation. For example,
30s
for 30 seconds or5m
for 5 minutes. Updating this value by itself will not trigger a delay. - destroy
Duration String - triggers Map<String>
- (Optional) Arbitrary map of values that, when changed, will run any creation or destroy delays again. See the main provider documentation for more information.
Outputs
All input properties are implicitly available as output properties. Additionally, the Sleep resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing Sleep Resource
Get an existing Sleep resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: SleepState, opts?: CustomResourceOptions): Sleep
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
create_duration: Optional[str] = None,
destroy_duration: Optional[str] = None,
triggers: Optional[Mapping[str, str]] = None) -> Sleep
func GetSleep(ctx *Context, name string, id IDInput, state *SleepState, opts ...ResourceOption) (*Sleep, error)
public static Sleep Get(string name, Input<string> id, SleepState? state, CustomResourceOptions? opts = null)
public static Sleep get(String name, Output<String> id, SleepState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Create
Duration string - Time duration to delay resource creation. For example,
30s
for 30 seconds or5m
for 5 minutes. Updating this value by itself will not trigger a delay. - Destroy
Duration string - Triggers Dictionary<string, string>
- (Optional) Arbitrary map of values that, when changed, will run any creation or destroy delays again. See the main provider documentation for more information.
- Create
Duration string - Time duration to delay resource creation. For example,
30s
for 30 seconds or5m
for 5 minutes. Updating this value by itself will not trigger a delay. - Destroy
Duration string - Triggers map[string]string
- (Optional) Arbitrary map of values that, when changed, will run any creation or destroy delays again. See the main provider documentation for more information.
- create
Duration String - Time duration to delay resource creation. For example,
30s
for 30 seconds or5m
for 5 minutes. Updating this value by itself will not trigger a delay. - destroy
Duration String - triggers Map<String,String>
- (Optional) Arbitrary map of values that, when changed, will run any creation or destroy delays again. See the main provider documentation for more information.
- create
Duration string - Time duration to delay resource creation. For example,
30s
for 30 seconds or5m
for 5 minutes. Updating this value by itself will not trigger a delay. - destroy
Duration string - triggers {[key: string]: string}
- (Optional) Arbitrary map of values that, when changed, will run any creation or destroy delays again. See the main provider documentation for more information.
- create_
duration str - Time duration to delay resource creation. For example,
30s
for 30 seconds or5m
for 5 minutes. Updating this value by itself will not trigger a delay. - destroy_
duration str - triggers Mapping[str, str]
- (Optional) Arbitrary map of values that, when changed, will run any creation or destroy delays again. See the main provider documentation for more information.
- create
Duration String - Time duration to delay resource creation. For example,
30s
for 30 seconds or5m
for 5 minutes. Updating this value by itself will not trigger a delay. - destroy
Duration String - triggers Map<String>
- (Optional) Arbitrary map of values that, when changed, will run any creation or destroy delays again. See the main provider documentation for more information.
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:
$ pulumi import time:index/sleep:Sleep example 30s,
e.g. For 30 seconds destroy duration with no create duration:
$ pulumi import time:index/sleep:Sleep example ,30s
The triggers
argument cannot be imported.
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- time pulumiverse/pulumi-time
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
time
Terraform Provider.