terraform-provider-google/google/data_source_google_storage_project_service_account.go
ishashchuk ef3ea881b1 Datasource for retrieving GCS service account (#1110)
* Datasource for retrieving GCS service account

* Removing duplicated argument

* Gofmt post resolving conflicts

* Addressing review comment
2018-02-21 13:37:23 -08:00

30 lines
672 B
Go

package google
import (
"github.com/hashicorp/terraform/helper/schema"
)
func dataSourceGoogleStorageProjectServiceAccount() *schema.Resource {
return &schema.Resource{
Read: dataSourceGoogleStorageProjectServiceAccountRead,
}
}
func dataSourceGoogleStorageProjectServiceAccountRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
project, err := getProject(d, config)
if err != nil {
return err
}
serviceAccount, err := config.clientStorage.Projects.ServiceAccount.Get(project).Do()
if err != nil {
return handleNotFoundError(err, d, "GCS service account not found")
}
d.SetId(serviceAccount.EmailAddress)
return nil
}