-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add google_storage_transfer_project_service_account data_source
- Loading branch information
1 parent
51920e5
commit 19e759c
Showing
6 changed files
with
157 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
google-beta/data_source_google_storage_transfer_project_service_account.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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 | ||
} |
31 changes: 31 additions & 0 deletions
31
google-beta/data_source_google_storage_transfer_project_service_account_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package google | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/helper/resource" | ||
) | ||
|
||
func TestAccDataSourceGoogleStorageTransferProjectServiceAccount_basic(t *testing.T) { | ||
t.Parallel() | ||
|
||
resourceName := "data.google_storage_transfer_project_service_account.default" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCheckGoogleStorageTransferProjectServiceAccount_basic, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(resourceName, "id"), | ||
resource.TestCheckResourceAttrSet(resourceName, "email"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
const testAccCheckGoogleStorageTransferProjectServiceAccount_basic = ` | ||
data "google_storage_transfer_project_service_account" "default" { } | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
website/docs/d/google_storage_transfer_project_service_account.html.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
layout: "google" | ||
page_title: "Google: google_storage_transfer_project_service_account" | ||
sidebar_current: "docs-google-datasource-storage-transfer-project-service-account" | ||
description: |- | ||
Retrieve default service account used by Storage Transfer Jobs running in this project | ||
--- | ||
|
||
# google\_storage\_transfer\_project\_service\_account | ||
|
||
Use this data source to retrieve Storage Transfer service account for this project | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
data "google_storage_transfer_project_service_account" "default" { } | ||
output "default_account" { | ||
value = "${data.google_storage_transfer_project_service_account.default.email}" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `project` - (Optional) The project ID. If it is not provided, the provider project is used. | ||
|
||
|
||
## Attributes Reference | ||
|
||
The following attributes are exported: | ||
|
||
* `email` - Email address of the default service account used by Storage Transfer Jobs running in this project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters