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

fix!: Change additional user default password #332

Conversation

carash
Copy link
Contributor

@carash carash commented Aug 4, 2022

Additional users are currently using the random_password.user-password as its default password instead of using each of their self-generated random_password.additional_passwords

@google-cla
Copy link

google-cla bot commented Aug 4, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Member

@bharathkkb bharathkkb left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @carash

@@ -192,7 +192,7 @@ resource "google_sql_user" "additional_users" {
for_each = local.users
project = var.project_id
name = each.value.name
password = lookup(each.value, "password", random_password.user-password.result)
password = lookup(each.value, "password", random_password.additional_passwords[each.key].result)
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a section to the upgrade guide for existing users? I suspect users who already applied can set the value ofrandom_password.user-password.result to var. additional_users to prevent a diff.
https://github.com/terraform-google-modules/terraform-google-sql-db/blob/master/docs/upgrading_to_sql_db_12.0.0.md

Copy link
Contributor

Choose a reason for hiding this comment

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

@carash - we'd like this to part of the upcoming release. Let us know if you can update this in the next 24h. Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do, I'll update the PR today along with the updated tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suspect an upgrade guide to prevent a diff might require manipulating the tfstate file directly, is that fine?

Copy link
Member

Choose a reason for hiding this comment

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

@carash I was thinking since they have already applied it with random_password.user-password.result, they can retrieve output from generated_user_password and use that to construct var. additional_users like

+ data "google_secret_manager_secret_version" "password" {
+  secret_id = "pg-user-pass"
+  project   = var.project_id
+ }
...
additional_users = [
     {
       name     = "user1"
+       password = data.google_secret_manager_secret_version.password.secret_data
     }
   ]

similar to what did here https://github.com/terraform-google-modules/terraform-google-sql-db/blob/master/docs/upgrading_to_sql_db_11.0.0.md#switched-to-using-random_password-to-generate-default-passwords

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah I see. that'll do it, thanks

@bharathkkb bharathkkb changed the title fix: Change additional user default password fix!: Change additional user default password Aug 9, 2022
@carash
Copy link
Contributor Author

carash commented Aug 11, 2022

Hi @bharathkkb, I'm currently having trouble with the integration testing, I've tried following the instructions in CONTRIBUTING.md, but the InSpec and Kitchen configs just don't seem to be working for me. Any chance of helping me with this?

I also noticed that there don't seem to be any files relating to Kitchen and InSpec in this repo. How should I run the integration test locally?

Co-authored-by: Laura Seidler <42136707+lauraseidler@users.noreply.github.com>
@g-awmalik
Copy link
Contributor

@carash - thanks for the upgrade guide, everything looks good.

Regarding int. tests, we're not using Kitchen/Inspec anymore instead we have golang based tests that you can find under the test/ directory. I can see why that is confusing since the contribution guide still refers to Kitchen; we will clean that up. Execution for int. test remains the same though i.e. make docker_test_prepare to prepare after setting envars and then make docker_test_integration to run all tests.

More info on this revised test framework can be found here: https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit/tree/master/infra/blueprint-test

@comment-bot-dev
Copy link

@carash
Thanks for the PR! 🚀
✅ Lint checks have passed.

Copy link
Contributor

@g-awmalik g-awmalik left a comment

Choose a reason for hiding this comment

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

LGTM

@g-awmalik g-awmalik merged commit f96f71e into terraform-google-modules:master Aug 12, 2022
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.

None yet

5 participants