mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-07 09:36:44 +00:00
42 lines
1009 B
Go
42 lines
1009 B
Go
![]() |
package google
|
||
|
|
||
|
import (
|
||
|
"github.com/hashicorp/terraform/helper/schema"
|
||
|
)
|
||
|
|
||
|
func dataSourceGoogleStorageTransferProjectServiceAccount() *schema.Resource {
|
||
|
return &schema.Resource{
|
||
|
Read: dataSourceGoogleStorageTransferProjectServiceAccountRead,
|
||
|
Schema: map[string]*schema.Schema{
|
||
|
"email": {
|
||
|
Type: schema.TypeString,
|
||
|
Computed: true,
|
||
|
},
|
||
|
"project": {
|
||
|
Type: schema.TypeString,
|
||
|
Optional: true,
|
||
|
Computed: true,
|
||
|
},
|
||
|
},
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func dataSourceGoogleStorageTransferProjectServiceAccountRead(d *schema.ResourceData, meta interface{}) error {
|
||
|
config := meta.(*Config)
|
||
|
|
||
|
project, err := getProject(d, config)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
serviceAccount, err := config.clientStorageTransfer.GoogleServiceAccounts.Get(project).Do()
|
||
|
if err != nil {
|
||
|
return handleNotFoundError(err, d, "Google Cloud Storage Transfer service account not found")
|
||
|
}
|
||
|
|
||
|
d.SetId(serviceAccount.AccountEmail)
|
||
|
d.Set("email", serviceAccount.AccountEmail)
|
||
|
d.Set("project", project)
|
||
|
return nil
|
||
|
}
|