pulumi/sdk
Will Jones 4e90fcb781 Implement the `CreateIfNotExists` resource option
This commit implements `CreateIfNotExists`, a new resource option that
allows programs to specify resource options that should be created only
if they do not already exist in the provider. Use cases for this feature
include "global" or shared resources, such as AWS service-linked
providers within an account, or SSL policies within a GCP
account/project. `CreateIfNotExists` behaves as follows:

* The option accepts an ID, much like `Import`, that will be used to
  determine whether or not a resource exists using a `Read` operation.
  If it does, resource inputs must match as they would be required to in
  an ordinary import. If not, the resource is created as usual.

* Due to the semantics specified above, it is an error to specify both
  `CreateIfNotExists` and `Import` resource options on a single
  resource.

The "if not exists" part is handled by a provider `Read` call that we
make in step generation. This is not ideal, since we'd like step
generation to be non-blocking (and `Read` could block for an arbitrary
amount of time). However, there aren't many other good options for
achieving this:

* Source evaluation would be a good middle ground, but this would
  require changing the contract of `Read`/introducing another call since
  we do not have a URN at this point.
* Parallelising step generation (see e.g. #15026). This is the "best"
  outcome and feels the most correct, but carries a large amount of risk.

There _are_ instances of us breaking this rule (not blocking in step
generation) already (e.g. `Check` and `Diff`, which "should" be fast but
in reality could do anything they like), and the hypothesis is that
there won't be many resources with this option in a given stack, so this
feels like an acceptable compromise.

A set of lifecycle tests capturing `CreateIfNotExists`' interactions
with existing resource options and scenarios are included. This commit
does not include SDK updates to use the new option; these will be
introduced in future changesets.

Part of #16189
2024-07-02 17:27:42 +01:00
..
go Implement the `CreateIfNotExists` resource option 2024-07-02 17:27:42 +01:00
nodejs Implement the `CreateIfNotExists` resource option 2024-07-02 17:27:42 +01:00
proto/go Implement the `CreateIfNotExists` resource option 2024-07-02 17:27:42 +01:00
python Implement the `CreateIfNotExists` resource option 2024-07-02 17:27:42 +01:00
.version Freeze v3.122.0 (#16547) 2024-07-02 00:20:23 +00:00
README.md Cleanup sdk/README.md 2023-01-03 17:12:12 -05:00
go.mod Query language runtime for options during “pulumi new” (#16346) 2024-06-17 17:10:55 +00:00
go.sum Query language runtime for options during “pulumi new” (#16346) 2024-06-17 17:10:55 +00:00
version.go Move .version to /sdk and embed it (#15185) 2024-01-19 14:11:17 +00:00

README.md

Pulumi Language SDKs

This directory contains Pulumi SDKs for the following languages:

See the respective READMEs for information about installing and using these libraries.

The language providers work by implementing gRPC interfaces defined in the top level directory proto.