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

Support serviceAccount field for AppEngine flex #6391

Merged
merged 9 commits into from
Sep 2, 2022
5 changes: 5 additions & 0 deletions mmv1/products/appengine/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,11 @@ objects:
name: 'runtimeMainExecutablePath'
description: |
The path or name of the app's main executable.
- !ruby/object:Api::Type::String
name: 'serviceAccount'
description: |
The identity that the deployed version will run as. Admin API will use the App Engine Appspot service account as
default if this field is neither provided in app.yaml file nor through CLI flag.
- !ruby/object:Api::Type::NestedObject
name: 'apiConfig'
description: |
Expand Down
1 change: 1 addition & 0 deletions mmv1/products/appengine/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
vars:
bucket_name: "appengine-static-content"
project: "appeng-flex"
account_id: "my-account"
test_env_vars:
org_id: :ORG_ID
billing_account: :BILLING_ACCT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,28 @@ resource "google_project_service" "service" {
disable_dependent_services = false
}

resource "google_service_account" "custom_service_account" {
project = google_project_service.service.project
account_id = "<%= ctx[:vars]['account_id'] %>"
melinath marked this conversation as resolved.
Show resolved Hide resolved
display_name = "Custom Service Account"
}

resource "google_project_iam_member" "gae_api" {
project = google_project_service.service.project
role = "roles/compute.networkUser"
member = "serviceAccount:service-${google_project.my_project.number}@gae-api-prod.google.com.iam.gserviceaccount.com"
member = "serviceAccount:${google_service_account.custom_service_account.email}"
}

resource "google_project_iam_member" "logs_writer" {
project = google_project_service.service.project
role = "roles/logging.logWriter"
member = "serviceAccount:${google_service_account.custom_service_account.email}"
}

resource "google_project_iam_member" "storage_viewer" {
project = google_project_service.service.project
role = "roles/storage.objectViewer"
member = "serviceAccount:${google_service_account.custom_service_account.email}"
}

resource "google_app_engine_flexible_app_version" "<%= ctx[:primary_resource_id] %>" {
Expand Down Expand Up @@ -71,6 +89,7 @@ resource "google_app_engine_flexible_app_version" "<%= ctx[:primary_resource_id]
}

noop_on_destroy = true
service_account = google_service_account.custom_service_account.email
}

resource "google_storage_bucket" "bucket" {
Expand Down