Skip to content

fix(sql): set resource identity before early-return in resourceSqlUserRead for stopped instances - #18644

Open
vr-ibm wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
vr-ibm:fix-sql-user-identity-stopped-instance
Open

fix(sql): set resource identity before early-return in resourceSqlUserRead for stopped instances#18644
vr-ibm wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
vr-ibm:fix-sql-user-identity-stopped-instance

Conversation

@vr-ibm

@vr-ibm vr-ibm commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Fixes hashicorp/terraform-provider-google#28571

When a Cloud SQL instance has ActivationPolicy != ALWAYS (stopped/paused), resourceSqlUserRead returns early before SetResourceIdentityAttributes is called. Users upgrading to provider ≥7.42 with existing state see Missing Resource Identity After Read on every plan.

Fix

Call SetResourceIdentityAttributes using project, instance, host, and name (already in scope from d.Get above) immediately before the early-return. The existing call later in the function is untouched.

Test

Strengthened TestAccSqlUser_instanceWithActivationPolicy to assert identity attributes survive a read and import round-trip while the instance is stopped.

sql: fixed `google_sql_user` returning `Missing Resource Identity After Read` when the parent Cloud SQL instance is stopped

…topped instances

When a Cloud SQL instance has ActivationPolicy != ALWAYS (stopped/paused),
resourceSqlUserRead returns early before SetResourceIdentityAttributes is
called. This causes 'Missing Resource Identity After Read' errors for users
upgrading to 7.42+ with existing state from older provider versions.

Fix: call SetResourceIdentityAttributes using values already in scope
(project, instance, host, name) before the early-return so identity is
always populated regardless of instance activation policy.

Also strengthens TestAccSqlUser_instanceWithActivationPolicy to assert
identity attributes are set after reading a stopped instance, and adds
an ImportState step to verify identity survives a full import round-trip.

Fixes hashicorp/terraform-provider-google#28571
@modular-magician modular-magician added awaiting-approval Pull requests that need reviewer's approval to run presubmit tests service/sqladmin-infra and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Aug 13, 2026
@modular-magician

modular-magician commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit ef3f88c:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 2 files changed, 22 insertions(+), 1 deletion(-)
google-beta provider View Diff 2 files changed, 22 insertions(+), 1 deletion(-)

Test report

Analytics

Total Tests Passed Skipped Affected
166 136 30 0
Affected Service Packages
  • sql

Learn how VCR tests work


Step 1: Replaying Mode

🟢 All tests passed in Replaying mode! No Recording was needed.

View the replaying VCR build log

@vr-ibm VCR tests complete for ef3f88c!

@modular-magician modular-magician added awaiting-approval Pull requests that need reviewer's approval to run presubmit tests and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Aug 14, 2026
@modular-magician

modular-magician commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit ad1e45c:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 2 files changed, 22 insertions(+), 1 deletion(-)
google-beta provider View Diff 2 files changed, 22 insertions(+), 1 deletion(-)

Test report

Analytics

Total Tests Passed Skipped Affected
166 136 30 0
Affected Service Packages
  • sql

Learn how VCR tests work


Step 1: Replaying Mode

🟢 All tests passed in Replaying mode! No Recording was needed.

View the replaying VCR build log

@vr-ibm VCR tests complete for ad1e45c!

@vr-ibm
vr-ibm marked this pull request as ready for review August 14, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

google_sql_user: "Missing Resource Identity After Read" on plan when the Cloud SQL instance is stopped

2 participants