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

Commit 7848134

Browse files
authored
Merge pull request hashicorp#8431 from sairez/sairez/google-instance-template-custom-service-account
provider/google: Allow custom Compute Engine service account in instance template
2 parents f22564c + 35c7d37 commit 7848134

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

builtin/providers/google/resource_compute_instance_template.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,14 @@ func resourceComputeInstanceTemplate() *schema.Resource {
272272

273273
"service_account": &schema.Schema{
274274
Type: schema.TypeList,
275+
MaxItems: 1,
275276
Optional: true,
276277
ForceNew: true,
277278
Elem: &schema.Resource{
278279
Schema: map[string]*schema.Schema{
279280
"email": &schema.Schema{
280281
Type: schema.TypeString,
282+
Optional: true,
281283
Computed: true,
282284
ForceNew: true,
283285
},
@@ -543,8 +545,13 @@ func resourceComputeInstanceTemplateCreate(d *schema.ResourceData, meta interfac
543545
scopes = append(scopes, canonicalizeServiceScope(scope))
544546
}
545547

548+
email := "default"
549+
if v := d.Get(prefix + ".email"); v != nil {
550+
email = v.(string)
551+
}
552+
546553
serviceAccount := &compute.ServiceAccount{
547-
Email: "default",
554+
Email: email,
548555
Scopes: scopes,
549556
}
550557

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ The following arguments are supported:
150150
* `scheduling` - (Optional) The scheduling strategy to use. More details about
151151
this configuration option are detailed below.
152152

153-
* `service_account` - (Optional) Service account to attach to the instance.
153+
* `service_account` - (Optional) Service account to attach to the instance. Structure is documented below.
154154

155155
* `tags` - (Optional) Tags to attach to the instance.
156156

@@ -214,6 +214,9 @@ The `access_config` block supports:
214214

215215
The `service_account` block supports:
216216

217+
* `email` - (Optional) The service account e-mail address. If not given, the
218+
default Google Compute Engine service account is used.
219+
217220
* `scopes` - (Required) A list of service scopes. Both OAuth2 URLs and gcloud
218221
short names are supported.
219222

0 commit comments

Comments
 (0)