Skip to content

Add resource identity to Move RPC #1123

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

Merged
merged 14 commits into from
Apr 21, 2025
Merged

Add resource identity to Move RPC #1123

merged 14 commits into from
Apr 21, 2025

Conversation

rainkwan
Copy link
Contributor

@rainkwan rainkwan commented Mar 27, 2025

Follow-Up PR for #1112

This PR implements MoveResourceState (Move) for identity.

@rainkwan rainkwan marked this pull request as ready for review April 2, 2025 18:43
@rainkwan rainkwan requested a review from a team as a code owner April 2, 2025 18:43
@rainkwan rainkwan added the enhancement New feature or request label Apr 2, 2025
@rainkwan rainkwan added this to the v1.15.0 milestone Apr 2, 2025
@rainkwan rainkwan force-pushed the rk/resource-identity branch from 718b775 to f3504cb Compare April 14, 2025 15:33
Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

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

Overall everything is looking good! I had a couple questions/nits

@rainkwan rainkwan force-pushed the rk/resource-identity branch 2 times, most recently from ee99491 to 335b4c0 Compare April 16, 2025 15:29
@rainkwan rainkwan requested a review from austinvalle April 16, 2025 18:14
Comment on lines 944 to 945
// Try to set TargetIdentity even though req.IdentitySchema is nil
resp.Diagnostics.Append(resp.TargetIdentity.SetAttribute(ctx, path.Root("test_id"), "should-not-be-set")...)
Copy link
Member

@austinvalle austinvalle Apr 17, 2025

Choose a reason for hiding this comment

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

This is the scenario we're trying to prevent, if a provider does this it'll send back identity data to Terraform despite it not "announcing" an identity schema for the resource 🙂:

Suggested change
// Try to set TargetIdentity even though req.IdentitySchema is nil
resp.Diagnostics.Append(resp.TargetIdentity.SetAttribute(ctx, path.Root("test_id"), "should-not-be-set")...)
// This resource doesn't indicate identity support (via a schema), so this should raise a diagnostic.
resp.TargetIdentity = &tfsdk.ResourceIdentity{
Raw: tftypes.NewValue(testIdentitySchema.Type().TerraformType(ctx), map[string]tftypes.Value{
"test_id": tftypes.NewValue(tftypes.String, "should-not-be-set"),
}),
Schema: testIdentitySchema,
}

Copy link
Contributor Author

@rainkwan rainkwan Apr 17, 2025

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Yeah it should be raising a diagnostic, it looks like the check being on line 228 was too early because resp.TargetIdentity is not set at that point (it's at moveStateResp.TargetIdentity when it comes back from your provider code that sets it).

Other RPCs just immediately set resp.Identity after the RPC, but if you want to move that piece of logic down lower we can also do that!

I'll make a comment suggestion 👍🏻

@rainkwan rainkwan requested a review from austinvalle April 17, 2025 17:00
@rainkwan rainkwan force-pushed the rk/resource-identity branch from c974c77 to 5746ebf Compare April 18, 2025 20:08
@rainkwan rainkwan requested a review from austinvalle April 18, 2025 20:36
Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

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

🎉

@rainkwan rainkwan force-pushed the rk/resource-identity branch from 092543b to 097c894 Compare April 21, 2025 13:44
@rainkwan rainkwan merged commit 3497335 into main Apr 21, 2025
35 checks passed
@rainkwan rainkwan deleted the rk/resource-identity branch April 21, 2025 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants