pulumi/pkg/resource/deploy
Pat Gavlin 013d0791ff [engine] Simplify `pulumi import` behavior.
The current behavior of `pulumi import` for a particular resource is a
bit strange. It was designed to generate the smallest usable set of
input properties for a resource using the following algorithm:

1. Read the current inputs and state (I_c, S_c) from the provider
2. Copy required inputs from I_c to a new input set I_n
3. Run I_n through the provider's Check method with the old inputs set to
   I_c, erroring on validation failures
4. Diff I_n against S_c
5. Copy the values of any differing properties from I_c into I_n

The most problematic pieces of this algorithm are (2) and (3). In these
steps, the engine first disregards any optional inputs under the
assumption that their values are not required in order for `Check` to
succeed, and that if omitting these values would cause diffs that they
will be copied over during (5). Unfortunately, the former assumption is
false and the latter can generate code that is misleading. In the former
case, some providers model mutually-exclusive properties as optional
properties where exactly one must be set. This then causes Check to fail
in (3), halting the import process. The errors this process produces are
opaque to the user, and worse, there is no corrective action the user
can take in order to unblock themselves.

We can simplify the implementation of `pulumi import` and allow users to
unblock themselves by eliminating the check/diff/copy, taking the inputs
from the provider wholesale, and either eliminating the call to Check
altogether or lowering Check failures to warnings instead of errors.
With this approach, the user always ends up with a successfully imported
resource, though the codegen'd definition may need modifications before
the program successfully runs. Improvements in providers' calculation of
accurate input sets can then be delivered incrementally with somewhat
less urgency, as users are no longer blocked.

A somewhat more radical alternative might be to skip storing the
imported resources in the stack's state altogether and instead generate
definitions that set the `import` resource option. This approach lowers
the `pulumi import` command to a simple codegen step. Though this
requires more work on the part of the user, it may fit more cleanly into
our overall design, as it builds on top of existing features. This
design also has the advantage of ensuring that a resource never ends up
in a stack's state until its definition is accurate.
2022-02-02 23:10:39 -08:00
..
deploytest Program codegen correctly handles foreign imports (#8861) 2022-01-31 21:48:32 +01:00
providers Allow disabling default providers (#8829) 2022-01-26 18:08:36 +01:00
builtins.go Make resource autonames determinstic (#8631) 2022-01-20 11:18:54 +00:00
deployment.go Preview of update plans (#8448) 2022-01-31 10:31:51 +00:00
deployment_executor.go Preview of update plans (#8448) 2022-01-31 10:31:51 +00:00
deployment_test.go Preview of update plans (#8448) 2022-01-31 10:31:51 +00:00
doc.go Document Go packages (#6009) 2021-01-11 11:07:59 -07:00
import.go Revert "Add option to set property names to import with (#8846)" 2022-02-02 23:10:39 -08:00
manifest.go Split Manifest type to it's own file (#8712) 2022-01-10 12:25:24 +00:00
plan.go Preview of update plans (#8448) 2022-01-31 10:31:51 +00:00
snapshot.go Add wildcard for --target and family (#8883) 2022-02-01 21:11:38 +01:00
snapshot_test.go Add wildcard for --target and family (#8883) 2022-02-01 21:11:38 +01:00
source.go Initial support for resource methods (authoring from Node.js, calling from Python) (#7363) 2021-06-30 07:48:56 -07:00
source_error.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
source_eval.go Allow disabling default providers (#8829) 2022-01-26 18:08:36 +01:00
source_eval_test.go Make resource autonames determinstic (#8631) 2022-01-20 11:18:54 +00:00
source_fixed.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
source_null.go Clone snapshot before testing with it (#8551) 2021-12-09 09:09:48 +00:00
source_query.go Make resource autonames determinstic (#8631) 2022-01-20 11:18:54 +00:00
source_query_test.go Initial support for resource methods (authoring from Node.js, calling from Python) (#7363) 2021-06-30 07:48:56 -07:00
step.go [engine] Simplify `pulumi import` behavior. 2022-02-02 23:10:39 -08:00
step_executor.go Preview of update plans (#8448) 2022-01-31 10:31:51 +00:00
step_generator.go [engine] Simplify `pulumi import` behavior. 2022-02-02 23:10:39 -08:00
step_generator_test.go Specify fields on engine diff (#8488) 2021-11-30 12:25:27 -08:00
target.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00