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

google_sql_user: Error setting disabled: Invalid address to set since 4.25.0 #11891

Closed
lra opened this issue Jun 16, 2022 · 14 comments
Closed

google_sql_user: Error setting disabled: Invalid address to set since 4.25.0 #11891

lra opened this issue Jun 16, 2022 · 14 comments

Comments

@lra
Copy link
Contributor

lra commented Jun 16, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v1.2.2
on darwin_arm64
+ provider registry.terraform.io/hashicorp/external v2.2.2
+ provider registry.terraform.io/hashicorp/google v4.25.0
+ provider registry.terraform.io/hashicorp/google-beta v4.25.0
+ provider registry.terraform.io/hashicorp/null v3.1.1
+ provider registry.terraform.io/hashicorp/random v3.1.3

Affected Resource(s)

  • google_sql_user

Terraform Configuration Files

module "mssql" {
  source  = "GoogleCloudPlatform/sql-db/google//modules/mssql"
  [...]
}

# Which includes:
resource "google_sql_user" "default" {
  name       = var.user_name
  project    = var.project_id
  instance   = google_sql_database_instance.default.name
  password   = coalesce(var.user_password, random_password.user-password.result)
  depends_on = [null_resource.module_depends_on, google_sql_database_instance.default]
}

We are using the official terraform-google-sql-db module: https://github.com/terraform-google-modules/terraform-google-sql-db/blob/master/modules/mssql/main.tf#L174-L180

Debug Output

Expected Behavior

$ terraform plan
No changes. Your infrastructure matches the configuration.

Actual Behavior

