Skip to main content
  1. Docs
  2. Infrastructure as Code
  3. Concepts
  4. Resources
  5. Resource options

Resource options

    All Pulumi IaC resources support a common set of options that allow you to customize how your resources are managed. Resource options allow you to do things like protect resources from being deleted, express more fine-grained control to the order in which resources are changed, or apply custom code that will allow you to change the properties of your resources.

    Resource constructors accept the following resource options. Each option’s reference page describes its behavior in depth and how the Pulumi SDKs enforce which resource types it applies to.

    Resource optionDescriptionApplies to
    additionalSecretOutputsSpecify output properties that must be encrypted as secrets.Custom only
    aliasesSpecify aliases so that renaming or refactoring doesn’t replace a resource.Custom and component
    customTimeoutsOverride the default retry/timeout behavior for resource provisioning.Custom only
    deleteBeforeReplaceDelete the existing resource before creating its replacement.Custom only
    deletedWithSkip this resource’s delete when the named resource is also being deleted.Custom only
    dependsOnSpecify explicit dependencies in addition to those in the dependency graph.Custom and component
    envVarMappingsRemap environment variables to custom keys for provider authentication.Provider only
    hideDiffsCompact the display of diffs for specified properties in CLI output.Custom only
    hooksRun custom logic at specific points in the resource lifecycle.Custom and component
    ignoreChangesIgnore changes to specified properties during a diff.Custom only
    importBring an existing cloud resource under Pulumi management.Custom only
    parentEstablish a parent/child relationship between resources.Custom and component
    protectPrevent accidental deletion by marking the resource as protected.Custom and component
    providerPass an explicitly configured provider instead of the default.Custom and component
    providersPass explicitly configured providers for a component’s child resources.Component only
    replaceOnChangesTreat changes to specified properties as forcing a replacement.Custom only
    replaceWithReplace this resource whenever one of the named resources is replaced.Custom only
    replacementTriggerForce a replacement whenever a specified trigger value changes.Custom only
    retainOnDeleteRetain the resource in the cloud provider when Pulumi deletes it.Custom only
    transformationsDynamically transform a resource’s properties (prefer transforms).Custom and component
    transformsDynamically transform a resource’s properties on the fly.Custom and component
    versionPin the provider plugin version used when operating on a resource.Custom only

    Resource options and component resources

    Not all resource options apply to component resources. Component resources are logical groupings that don’t have a backing cloud provider, so options that affect provider behavior have no effect on the component itself (though, as described below, several of them are inherited by the component’s children). The Applies to column in the table above shows which options have a direct effect on the component itself; each option’s reference page explains the behavior in detail.

    When you apply a resource option to a component that doesn’t support it, the option has no direct effect on the component. To apply options like ignoreChanges to the child resources within a component, use the transforms option to modify child resources as they’re created.

    Options inherited from a component to its children

    When a resource option is set on a component, several options propagate from the component to each of its child resources automatically. The child resource doesn’t need to set the option itself; the engine carries the value down the parent/child chain at resource registration time. Each option’s reference page describes how the option behaves on a component in detail.

    Resource optionInherited by children of a component
    additionalSecretOutputsN/A
    aliasesYes
    customTimeoutsNo
    deleteBeforeReplaceN/A
    deletedWithYes
    dependsOnNo
    envVarMappingsN/A
    hideDiffsNo
    hooksNo
    ignoreChangesNo
    importN/A
    parentN/A
    protectYes
    providerYes
    providersYes
    replaceOnChangesNo
    replaceWithNo
    replacementTriggerNo
    retainOnDeleteYes
    transformationsYes
    transformsYes
    versionNo

    Options marked N/A can’t be set on a component to begin with: additionalSecretOutputs, deleteBeforeReplace, and import are custom-resource-only (and a compile-time error on components in TypeScript, C#, and Java); envVarMappings only applies to explicitly configured provider resources; and parent defines the parent/child relationship itself rather than being a value that’s inherited.

    For options that aren’t inherited, set them on each child resource that needs the behavior, or use transforms on the component to inject the option into matching child registrations as they’re created.