Skip to content

Chore: Use default credentials for tests instead of SA key #1406

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

guilherme-hosoda-cit
Copy link
Contributor

This PR introduces support for default Google Cloud SDK (gcloud) credentials during testing. This eliminates the need for a service account key.

Note

This solution injects your entire Gcloud SDK into the CFT container.

@guilherme-hosoda-cit guilherme-hosoda-cit marked this pull request as draft April 23, 2025 13:52
@eeaton
Copy link
Collaborator

eeaton commented Apr 25, 2025

Thanks Guilherme for the PR!

Unfortunately, there are more changes needed. When I tried testing this locally it fails at an error related to service account keys. (Service Account keys are blocked for most new customer accounts with secure by default org policies), and the automation in the CFT image still relies on service account keys.

I encounter this running make docker_test_prepare. It partially works to create a folder like "test_foundation_folder_z7orq3" and bootstrap project like "ci-foundation-z7orq3-afkk" work, but then fails with an error like the following:

"""
Key creation is not allowed on this service account. [google.rpc.error_details_ext] { message: "Key creation is not allowed on this service account." details { [type.googleapis.com/google.rpc.PreconditionFailure] { violations { type: "constraints/iam.disableServiceAccountKeyCreation" subject: "projects/ci-foundation-z7orq3-afkk/serviceAccounts/ci-account@ci-foundation-z7orq3-afkk.iam.gserviceaccount.com?configvalue=ci-account%40ci-foundation-z7orq3-afkk.iam.gserviceaccount.com" description: "Key creation is not allowed on this service account.
"""

In this repo, I found there is a resource google_service_account_key.int_test at test/setup/iam.tf, and output sa_key under outputs.tf also references that value. It looks like I can get around the issue by removing those two references.

Can you please update this PR to also remove all references to google_service_account_key.int_test?

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.

2 participants