$ terraform plan
│ Error: Error setting disabled: Invalid address to set: []string{"disabled"}
│ 
│   with module.stack.module.mssql.module.mssql.google_sql_user.default,
│   on .terraform/modules/stack.mssql.mssql/modules/mssql/main.tf line 174, in resource "google_sql_user" "default":
│  174: resource "google_sql_user" "default" {

Steps to Reproduce

  1. Create a mssql server using the module sourced source = "GoogleCloudPlatform/sql-db/google//modules/mssql" and the hashicorp/google set to 4.240.
  2. Run terraform apply to create the mssql server
  3. Set the version of the hashicorp/google to 4.25.0
  4. Run terraform plan
│ Error: Error setting disabled: Invalid address to set: []string{"disabled"}
│ 
│   with module.stack.module.mssql.module.mssql.google_sql_user.default,
│   on .terraform/modules/stack.mssql.mssql/modules/mssql/main.tf line 174, in resource "google_sql_user" "default":
│  174: resource "google_sql_user" "default" {

References

I think the bug has been introduced by #11834

@lra lra added the bug label Jun 16, 2022
@iamasmith
Copy link

iamasmith commented Jun 16, 2022

Also experiencing this issue today and pinning to 4.24.0 to avoid and agree this is a regression.

@slevenick
Copy link
Collaborator

Very strange, it looks like during the Read function we set an invalid value that isn't in the schema, but I would expect this to fail during the test. It appears we aren't receiving this block back from the API which is why the test hasn't been failing.

@lra are you able to provide a debug log that shows the GET request that is issued and the corresponding response that I suspect has the sql_server_user_details block set to I can confirm this?

@lra
Copy link
Contributor Author

lra commented Jul 20, 2022

There you go, I had to redact a few things, I also used the latest versions:

Terraform v1.2.5
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v4.29.0
+ provider registry.terraform.io/hashicorp/google-beta v4.29.0
---[ REQUEST ]---------------------------------------
GET /sql/v1beta4/projects/REDACTED/instances/REDACTED/users?alt=json&prettyPrint=false HTTP/1.1
Host: sqladmin.googleapis.com
User-Agent: google-api-go-client/0.5 Terraform/1.2.5 (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google/dev
X-Goog-Api-Client: gl-go/1.16.14 gdcl/0.82.0
Accept-Encoding: gzip


-----------------------------------------------------: timestamp=2022-07-20T15:35:13.310+0200
2022-07-20T15:35:14.729+0200 [INFO]  provider.terraform-provider-google_v4.29.0_x5: 2022/07/20 15:35:14 [DEBUG] Google API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 200 OK
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Date: Wed, 20 Jul 2022 13:35:14 GMT
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
 "kind": "sql#usersList",
 "items": [
  {
   "kind": "sql#user",
   "etag": "REDACTED",
   "name": "##MS_PolicyTsqlExecutionLogin##",
   "host": "",
   "instance": "REDACTED",
   "project": "REDACTED",
   "sqlserverUserDetails": {
    "disabled": true
   }
  },
  {
   "kind": "sql#user",
   "etag": "REDACTED",
   "name": "sqlserver",
   "host": "",
   "instance": "REDACTED",
   "project": "REDACTED",
   "sqlserverUserDetails": {
    "serverRoles": [
     "CustomerDbRootRole"
    ]
   }
  },
  {
   "kind": "sql#user",
   "etag": "REDACTED",
   "name": "REDACTED",
   "host": "",
   "instance": "REDACTED",
   "project": "REDACTED",
   "sqlserverUserDetails": {
    "serverRoles": [
     "CustomerDbRootRole"
    ]
   }
  },
  {
   "kind": "sql#user",
   "etag": "REDACTED",
   "name": "REDACTED",
   "host": "",
   "instance": "REDACTED",
   "project": "REDACTED",
   "sqlserverUserDetails": {}
  },
  {
   "kind": "sql#user",
   "etag": "REDACTED",
   "name": "REDACTED",
   "host": "",
   "instance": "REDACTED",
   "project": "REDACTED",
   "sqlserverUserDetails": {}
  },
  {
   "kind": "sql#user",
   "etag": "REDACTED",
   "name": "REDACTED",
   "host": "",
   "instance": "REDACTED",
   "project": "REDACTED",
   "sqlserverUserDetails": {}
  },
  {
   "kind": "sql#user",
   "etag": "REDACTED",
   "name": "REDACTED",
   "host": "",
   "instance": "REDACTED",
   "project": "REDACTED",
   "sqlserverUserDetails": {}
  },
  {
   "kind": "sql#user",
   "etag": "REDACTED",
   "name": "REDACTED",
   "host": "",
   "instance": "REDACTED",
   "project": "REDACTED",
   "sqlserverUserDetails": {}
  },
  {
   "kind": "sql#user",
   "etag": "REDACTED",
   "name": "REDACTED",
   "host": "",
   "instance": "REDACTED",
   "project": "REDACTED",
   "sqlserverUserDetails": {}
  },
  {
   "kind": "sql#user",
   "etag": "REDACTED",
   "name": "REDACTED",
   "host": "",
   "instance": "REDACTED",
   "project": "REDACTED",
   "sqlserverUserDetails": {}
  },
  {
   "kind": "sql#user",
   "etag": "REDACTED",
   "name": "REDACTED",
   "host": "",
   "instance": "REDACTED",
   "project": "REDACTED",
   "sqlserverUserDetails": {}
  },
  {
   "kind": "sql#user",
   "etag": "REDACTED",
   "name": "REDACTED",
   "host": "",
   "instance": "REDACTED",
   "project": "REDACTED",
   "sqlserverUserDetails": {}
  },
  {
   "kind": "sql#user",
   "etag": "REDACTED",
   "name": "REDACTED",
   "host": "",
   "instance": "REDACTED",
   "project": "REDACTED",
   "sqlserverUserDetails": {}
  },
  {
   "kind": "sql#user",
   "etag": "REDACTED",
   "name": "##MS_PolicyEventProcessingLogin##",
   "host": "",
   "instance": "REDACTED",
   "project": "REDACTED",
   "sqlserverUserDetails": {
    "disabled": true
   }
  }
 ]
}

@edwardmedia
Copy link
Contributor

b/239809673

@edwardmedia
Copy link
Contributor

@philip-harvey
Copy link

Is there any work around to this issue apart from using an old provider version? I can't use an old provider due to needing fixes in the newer provider for other provider issues.

@philip-harvey
Copy link

philip-harvey commented Oct 5, 2022

Why is this labeled as upstream? This seems to be a provider issue.

@slevenick
Copy link
Collaborator

I think there's some confusion around how this field should work. The API apparently doesn't support setting it: GoogleCloudPlatform/magic-modules#6165 (review)

But in some cases it seems to?

@philip-harvey
Copy link

does this mean it's impossible to create a MS SQL user via Terraform currently?

@megan07
Copy link
Contributor

megan07 commented Oct 10, 2022

Closed by GoogleCloudPlatform/magic-modules#6165

@megan07 megan07 closed this as completed Oct 10, 2022
@philip-harvey
Copy link

Will there be a release with this fixed? Just re-tested with the most recent release and it's still broken. Thanks.

@megan07
Copy link
Contributor

megan07 commented Oct 10, 2022

From what I can tell, this will likely be out in the 4.41.0 release. Thanks!

@ArturZejfer
Copy link

ArturZejfer commented Oct 18, 2022

works with 4.41
thanks

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2022
@github-actions github-actions bot added forward/review In review; remove label to forward service/sqladmin-infra labels Jan 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants