pulumi / pulumi-converter-terraform

Apache License 2.0
9 stars 3 forks source link

Automatically do a refresh after import #69

Open GeoffMillerAZ opened 11 months ago

GeoffMillerAZ commented 11 months ago

Hello!

Issue details

Perform a pulumi refresh automatically after doing a successful state import from terraform.

After doing an import, I noticed that some resources showed diffs. So I decided to do a refresh. This was roughly the output:

pulumi import --from terraform terraform.tfstate

output from import omitted

pulumi refresh

Refreshing (gplay)

View in Browser (Ctrl+O): https://app.pulumi.com/GeoffMillerAZ/aptos-node/gplay/updates/43

     Type                           Name                                          Status            Info
     pulumi:pulumi:Stack            aptos-node-gplay                                                
 ~   ├─ gcp:projects:Service        services-cloudresourcemanager.googleapis.com  updated (12s)     [diff: +disableOnDestroy]
 ~   ├─ gcp:projects:Service        services-monitoring.googleapis.com            updated (12s)     [diff: +disableOnDestroy]
 ~   ├─ gcp:projects:Service        services-compute.googleapis.com               updated (12s)     [diff: +disableOnDestroy]
     ├─ gcp:projects:Service        services-clouderrorreporting.googleapis.com   updated (12s)     [diff: +disableOnDestroy]
     ├─ gcp:projects:Service        services-container.googleapis.com             updated (12s)     [diff: +disableOnDestroy]
 ~   ├─ gcp:projects:Service        services-iam.googleapis.com                   updated (12s)     [diff: +disableOnDestroy]
     ├─ gcp:projects:Service        services-logging.googleapis.com               updated (12s)     [diff: +disableOnDestroy]
     ├─ gcp:projects:Service        services-spanner.googleapis.com               updated (12s)     [diff: +disableOnDestroy]
 ~   ├─ gcp:projects:Service        services-secretmanager.googleapis.com         updated (12s)     [diff: +disableOnDestroy]
 ~   └─ gcp:projects:Service        services-cloudkms.googleapis.com              updated (12s)     [diff: +disableOnDestroy]

This will not only validate the import to make sure it was successful, but also pull in any live configuration missing from the state file post conversion.

You will also need to add a --skip-refresh to the pulumi import --from in case someone wants to do an import from a converter that doesn't want to do a refresh (for whatever reason).

This will be help the conversion process because extra diffs in pulumi up will make it seem as though your Pulumi code that was converted from Terraform has diffs. By running a refresh, we reduce the diffs that are do to differences in the effect of the converted code.

Affected area/feature

ericrudder commented 11 months ago

Good point about reducing the "diff anxiety" @GeoffMillerAZ

GeoffMillerAZ commented 11 months ago

Import kind of is a refresh, we use the same provider method (Read) for both. If a provider is returning one set of data for an import read, but then updating that on a refresh read that's a provider issue.

This is what I was told on the issue. So maybe this issue needs to be closed and new issues opened with each provider when diffs are found after an import? @Frassle , thoughts?