Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit 701cd20

Browse files
authored
Merge pull request hashicorp#7991 from evandbrown/google-instance-custom-service-account
providers/google: Allow custom Compute Engine service account
2 parents e7f31eb + 0e565e5 commit 701cd20

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

builtin/providers/google/resource_compute_instance.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,16 @@ func resourceComputeInstance() *schema.Resource {
250250

251251
"service_account": &schema.Schema{
252252
Type: schema.TypeList,
253+
MaxItems: 1,
253254
Optional: true,
254255
ForceNew: true,
255256
Elem: &schema.Resource{
256257
Schema: map[string]*schema.Schema{
257258
"email": &schema.Schema{
258259
Type: schema.TypeString,
259-
Computed: true,
260260
ForceNew: true,
261+
Optional: true,
262+
Computed: true,
261263
},
262264

263265
"scopes": &schema.Schema{
@@ -524,8 +526,13 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
524526
scopes[i] = canonicalizeServiceScope(v.(string))
525527
}
526528

529+
email := "default"
530+
if v := d.Get(prefix + ".email"); v != nil {
531+
email = v.(string)
532+
}
533+
527534
serviceAccount := &compute.ServiceAccount{
528-
Email: "default",
535+
Email: email,
529536
Scopes: scopes,
530537
}
531538

website/source/docs/providers/google/r/compute_instance.html.markdown

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ The following arguments are supported:
101101
this configuration option are detailed below.
102102

103103
* `service_account` - (Optional) Service account to attach to the instance.
104+
Structure is documented below.
104105

105106
* `tags` - (Optional) Tags to attach to the instance.
106107

@@ -151,18 +152,21 @@ The `access_config` block supports:
151152
* `nat_ip` - (Optional) The IP address that will be 1:1 mapped to the instance's
152153
network ip. If not given, one will be generated.
153154

155+
The `service_account` block supports:
156+
157+
* `email` - (Optional) The service account e-mail address. If not given, the
158+
default Google Compute Engine service account is used.
159+
160+
* `scopes` - (Required) A list of service scopes. Both OAuth2 URLs and gcloud
161+
short names are supported.
162+
154163
(DEPRECATED) The `network` block supports:
155164

156165
* `source` - (Required) The name of the network to attach this interface to.
157166

158167
* `address` - (Optional) The IP address of a reserved IP address to assign
159168
to this interface.
160169

161-
The `service_account` block supports:
162-
163-
* `scopes` - (Required) A list of service scopes. Both OAuth2 URLs and gcloud
164-
short names are supported.
165-
166170
The `scheduling` block supports:
167171

168172
* `preemptible` - (Optional) Is the instance preemptible.

0 commit comments

Comments
 (0)