pulumi/sdk/go/common
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
..
apitype Implement the `CreateIfNotExists` resource option 2024-07-02 17:27:42 +01:00
channel Send all events to the engine event stream (#14607) 2023-11-20 21:55:59 +00:00
constant Send update metadata about update plans 2022-10-12 22:55:59 +01:00
diag turn on the golangci-lint exhaustive linter (#15028) 2024-01-17 16:50:41 +00:00
encoding all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
env Set the --continue-on-error flag with PULUMI_CONTINUE_ON_ERROR environment variable (#16442) 2024-06-25 08:28:37 +00:00
promise Use promise rather than `atomic.Value` to record step errors. (#14612) 2023-11-18 19:03:35 +00:00
resource Implement the `CreateIfNotExists` resource option 2024-07-02 17:27:42 +01:00
slice Engine support for remote transforms (#15290) 2024-02-21 16:30:46 +00:00
testing Use a new PULUMI_HOME for every test environment (#15559) 2024-03-01 21:32:49 +00:00
tokens Move resource.URN to urn.URN (#15689) 2024-03-14 15:28:32 +00:00
tools all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
util Fix TestTerminate_gracefulShutdown/python flake (#16471) 2024-06-26 05:50:58 +00:00
version move pkg/version -> sdk/go/common/version 2020-03-18 15:25:25 -07:00
workspace Add packagemanager prompt to pulumi new for nodejs (#16417) 2024-06-21 11:35:06 +00:00