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 option | Description | Applies to |
|---|---|---|
| additionalSecretOutputs | Specify output properties that must be encrypted as secrets. | Custom only |
| aliases | Specify aliases so that renaming or refactoring doesn’t replace a resource. | Custom and component |
| customTimeouts | Override the default retry/timeout behavior for resource provisioning. | Custom only |
| deleteBeforeReplace | Delete the existing resource before creating its replacement. | Custom only |
| deletedWith | Skip this resource’s delete when the named resource is also being deleted. | Custom only |
| dependsOn | Specify explicit dependencies in addition to those in the dependency graph. | Custom and component |
| envVarMappings | Remap environment variables to custom keys for provider authentication. | Provider only |
| hideDiffs | Compact the display of diffs for specified properties in CLI output. | Custom only |
| hooks | Run custom logic at specific points in the resource lifecycle. | Custom and component |
| ignoreChanges | Ignore changes to specified properties during a diff. | Custom only |
| import | Bring an existing cloud resource under Pulumi management. | Custom only |
| parent | Establish a parent/child relationship between resources. | Custom and component |
| protect | Prevent accidental deletion by marking the resource as protected. | Custom and component |
| provider | Pass an explicitly configured provider instead of the default. | Custom and component |
| providers | Pass explicitly configured providers for a component’s child resources. | Component only |
| replaceOnChanges | Treat changes to specified properties as forcing a replacement. | Custom only |
| replaceWith | Replace this resource whenever one of the named resources is replaced. | Custom only |
| replacementTrigger | Force a replacement whenever a specified trigger value changes. | Custom only |
| retainOnDelete | Retain the resource in the cloud provider when Pulumi deletes it. | Custom only |
| transformations | Dynamically transform a resource’s properties (prefer transforms). | Custom and component |
| transforms | Dynamically transform a resource’s properties on the fly. | Custom and component |
| version | Pin 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.
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 option | Inherited by children of a component |
|---|---|
| additionalSecretOutputs | N/A |
| aliases | Yes |
| customTimeouts | No |
| deleteBeforeReplace | N/A |
| deletedWith | Yes |
| dependsOn | No |
| envVarMappings | N/A |
| hideDiffs | No |
| hooks | No |
| ignoreChanges | No |
| import | N/A |
| parent | N/A |
| protect | Yes |
| provider | Yes |
| providers | Yes |
| replaceOnChanges | No |
| replaceWith | No |
| replacementTrigger | No |
| retainOnDelete | Yes |
| transformations | Yes |
| transforms | Yes |
| version | No |
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.
Thank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.