mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-01 07:42:40 +00:00
Add google_storage_transfer_project_service_account data_source (#2692)
<!-- This change is generated by MagicModules. --> /cc @akramhussein
This commit is contained in:
parent
f39137c5d3
commit
23b44b5ae5
|
@ -46,6 +46,7 @@ import (
|
||||||
"google.golang.org/api/spanner/v1"
|
"google.golang.org/api/spanner/v1"
|
||||||
"google.golang.org/api/sqladmin/v1beta4"
|
"google.golang.org/api/sqladmin/v1beta4"
|
||||||
"google.golang.org/api/storage/v1"
|
"google.golang.org/api/storage/v1"
|
||||||
|
"google.golang.org/api/storagetransfer/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is the configuration structure used to instantiate the Google
|
// Config is the configuration structure used to instantiate the Google
|
||||||
|
@ -91,6 +92,7 @@ type Config struct {
|
||||||
clientCloudFunctions *cloudfunctions.Service
|
clientCloudFunctions *cloudfunctions.Service
|
||||||
clientCloudIoT *cloudiot.Service
|
clientCloudIoT *cloudiot.Service
|
||||||
clientAppEngine *appengine.APIService
|
clientAppEngine *appengine.APIService
|
||||||
|
clientStorageTransfer *storagetransfer.Service
|
||||||
|
|
||||||
bigtableClientFactory *BigtableClientFactory
|
bigtableClientFactory *BigtableClientFactory
|
||||||
}
|
}
|
||||||
|
@ -379,6 +381,13 @@ func (c *Config) loadAndValidate() error {
|
||||||
}
|
}
|
||||||
c.clientComposer.UserAgent = userAgent
|
c.clientComposer.UserAgent = userAgent
|
||||||
|
|
||||||
|
log.Printf("[INFO] Instantiating Google Cloud Storage Transfer Client...")
|
||||||
|
c.clientStorageTransfer, err = storagetransfer.New(client)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.clientStorageTransfer.UserAgent = userAgent
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
|
@ -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" { }
|
||||||
|
`
|
|
@ -61,44 +61,45 @@ func Provider() terraform.ResourceProvider {
|
||||||
},
|
},
|
||||||
|
|
||||||
DataSourcesMap: map[string]*schema.Resource{
|
DataSourcesMap: map[string]*schema.Resource{
|
||||||
"google_active_folder": dataSourceGoogleActiveFolder(),
|
"google_active_folder": dataSourceGoogleActiveFolder(),
|
||||||
"google_billing_account": dataSourceGoogleBillingAccount(),
|
"google_billing_account": dataSourceGoogleBillingAccount(),
|
||||||
"google_dns_managed_zone": dataSourceDnsManagedZone(),
|
"google_dns_managed_zone": dataSourceDnsManagedZone(),
|
||||||
"google_client_config": dataSourceGoogleClientConfig(),
|
"google_client_config": dataSourceGoogleClientConfig(),
|
||||||
"google_cloudfunctions_function": dataSourceGoogleCloudFunctionsFunction(),
|
"google_cloudfunctions_function": dataSourceGoogleCloudFunctionsFunction(),
|
||||||
"google_compute_address": dataSourceGoogleComputeAddress(),
|
"google_compute_address": dataSourceGoogleComputeAddress(),
|
||||||
"google_compute_backend_service": dataSourceGoogleComputeBackendService(),
|
"google_compute_backend_service": dataSourceGoogleComputeBackendService(),
|
||||||
"google_compute_default_service_account": dataSourceGoogleComputeDefaultServiceAccount(),
|
"google_compute_default_service_account": dataSourceGoogleComputeDefaultServiceAccount(),
|
||||||
"google_compute_forwarding_rule": dataSourceGoogleComputeForwardingRule(),
|
"google_compute_forwarding_rule": dataSourceGoogleComputeForwardingRule(),
|
||||||
"google_compute_image": dataSourceGoogleComputeImage(),
|
"google_compute_image": dataSourceGoogleComputeImage(),
|
||||||
"google_compute_instance": dataSourceGoogleComputeInstance(),
|
"google_compute_instance": dataSourceGoogleComputeInstance(),
|
||||||
"google_compute_global_address": dataSourceGoogleComputeGlobalAddress(),
|
"google_compute_instance_group": dataSourceGoogleComputeInstanceGroup(),
|
||||||
"google_compute_instance_group": dataSourceGoogleComputeInstanceGroup(),
|
"google_compute_global_address": dataSourceGoogleComputeGlobalAddress(),
|
||||||
"google_compute_lb_ip_ranges": dataSourceGoogleComputeLbIpRanges(),
|
"google_compute_lb_ip_ranges": dataSourceGoogleComputeLbIpRanges(),
|
||||||
"google_compute_network": dataSourceGoogleComputeNetwork(),
|
"google_compute_network": dataSourceGoogleComputeNetwork(),
|
||||||
"google_compute_regions": dataSourceGoogleComputeRegions(),
|
"google_compute_regions": dataSourceGoogleComputeRegions(),
|
||||||
"google_compute_region_instance_group": dataSourceGoogleComputeRegionInstanceGroup(),
|
"google_compute_region_instance_group": dataSourceGoogleComputeRegionInstanceGroup(),
|
||||||
"google_compute_subnetwork": dataSourceGoogleComputeSubnetwork(),
|
"google_compute_subnetwork": dataSourceGoogleComputeSubnetwork(),
|
||||||
"google_compute_zones": dataSourceGoogleComputeZones(),
|
"google_compute_zones": dataSourceGoogleComputeZones(),
|
||||||
"google_compute_vpn_gateway": dataSourceGoogleComputeVpnGateway(),
|
"google_compute_vpn_gateway": dataSourceGoogleComputeVpnGateway(),
|
||||||
"google_compute_ssl_policy": dataSourceGoogleComputeSslPolicy(),
|
"google_compute_ssl_policy": dataSourceGoogleComputeSslPolicy(),
|
||||||
"google_container_cluster": dataSourceGoogleContainerCluster(),
|
"google_container_cluster": dataSourceGoogleContainerCluster(),
|
||||||
"google_container_engine_versions": dataSourceGoogleContainerEngineVersions(),
|
"google_container_engine_versions": dataSourceGoogleContainerEngineVersions(),
|
||||||
"google_container_registry_repository": dataSourceGoogleContainerRepo(),
|
"google_container_registry_repository": dataSourceGoogleContainerRepo(),
|
||||||
"google_container_registry_image": dataSourceGoogleContainerImage(),
|
"google_container_registry_image": dataSourceGoogleContainerImage(),
|
||||||
"google_iam_policy": dataSourceGoogleIamPolicy(),
|
"google_iam_policy": dataSourceGoogleIamPolicy(),
|
||||||
"google_iam_role": dataSourceGoogleIamRole(),
|
"google_iam_role": dataSourceGoogleIamRole(),
|
||||||
"google_kms_secret": dataSourceGoogleKmsSecret(),
|
"google_kms_secret": dataSourceGoogleKmsSecret(),
|
||||||
"google_folder": dataSourceGoogleFolder(),
|
"google_folder": dataSourceGoogleFolder(),
|
||||||
"google_netblock_ip_ranges": dataSourceGoogleNetblockIpRanges(),
|
"google_netblock_ip_ranges": dataSourceGoogleNetblockIpRanges(),
|
||||||
"google_organization": dataSourceGoogleOrganization(),
|
"google_organization": dataSourceGoogleOrganization(),
|
||||||
"google_project": dataSourceGoogleProject(),
|
"google_project": dataSourceGoogleProject(),
|
||||||
"google_project_services": dataSourceGoogleProjectServices(),
|
"google_project_services": dataSourceGoogleProjectServices(),
|
||||||
"google_service_account": dataSourceGoogleServiceAccount(),
|
"google_service_account": dataSourceGoogleServiceAccount(),
|
||||||
"google_service_account_key": dataSourceGoogleServiceAccountKey(),
|
"google_service_account_key": dataSourceGoogleServiceAccountKey(),
|
||||||
"google_storage_bucket_object": dataSourceGoogleStorageBucketObject(),
|
"google_storage_bucket_object": dataSourceGoogleStorageBucketObject(),
|
||||||
"google_storage_object_signed_url": dataSourceGoogleSignedUrl(),
|
"google_storage_object_signed_url": dataSourceGoogleSignedUrl(),
|
||||||
"google_storage_project_service_account": dataSourceGoogleStorageProjectServiceAccount(),
|
"google_storage_project_service_account": dataSourceGoogleStorageProjectServiceAccount(),
|
||||||
|
"google_storage_transfer_project_service_account": dataSourceGoogleStorageTransferProjectServiceAccount(),
|
||||||
},
|
},
|
||||||
|
|
||||||
ResourcesMap: ResourceMap(),
|
ResourcesMap: ResourceMap(),
|
||||||
|
|
|
@ -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
|
|
@ -141,6 +141,9 @@
|
||||||
<li<%= sidebar_current("docs-google-datasource-storage-project-service-account") %>>
|
<li<%= sidebar_current("docs-google-datasource-storage-project-service-account") %>>
|
||||||
<a href="/docs/providers/google/d/google_storage_project_service_account.html">google_storage_project_service_account</a>
|
<a href="/docs/providers/google/d/google_storage_project_service_account.html">google_storage_project_service_account</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li<%= sidebar_current("docs-google-datasource-storage-transfer-project-service-account") %>>
|
||||||
|
<a href="/docs/providers/google/d/google_storage_transfer_project_service_account.html">google_storage_transfer_project_service_account</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user