Module dynamic

@pulumi/pulumi > dynamic

class Resource

extends CustomResource

Resource represents a Pulumi Resource that incorporates an inline implementation of the Resource’s CRUD operations.


new Resource(provider: ResourceProvider, name: string, props: Inputs, opts?: resource.CustomResourceOptions)

Creates a new dynamic resource.

  • provider The implementation of the resource's CRUD operations.
  • name The name of the resource.
  • props The arguments to use to populate the new resource. Must not define the reserved property "__provider".
  • opts A bag of options that control this resource's behavior.

method getProvider

public getProvider(moduleMember: string): ProviderResource | undefined

method isInstance

public static isInstance(obj: any): boolean

Returns true if the given object is an instance of CustomResource. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

property __childResources

public __childResources: Set<Resource> | undefined;

The child resources of this resource. We use these (only from a ComponentResource) to allow code to dependOn a ComponentResource and have that effectively mean that it is depending on all the CustomResource children of that component.

Important! We only walk through ComponentResources. They’re the only resources that serve as an aggregation of other primitive (i.e. custom) resources. While a custom resource can be a parent of other resources, we don’t want to ever depend on those child resource. If we do, it’s simple to end up in a situation where we end up depending on a child resource that has a data cycle dependency due to the data passed into it.

An example of how this would be bad is:

    var c1 = new CustomResource("c1");
    var c2 = new CustomResource("c2", { parentId: }, { parent: c1 });
    var c3 = new CustomResource("c3", { parentId: }, { parent: c1 });

The problem here is that ‘c2’ has a data dependency on ‘c1’. If it tries to wait on ‘c1’ it will walk to the children and wait on them. This will mean it will wait on ‘c3’. But ‘c3’ will be waiting in the same manner on ‘c2’, and a cycle forms.

This normally does not happen with ComponentResources as they do not have any data flowing into them. The only way you would be able to have a problem is if you had this sort of coding pattern:

    var c1 = new ComponentResource("c1");
    var c2 = new CustomResource("c2", { parentId: c1.urn }, { parent: c1 });
    var c3 = new CustomResource("c3", { parentId: c1.urn }, { parent: c1 });

However, this would be pretty nonsensical as there is zero need for a custom resource to ever need to reference the urn of a component resource. So it’s acceptable if that sort of pattern failed in practice.

property __parentResource

public __parentResource: Resource | undefined;

The optional parent of this resource.

property __pulumiCustomResource

public __pulumiCustomResource: boolean = true;

A private field to help with RTTI that works in SxS scenarios.

property __pulumiResource

public __pulumiResource: boolean = true;

A private field to help with RTTI that works in SxS scenarios.

property id

public id: Output<ID>;

id is the provider-assigned unique ID for this managed resource. It is set during deployments and may be missing (undefined) during planning phases.

property urn

public urn: Output<URN>;

urn is the stable logical URN used to distinctly address a resource, both before and after deployments.

interface CheckFailure

CheckFailure represents a single failure in the results of a call to ResourceProvider.check

property property

property: string;

The property that failed validation.

property reason

reason: string;

The reason that the property failed validation.

interface CheckResult

CheckResult represents the results of a call to ResourceProvider.check.

property failures

failures?: CheckFailure[];

Any validation failures that occurred.

property inputs

inputs?: any;

The inputs to use, if any.

interface CreateResult

CreateResult represents the results of a call to ResourceProvider.create.

property id

id: resource.ID;

The ID of the created resource.

property outs

outs?: any;

Any properties that were computed during creation.

interface DiffResult

DiffResult represents the results of a call to ResourceProvider.diff.

property changes

changes?: undefined | false | true;

If true, this diff detected changes and suggests an update.

property deleteBeforeReplace

deleteBeforeReplace?: undefined | false | true;

If true, and a replacement occurs, the resource will first be deleted before being recreated. This is to void potential side-by-side issues with the default create before delete behavior.

property replaces

replaces?: string[];

If this update requires a replacement, the set of properties triggering it.

property stables

stables?: string[];

An optional list of properties that will not ever change.

interface ReadResult

property id

id?: resource.ID;

The ID of the resource ready back (or blank if missing).

property props

props?: any;

The current property state read from the live environment.

interface ResourceProvider

ResourceProvider represents an object that provides CRUD operations for a particular type of resource.

property check

check?: undefined | (olds: any, news: any) => Promise<CheckResult>;

Check validates that the given property bag is valid for a resource of the given type.

property create

create: (inputs: any) => Promise<CreateResult>;

Create allocates a new instance of the provided resource and returns its unique ID afterwards. If this call fails, the resource must not have been created (i.e., it is “transacational”).

property delete

delete?: undefined | (id: resource.ID, props: any) => Promise<void>;

Delete tears down an existing resource with the given ID. If it fails, the resource is assumed to still exist.

property diff

diff?: undefined | (id: resource.ID, olds: any, news: any) => Promise<DiffResult>;

Diff checks what impacts a hypothetical update will have on the resource’s properties.

property read

read?: undefined | (id: resource.ID, props?: any) => Promise<ReadResult>;

Reads the current live state associated with a resource. Enough state must be included in the inputs to uniquely identify the resource; this is typically just the resource ID, but it may also include some properties.

property update

update?: undefined | (id: resource.ID, olds: any, news: any) => Promise<UpdateResult>;

Update updates an existing resource with new values.

interface UpdateResult

UpdateResult represents the results of a call to ResourceProvider.update.

property outs

outs?: any;

Any properties that were computed during updating.