mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-03 01:01:06 +00:00
providers/google: Allow custom Compute Engine service account
This commit allows an operator to specify the e-mail address of a service account to use with a Google Compute Engine instance. If no service account e-mail is provided, the default service account is used. Closes #7985
This commit is contained in:
parent
e761259876
commit
ace4cf2831
@ -250,14 +250,16 @@ func resourceComputeInstance() *schema.Resource {
|
||||
|
||||
"service_account": &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
MaxItems: 1,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"email": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"scopes": &schema.Schema{
|
||||
@ -524,8 +526,13 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
|
||||
scopes[i] = canonicalizeServiceScope(v.(string))
|
||||
}
|
||||
|
||||
email := "default"
|
||||
if v := d.Get(prefix + ".email"); v != nil {
|
||||
email = v.(string)
|
||||
}
|
||||
|
||||
serviceAccount := &compute.ServiceAccount{
|
||||
Email: "default",
|
||||
Email: email,
|
||||
Scopes: scopes,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user