Skip to content

Commit 8e2d568

Browse files
authored
Add scopes to service account auth in CES Toolsets (#16580)
1 parent ecf214e commit 8e2d568

4 files changed

Lines changed: 41 additions & 5 deletions

File tree

mmv1/products/ces/Toolset.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,13 @@ properties:
251251
CES service agent
252252
`service-@gcp-sa-ces.iam.gserviceaccount.com`.
253253
required: true
254+
- name: scopes
255+
type: Array
256+
description: |-
257+
The OAuth scopes to grant. If not specified, the default scope
258+
`https://www.googleapis.com/auth/cloud-platform` is used.
259+
item_type:
260+
type: String
254261
- name: serviceAgentIdTokenAuthConfig
255262
type: NestedObject
256263
description: |-
@@ -434,6 +441,13 @@ properties:
434441
CES service agent
435442
`service-@gcp-sa-ces.iam.gserviceaccount.com`.
436443
required: true
444+
- name: scopes
445+
type: Array
446+
description: |-
447+
The OAuth scopes to grant. If not specified, the default scope
448+
`https://www.googleapis.com/auth/cloud-platform` is used.
449+
item_type:
450+
type: String
437451
- name: serviceAgentIdTokenAuthConfig
438452
type: NestedObject
439453
description: |-

mmv1/templates/terraform/examples/ces_toolset_mcp_service_account_auth_config.tf.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ resource "google_ces_toolset" "ces_toolset_mcp_service_account_auth_config" {
3535
api_authentication {
3636
service_account_auth_config {
3737
service_account = "{{index $.TestEnvVars "service_account"}}"
38+
scopes = ["scope1"]
3839
}
3940
}
4041
}

mmv1/templates/terraform/examples/ces_toolset_openapi_service_account_auth_config.tf.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ resource "google_ces_toolset" "ces_toolset_openapi_service_account_auth_config"
4444
}
4545
api_authentication {
4646
service_account_auth_config {
47-
service_account = "testaccount@gmail.com"
47+
service_account = "{{index $.TestEnvVars "service_account"}}"
48+
scopes = ["scope1"]
4849
}
4950
}
5051
}

mmv1/third_party/terraform/services/ces/ces_toolset_test.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ func TestAccCESToolset_cesToolsetOpenapiServiceAccountAuthConfigExample_update(t
4949

5050
func testAccCESToolset_cesToolsetOpenapiServiceAccountAuthConfigExample_full(context map[string]interface{}) string {
5151
return acctest.Nprintf(`
52+
resource "google_service_account" "ces_test_service_account" {
53+
account_id = "tf-test-sa-ces-%{random_suffix}"
54+
}
55+
5256
resource "google_ces_app" "ces_app_for_toolset" {
5357
app_id = "tf-test-app-id%{random_suffix}"
5458
location = "us"
@@ -95,7 +99,8 @@ resource "google_ces_toolset" "ces_toolset_openapi_service_account_auth_config"
9599
}
96100
api_authentication {
97101
service_account_auth_config {
98-
service_account = "testaccount@gmail.com"
102+
service_account = "${google_service_account.ces_test_service_account.email}"
103+
scopes = ["https://www.googleapis.com/auth/cloud-platform"]
99104
}
100105
}
101106
}
@@ -105,6 +110,10 @@ resource "google_ces_toolset" "ces_toolset_openapi_service_account_auth_config"
105110

106111
func testAccCESToolset_cesToolsetOpenapiServiceAccountAuthConfigExample_update(context map[string]interface{}) string {
107112
return acctest.Nprintf(`
113+
resource "google_service_account" "ces_test_service_account" {
114+
account_id = "tf-test-sa-ces-%{random_suffix}"
115+
}
116+
108117
resource "google_ces_app" "ces_app_for_toolset" {
109118
app_id = "tf-test-app-id%{random_suffix}"
110119
location = "us"
@@ -151,7 +160,8 @@ resource "google_ces_toolset" "ces_toolset_openapi_service_account_auth_config"
151160
}
152161
api_authentication {
153162
service_account_auth_config {
154-
service_account = "testaccountupdated@gmail.com"
163+
service_account = "${google_service_account.ces_test_service_account.email}"
164+
scopes = ["https://www.googleapis.com/auth/cloud-platform"]
155165
}
156166
}
157167
}
@@ -814,6 +824,10 @@ func TestAccCESToolset_cesToolsetMcpServiceAccountAuthConfigExample_update(t *te
814824

815825
func testAccCESToolset_cesToolsetMcpServiceAccountAuthConfigExample_full(context map[string]interface{}) string {
816826
return acctest.Nprintf(`
827+
resource "google_service_account" "ces_test_service_account" {
828+
account_id = "tf-test-sa-ces-%{random_suffix}"
829+
}
830+
817831
resource "google_ces_app" "ces_app_for_toolset" {
818832
app_id = "tf-test-app-id%{random_suffix}"
819833
location = "us"
@@ -847,7 +861,8 @@ resource "google_ces_toolset" "ces_toolset_mcp_service_account_auth_config" {
847861
}
848862
api_authentication {
849863
service_account_auth_config {
850-
service_account = "testaccount@gmail.com"
864+
service_account = "${google_service_account.ces_test_service_account.email}"
865+
scopes = ["https://www.googleapis.com/auth/cloud-platform"]
851866
}
852867
}
853868
}
@@ -857,6 +872,10 @@ resource "google_ces_toolset" "ces_toolset_mcp_service_account_auth_config" {
857872

858873
func testAccCESToolset_cesToolsetMcpServiceAccountAuthConfigExample_update(context map[string]interface{}) string {
859874
return acctest.Nprintf(`
875+
resource "google_service_account" "ces_test_service_account" {
876+
account_id = "tf-test-sa-ces-%{random_suffix}"
877+
}
878+
860879
resource "google_ces_app" "ces_app_for_toolset" {
861880
app_id = "tf-test-app-id%{random_suffix}"
862881
location = "us"
@@ -890,7 +909,8 @@ resource "google_ces_toolset" "ces_toolset_mcp_service_account_auth_config" {
890909
}
891910
api_authentication {
892911
service_account_auth_config {
893-
service_account = "testaccountupdated@gmail.com"
912+
service_account = "${google_service_account.ces_test_service_account.email}"
913+
scopes = ["https://www.googleapis.com/auth/cloud-platform"]
894914
}
895915
}
896916
}

0 commit comments

Comments
 (0)