Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress undefined to default diffs on aws.autoscaling.Group #4510

Merged
merged 4 commits into from
Sep 24, 2024

Conversation

t0yv0
Copy link
Member

@t0yv0 t0yv0 commented Sep 23, 2024

Fix a regression in the import experience on aws.autoscaling.Group. Specifically the conflict between undefined and default values that pulumi import used to detect is no longer a conflict by automatically injecting DiffSuppressFunc for the relevant properties.

Fixes #4457

Fix a regression in the import experience on aws.autoscaling.Group. Specifically the conflict between undefined and
default values that `pulumi import` used to detect is no longer a conflict by automatically injecting DiffSuppressFunc
for the relevant properties.

Fixes #4457
t.Logf("workdir = %s", workdir)
importResult := execPulumi(t, ptest, workdir, "import", "aws:autoscaling/group:Group", "newag", autoGroupName, "--yes")

t.Logf("Editing the program to add the code recommended by import")
Copy link
Member Author

@t0yv0 t0yv0 Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK we have no precedent of testing this, throwing in some automation, can generalize later if this is important. I have a suspicion that the issue generalizes to many resources in the ecosystem as TF Read() is not guaranteed to apply defaults.

Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

Maintainer note: consult the runbook for dealing with any breaking changes.

Copy link
Contributor

@VenelinMartinov VenelinMartinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we considered using a TransformOutputs hook instead? That could be used to act on the import output, so that the fixup has to happen only once after the state is imported/

provider/provider_python_test.go Outdated Show resolved Hide resolved
provider/provider_python_test.go Outdated Show resolved Hide resolved
@t0yv0
Copy link
Member Author

t0yv0 commented Sep 24, 2024

I was a little surprised but TransformOutputs hook works well. It is able to eliminate the default values from the printed imported program which is good, and it also fixes the issue. The ability to be certain about undefined vs null vs empty is much appreciated. I think it also bypasses the problem with hypothetical defaults change.

provider/resources.go Outdated Show resolved Hide resolved
@t0yv0
Copy link
Member Author

t0yv0 commented Sep 24, 2024

I've tested refresh and import_ option manually, seem to work as well for this with these changes.

Copy link
Contributor

@flostadler flostadler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}
}
defaults := map[string]resource.PropertyValue{
"forceDelete": defaultValue("force_delete"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we detect the props that need the defaults to be fixed? This would help us generalize this and also make maintenance a bit easier (no need to play catchup with upstream).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works so well we should maybe change the bridge default behavior here in pulumi/pulumi-terraform-bridge#2436 so that's how it works by default without the custom code.

@t0yv0 t0yv0 enabled auto-merge (squash) September 24, 2024 18:57
@t0yv0 t0yv0 merged commit 3379551 into master Sep 24, 2024
30 checks passed
@t0yv0 t0yv0 deleted the t0yv0/fix-4457 branch September 24, 2024 19:25
@pulumi-bot
Copy link
Contributor

This PR has been shipped in release v6.53.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[import] AWS autoscaling group import and subsequent up tries to fix defaults to actual default values
4 participants