pulumi/sdk/go/common/resource/plugin
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
..
analyzer.go Allow anything in resource names (#14107) 2023-11-20 08:59:00 +00:00
analyzer_plugin.go Refactor: move plugin kind to apitype (#15946) 2024-04-25 17:30:30 +00:00
check.go Enable importas linter (#15167) 2024-01-17 14:56:37 +00:00
config_source.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
context.go Actually save root on plugin.Context (#14684) 2023-11-29 14:30:52 +00:00
context_test.go Fix data race in plugin.Context 2023-03-31 07:15:11 -07:00
converter.go Plumb Remote, Component, and LogicalName into the import plugin system (#15199) 2024-01-24 17:15:30 +00:00
converter_plugin.go Refactor: move plugin kind to apitype (#15946) 2024-04-25 17:30:30 +00:00
converter_plugin_test.go Plumb Remote, Component, and LogicalName into the import plugin system (#15199) 2024-01-24 17:15:30 +00:00
converter_server.go Plumb Remote, Component, and LogicalName into the import plugin system (#15199) 2024-01-24 17:15:30 +00:00
converter_server_test.go Plumb Remote, Component, and LogicalName into the import plugin system (#15199) 2024-01-24 17:15:30 +00:00
diagnostic.go Make language-python it's own module (#13819) 2023-08-31 16:35:21 +00:00
diagnostic_test.go Allow converter plugins to return diagnostics 2023-06-05 17:38:59 +01:00
doc.go Provider implementer's guide draft (#6322) 2021-04-13 14:11:02 -07:00
host.go Normalize plugin.Provider methods to (Context, Request) -> (Response, error) (#16302) 2024-06-07 19:47:49 +00:00
host_server.go Enable importas linter (#15167) 2024-01-17 14:56:37 +00:00
host_test.go Lock access to the plugin loading channels 2023-08-10 23:40:23 +01:00
langruntime.go Add not-found markers to missing executables for packagemanagers (#16488) 2024-06-28 23:21:55 +00:00
langruntime_plugin.go Query language runtime for options during “pulumi new” (#16346) 2024-06-17 17:10:55 +00:00
langruntime_test.go Add not-found markers to missing executables for packagemanagers (#16488) 2024-06-28 23:21:55 +00:00
plugin.go Refactor: move plugin kind to apitype (#15946) 2024-04-25 17:30:30 +00:00
plugin_test.go Revert "resource/plugin: Shut down plugins gracefully (#13795)" (#13844) 2023-08-31 16:29:55 +00:00
provider.go Implement the `CreateIfNotExists` resource option 2024-07-02 17:27:42 +01:00
provider_plugin.go Implement the `CreateIfNotExists` resource option 2024-07-02 17:27:42 +01:00
provider_plugin_test.go Normalize plugin.Provider methods to (Context, Request) -> (Response, error) (#16302) 2024-06-07 19:47:49 +00:00
provider_server.go Normalize plugin.Provider methods to (Context, Request) -> (Response, error) (#16302) 2024-06-07 19:47:49 +00:00
provider_server_test.go Normalize plugin.Provider methods to (Context, Request) -> (Response, error) (#16302) 2024-06-07 19:47:49 +00:00
provider_test.go Fix PropertyPaths generated by NewDetailedDiffFromObjectDiff (#14337) 2023-10-25 10:39:03 +00:00
provider_unimplemented.go Normalize plugin.Provider methods to (Context, Request) -> (Response, error) (#16302) 2024-06-07 19:47:49 +00:00
rpc.go Add asset/archive to conformance tests and fix engine working dir issues (#16100) 2024-05-02 11:32:54 +00:00
rpc_rapid_test.go Remove deprecated Protobufs imports (#15158) 2024-01-17 09:35:20 +00:00
rpc_test.go Fix upgrade with ResourceReference (#15377) 2024-02-06 08:22:46 +00:00
server.go Add mapping service to converter 2023-03-24 17:09:17 +00:00