straight-cat-87033
05/23/2023, 12:14 AMimport
resource option:
The docs state that:
The resulting Pulumi program, after the import is complete, will faithfully generate the same desired state as your existing infrastructure’s actual state.
Because of this, all properties need to be fully specified. If you forget to specify a property, or that property’s value is incorrect, you’ll first receive a warning during preview, and then an error during the actual import update.But that isn’t matching the behavior that I’m seeing with regards to unspecified properties.
gcp.container.Cluster
resource by specifying the import_
option, and I can leave off the majority of the options and still have the preview portion of pulumi up
succeed with no warning.
I can see in the details
of the preview that the unspecified fields are properly being pulled in from the imported resource (e.g, the nodepools on the cluster).
Three specific questions:
1. If I go through with pulumi up
, can I guarantee that it will not modify any of the existing resources as long as import_
is in place?
2. If I then remove the import_
option with those unspecified options unchanged, would it then modify the resources and (e.g.) delete the nodepools that are present on the cluster?
3. After the initial pulumi up
has been run to import the resource, do I have to remove the import_
command?
a. We are swapping from manually-managed to pulumi-managed infrastructure gradually, so allowing the two to coexist might be nice, especially if the answer to 2. is ‘yes’little-cartoon-10569
05/23/2023, 1:45 AMambitious-father-68746
05/23/2023, 6:33 AMpulumi import
CLI command, which might be easier than trying to do it via code. It's what I usually do. Pulumi imports just change the state file, not the resources themselves.salmon-gold-74709
05/23/2023, 3:36 PMpulumi import
command to generate Pulumi code as mentioned in docs? It seems like a good option - how well does it work?ambitious-father-68746
05/23/2023, 3:39 PMstraight-cat-87033
05/23/2023, 5:54 PMGenerally, the correct thing to do is to update your code to match the actual configuration (which is why there are warnings and errors, as documented), import, then remove the import option.I did not get any warnings on the preview, which is at the heart of my question. I’m hesitant to go through with the
up
operation, because I am not confident it will run without modifying the state on the server — especially because removing (most) fields does not affect whether an warning is raised.Does anyone use theI did attempt to use that — for gcp/python I got some warnings about the fields that were set in the imported definitions being incompatible with one another. Right now I am leaning towards just recreating new infrastructure with pulumi and not attempting to migrate my existing infrastructure over at all. It seems like it’s less risky if I do not want to accidentally modify the properties of the legacy infrastructurecommand to generate Pulumi code as mentioned in docs?pulumi import