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: Fixed import where host is an IPv4 CIDR #8028

Conversation

modular-magician
Copy link
Collaborator

Previously it was not possible to import CloudSQL users for MySQL with host set to an IPv4 CIDR. The parsing of ID failed if host was a CIDR since it expected it to be on the form {project}/{instance}/{host}/{name} and an error was returned if there where more than three slashes in the ID.

With this fix if there are four slashes in the ID the third is considered part of the host argument.

sql: fixed importing `google_sql_user` where `host` is an IPv4 CIDR

Acceptance test run:

$ make testacc TEST=./google/services/sql TESTARGS='-run=TestAccSqlUser_mysql' 
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google/services/sql -v -run=TestAccSqlUser_mysql -timeout 240m -ldflags="-X=github.com/hashicorp/terraform-provider-google/version.ProviderVersion=acc"
=== RUN   TestAccSqlUser_mysql
=== PAUSE TestAccSqlUser_mysql
=== RUN   TestAccSqlUser_mysqlPasswordPolicy
=== PAUSE TestAccSqlUser_mysqlPasswordPolicy
=== CONT  TestAccSqlUser_mysql
=== CONT  TestAccSqlUser_mysqlPasswordPolicy
--- PASS: TestAccSqlUser_mysql (770.89s)
--- PASS: TestAccSqlUser_mysqlPasswordPolicy (950.89s)
PASS
ok      github.com/hashicorp/terraform-provider-google/google/services/sql      952.219s

Previously a import would fail with the message shown bellow. After the change this import succeeds with host set to 10.0.0.0/24.

$ terraform import google_sql_user.admin my-project/my-instance/10.0.0.0/24/admin 
[...]
        Error: Invalid specifier. Expecting {project}/{instance}/{name} for postgres instance and {project}/{instance}/{host}/{name} for MySQL instance

Derived from GoogleCloudPlatform/magic-modules#11523

[upstream:8eb4d1a9d94f44eb65ba93425eef7be1bd785f95]

Signed-off-by: Modular Magician <[email protected]>
@modular-magician modular-magician merged commit 7dbcab2 into hashicorp:main Aug 23, 2024
2 checks passed
@modular-magician modular-magician deleted the downstream-pr-8eb4d1a9d94f44eb65ba93425eef7be1bd785f95 branch November 16, 2024 02:19
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.

1 participant