Skip to content

Commit d440a24

Browse files
committed
godev/cmd: add service account to cloud deployments
To increase the security of our Cloud Run services we use a dedicated service account and switch the cloud tasks service account to one with a limited set of permissions. Change-Id: Ia2730d9cabc79d1f3d134ea8eb3ffcf0b50ec125 Reviewed-on: https://go-review.googlesource.com/c/telemetry/+/524815 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Jamal Carvalho <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
1 parent 67afbd8 commit d440a24

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

godev/cmd/telemetrygodev/cloudbuild.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ steps:
3636
- "gcr.io/$PROJECT_ID/telemetrygodev:$COMMIT_SHA"
3737
- "--region"
3838
- "us-central1"
39+
- "--service-account"
40+
- "$_RUN_SERVICE_ACCOUNT"
3941
- "--set-env-vars"
4042
- "GO_TELEMETRY_PROJECT_ID=$PROJECT_ID,GO_TELEMETRY_ENV=$_ENV"
4143
images:

godev/cmd/worker/cloudbuild.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ steps:
3636
- "gcr.io/$PROJECT_ID/worker:$COMMIT_SHA"
3737
- "--region"
3838
- "us-central1"
39+
- "--service-account"
40+
- "$_RUN_SERVICE_ACCOUNT"
3941
- "--set-env-vars"
4042
- "GO_TELEMETRY_PROJECT_ID=$PROJECT_ID"
4143
- "--set-env-vars"
4244
- "GO_TELEMETRY_ENV=$_ENV"
4345
- "--set-env-vars"
44-
- "GO_TELEMETRY_SERVICE_ACCOUNT=$_SERVICE_ACCOUNT"
46+
- "GO_TELEMETRY_IAP_SERVICE_ACCOUNT=$_IAP_SERVICE_ACCOUNT"
4547
- "--set-env-vars"
4648
- "GO_TELEMETRY_CLIENT_ID=$_CLIENT_ID"
4749
- "--set-env-vars"

godev/cmd/worker/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func createHTTPTask(cfg *config.Config, url string) (*taskspb.Task, error) {
112112
Url: url,
113113
AuthorizationHeader: &taskspb.HttpRequest_OidcToken{
114114
OidcToken: &taskspb.OidcToken{
115-
ServiceAccountEmail: cfg.ServiceAccount,
115+
ServiceAccountEmail: cfg.IAPServiceAccount,
116116
Audience: cfg.ClientID,
117117
},
118118
},

godev/internal/config/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ type Config struct {
3131
// QueueID is the name of the queue for worker tasks.
3232
QueueID string
3333

34-
// ServiceAccount is the service account used when queueing worker tasks.
35-
ServiceAccount string
34+
// IAPServiceAccount is the service account used when queueing worker tasks.
35+
IAPServiceAccount string
3636

3737
// ClientID is the OAuth client used in authentication for queue tasks.
3838
ClientID string
@@ -88,7 +88,7 @@ func NewConfig() *Config {
8888
ProjectID: env("GO_TELEMETRY_PROJECT_ID", ""),
8989
LocationID: env("GO_TELEMETRY_LOCATION_ID", ""),
9090
QueueID: environment + "-worker-tasks",
91-
ServiceAccount: env("GO_TELEMETRY_SERVICE_ACCOUNT", ""),
91+
IAPServiceAccount: env("GO_TELEMETRY_IAP_SERVICE_ACCOUNT", ""),
9292
ClientID: env("GO_TELEMETRY_CLIENT_ID", ""),
9393
StorageEmulatorHost: env("GO_TELEMETRY_STORAGE_EMULATOR_HOST", "localhost:8081"),
9494
LocalStorage: env("GO_TELEMETRY_LOCAL_STORAGE", ".localstorage"),

0 commit comments

Comments
 (0)