-
Notifications
You must be signed in to change notification settings - Fork 99
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Module version
v1.16.1
Relevant provider source code
func (p *googleEphemeralServiceAccountKey) Close(ctx context.Context, req ephemeral.CloseRequest, resp *ephemeral.CloseResponse) {
serviceAccountKeyName, err := req.Private.GetKey(ctx, "name")
fmt.Printf("[DEBUG] Deleting Service Account Key %q\n", serviceAccountKeyName)
if err != nil {
resp.Diagnostics.AddError(
"Error getting private key",
fmt.Sprintf("Error getting private key: %s", err),
)
return
}
deletion, _ := p.providerConfig.NewIamClient(p.providerConfig.UserAgent).Projects.ServiceAccounts.Keys.Delete(string(serviceAccountKeyName)).Do()
if deletion != nil {
resp.Diagnostics.AddError(
"Error deleting Service Account Key",
fmt.Sprintf("Error deleting Service Account Key %q: %s", string(serviceAccountKeyName), err),
)
return
}
}Terraform Configuration Files
func testAccEphemeralServiceAccountKey_publicKey(account, name string) string {
return fmt.Sprintf(`
resource "google_service_account" "acceptance" {
account_id = "%s"
display_name = "%s"
}
ephemeral "google_service_account_key" "key" {
service_account_id = google_service_account.acceptance.email
public_key = filebase64("test-fixtures/public_key.pem")
}
`, account, name)
}Debug Output
Expected Behavior
2025/11/04 13:51:06 [DEBUG] Retry Transport: Returning after 1 attempts
[DEBUG] Deleting Service Account Key ""
[DEBUG] Deleting Service Account Key ""
[DEBUG] Deleting Service Account Key ""
[DEBUG] Deleting Service Account Key ""
[DEBUG] Deleting Service Account Key ""
[DEBUG] Deleting Service Account Key ""
--- PASS: TestAccEphemeralServiceAccountKey_basic (34.44s)
PASS
ok github.com/hashicorp/terraform-provider-google/google/services/resourcemanager 35.988sActual Behavior
we should be seeing the service account key name shown in debug log
Steps to Reproduce
git clone https://github.com/BBBmau/magic-modules/git switch ephemeral-close-bug- `envchain GCLOUD make testacc TEST=./google/services/resourcemanager TESTARGS='-run=TestAccEphemeralServiceAccountKey_basic' assuming you have envchain installed (required to have gcloud envvars set)
References
This issue comes from working on:
serviceAccountKey: addClose()in ephemeral to supportprivate_dataattribute GoogleCloudPlatform/magic-modules#15476
which would introduceClose()to allow for theprivate_keyto be returned, an attribute that previously wasn't supported because of not includingClose()in the initial implementation
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working