pulumi/pkg/resource/deploy
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
..
deploytest Implement the `CreateIfNotExists` resource option 2024-07-02 17:27:42 +01:00
providers Initial work for parameterized providers (#16281) 2024-06-10 17:28:47 +00:00
builtins.go Normalize plugin.Provider methods to (Context, Request) -> (Response, error) (#16302) 2024-06-07 19:47:49 +00:00
builtins_test.go Normalize plugin.Provider methods to (Context, Request) -> (Response, error) (#16302) 2024-06-07 19:47:49 +00:00
deployment.go Change `pulumi refresh` to report diff relative to desired state instead of relative to only output changes (#16146) 2024-06-12 16:17:05 +00:00
deployment_executor.go Clean up deployment options (#16357) 2024-06-11 13:37:57 +00:00
deployment_executor_test.go Better handle property dependencies and `deletedWith` (#16088) 2024-05-03 17:08:06 +00:00
deployment_test.go Clean up deployment options (#16357) 2024-06-11 13:37:57 +00:00
doc.go Document Go packages (#6009) 2021-01-11 11:07:59 -07:00
import.go Implement the `CreateIfNotExists` resource option 2024-07-02 17:27:42 +01:00
import_test.go Clean up deployment options (#16357) 2024-06-11 13:37:57 +00:00
manifest.go Split Manifest type to it's own file (#8712) 2022-01-10 12:25:24 +00:00
manifest_test.go Refactor: move plugin kind to apitype (#15946) 2024-04-25 17:30:30 +00:00
plan.go Enable perfsprint linter (#14813) 2023-12-12 12:19:42 +00:00
plan_test.go [ci] `pkg/resource/deploy` coverage (#14831) 2023-12-19 16:14:40 +00:00
snapshot.go Revert "Revert "Run integration tests and dev builds with race detection" (#15998)" (#16148) 2024-05-09 16:15:41 +00:00
snapshot_test.go Revert "Revert "Run integration tests and dev builds with race detection" (#15998)" (#16148) 2024-05-09 16:15:41 +00:00
source.go Clean up deployment options (#16357) 2024-06-11 13:37:57 +00:00
source_error.go Clean up deployment options (#16357) 2024-06-11 13:37:57 +00:00
source_error_test.go Clean up deployment options (#16357) 2024-06-11 13:37:57 +00:00
source_eval.go Implement the `CreateIfNotExists` resource option 2024-07-02 17:27:42 +01:00
source_eval_test.go Implement the `CreateIfNotExists` resource option 2024-07-02 17:27:42 +01:00
source_null.go Clean up deployment options (#16357) 2024-06-11 13:37:57 +00:00
source_query.go Initial work for parameterized providers (#16281) 2024-06-10 17:28:47 +00:00
source_query_test.go Query language runtime for options during “pulumi new” (#16346) 2024-06-17 17:10:55 +00:00
state_builder.go Revert "Revert "Run integration tests and dev builds with race detection" (#15998)" (#16148) 2024-05-09 16:15:41 +00:00
state_builder_test.go When changing parents also fix URNs (#13935) 2023-09-14 19:52:27 +00:00
step.go Implement the `CreateIfNotExists` resource option 2024-07-02 17:27:42 +01:00
step_executor.go Remove `Step.Apply`'s `preview` parameter (#16367) 2024-06-14 10:19:13 +00:00
step_executor_test.go Clean up deployment options (#16357) 2024-06-11 13:37:57 +00:00
step_generator.go Implement the `CreateIfNotExists` resource option 2024-07-02 17:27:42 +01:00
step_generator_test.go Clean up deployment options (#16357) 2024-06-11 13:37:57 +00:00
step_test.go Remove `Step.Apply`'s `preview` parameter (#16367) 2024-06-14 10:19:13 +00:00
target.go Add tokens.StackName (#14487) 2023-11-15 07:44:54 +00:00
target_test.go upgrade to latest version of golangci-lint (#15977) 2024-04-19 06:20:33 +00:00