appengine: add service_account to google_app_engine_application (#18718)#78
Open
jbbqqf wants to merge 11 commits into
Open
appengine: add service_account to google_app_engine_application (#18718)#78jbbqqf wants to merge 11 commits into
jbbqqf wants to merge 11 commits into
Conversation
Surface the optional Application.serviceAccount field that the AppEngine Admin API has long supported. The field sets the app-level default identity used by deployed App Engine versions when no per-version identity is supplied; it is immutable post-creation, so the schema is ForceNew + Computed (the API may set a default). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add the optional
service_accountargument togoogle_app_engine_application, surfacing theApplication.serviceAccountfield that the AppEngine Admin API has long supported. The field is the app-level default identity used by deployed App Engine versions when no per-version identity is supplied.Fixes hashicorp/terraform-provider-google#18718 — see hashicorp/terraform-provider-google#18718
Why
Today users provisioning an AppEngine application via Terraform cannot pin a custom service account; the API only accepts it on Create (it is immutable post-creation), so the gap forces a
gcloud app create --service-account=workaround that fights with subsequentterraform apply. Surfacing the field on the resource is the standard fix.GCP API reference:
Application.serviceAccount: "The service account associated with the application. This is the app-level default identity. If no identity provided during create version, Admin API will fallback to this one."What changed
This change is to a hand-written Terraform resource (Type=Handwritten in the meta yaml; source-of-truth lives at
mmv1/third_party/terraform/services/appengine/resource_app_engine_application.goin magic-modules).service_account—Optional,Computed,ForceNew(the API rejects updates to this field).expandAppEngineApplicationconstructor and theresourceAppEngineApplicationReadflatten loop.fields:map (api_field: 'serviceAccount').Edge cases tested
# service_account omittedterraform planshows no diff after refreshComputed: truelets the API-assigned default round-trip cleanlyservice_account = "my-app-sa@my-proj.iam.gserviceaccount.com"app.ServiceAccountservice_account = "different-sa@..."forces replacementand the user gets a clear "must destroy + recreate" messageForceNew: true(the AppEngine API does not list this field inApps.Patch's supported updateMask)A live before/after smoke against an AppEngine application was not run because:
resourceAppEngineApplicationDeleteonly logs a warning), and even at the GCP API level it lives until project deletion.terraform validateproves on its own.The static gap is provable directly: an HCL config with
service_account = "..."returnsError: Unsupported argumentonorigin/mainand validates cleanly on this branch.Test protocol
go run ./mmv1 -product=appengine -version=gago run ./mmv1 -product=appengine -version=betago build ./google/services/appengine/...(TPG)go build ./google-beta/services/appengine/...(TPGB)go vet ./google/services/appengine/...(both)Related PRs
Disclosure
This PR was implemented with assistance from Claude Code as part of a focused contribution batch on hand-written AppEngine resources. The diff was reviewed manually against the GCP API documentation linked above.
The author (a human) reviewed the diff and the build/vet output before opening this PR.