diff --git a/build/terraform b/build/terraform index 188ef94e612b..0b3a6db2fb8b 160000 --- a/build/terraform +++ b/build/terraform @@ -1 +1 @@ -Subproject commit 188ef94e612bb50914c625bbd9c8d3807a0fae16 +Subproject commit 0b3a6db2fb8b3de6ef392c59dd883eaa28909e3b diff --git a/build/terraform-beta b/build/terraform-beta index eb5a485e757b..2f343d3b2c07 160000 --- a/build/terraform-beta +++ b/build/terraform-beta @@ -1 +1 @@ -Subproject commit eb5a485e757bf38d6eaab23ebb1b896c5d9c6f1d +Subproject commit 2f343d3b2c076437d45a988c069849e8082b5e14 diff --git a/third_party/terraform/data_sources/data_source_google_storage_transfer_project_service_account.go b/third_party/terraform/data_sources/data_source_google_storage_transfer_project_service_account.go new file mode 100644 index 000000000000..7f7457162d76 --- /dev/null +++ b/third_party/terraform/data_sources/data_source_google_storage_transfer_project_service_account.go @@ -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 +} diff --git a/third_party/terraform/tests/data_source_google_storage_transfer_project_service_account_test.go b/third_party/terraform/tests/data_source_google_storage_transfer_project_service_account_test.go new file mode 100644 index 000000000000..fe992eabc46b --- /dev/null +++ b/third_party/terraform/tests/data_source_google_storage_transfer_project_service_account_test.go @@ -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" { } +` diff --git a/third_party/terraform/utils/config.go.erb b/third_party/terraform/utils/config.go.erb index 6e72b2f804c9..831fb16f9383 100644 --- a/third_party/terraform/utils/config.go.erb +++ b/third_party/terraform/utils/config.go.erb @@ -51,6 +51,7 @@ import ( "google.golang.org/api/spanner/v1" "google.golang.org/api/sqladmin/v1beta4" "google.golang.org/api/storage/v1" + "google.golang.org/api/storagetransfer/v1" ) // Config is the configuration structure used to instantiate the Google @@ -102,6 +103,7 @@ type Config struct { <% unless version == 'ga' -%> clientServiceNetworking *servicenetworking.APIService <% end -%> + clientStorageTransfer *storagetransfer.Service bigtableClientFactory *BigtableClientFactory } @@ -412,6 +414,13 @@ func (c *Config) loadAndValidate() error { c.clientServiceNetworking.UserAgent = userAgent <% end -%> + 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 } diff --git a/third_party/terraform/utils/provider.go.erb b/third_party/terraform/utils/provider.go.erb index 7e11f912108c..090597fd26f8 100644 --- a/third_party/terraform/utils/provider.go.erb +++ b/third_party/terraform/utils/provider.go.erb @@ -63,44 +63,45 @@ func Provider() terraform.ResourceProvider { }, DataSourcesMap: map[string]*schema.Resource{ - "google_active_folder": dataSourceGoogleActiveFolder(), - "google_billing_account": dataSourceGoogleBillingAccount(), - "google_dns_managed_zone": dataSourceDnsManagedZone(), - "google_client_config": dataSourceGoogleClientConfig(), - "google_cloudfunctions_function": dataSourceGoogleCloudFunctionsFunction(), - "google_compute_address": dataSourceGoogleComputeAddress(), - "google_compute_backend_service": dataSourceGoogleComputeBackendService(), - "google_compute_default_service_account": dataSourceGoogleComputeDefaultServiceAccount(), - "google_compute_forwarding_rule": dataSourceGoogleComputeForwardingRule(), - "google_compute_image": dataSourceGoogleComputeImage(), - "google_compute_instance": dataSourceGoogleComputeInstance(), - "google_compute_global_address": dataSourceGoogleComputeGlobalAddress(), - "google_compute_instance_group": dataSourceGoogleComputeInstanceGroup(), - "google_compute_lb_ip_ranges": dataSourceGoogleComputeLbIpRanges(), - "google_compute_network": dataSourceGoogleComputeNetwork(), - "google_compute_regions": dataSourceGoogleComputeRegions(), - "google_compute_region_instance_group": dataSourceGoogleComputeRegionInstanceGroup(), - "google_compute_subnetwork": dataSourceGoogleComputeSubnetwork(), - "google_compute_zones": dataSourceGoogleComputeZones(), - "google_compute_vpn_gateway": dataSourceGoogleComputeVpnGateway(), - "google_compute_ssl_policy": dataSourceGoogleComputeSslPolicy(), - "google_container_cluster": dataSourceGoogleContainerCluster(), - "google_container_engine_versions": dataSourceGoogleContainerEngineVersions(), - "google_container_registry_repository": dataSourceGoogleContainerRepo(), - "google_container_registry_image": dataSourceGoogleContainerImage(), - "google_iam_policy": dataSourceGoogleIamPolicy(), - "google_iam_role": dataSourceGoogleIamRole(), - "google_kms_secret": dataSourceGoogleKmsSecret(), - "google_folder": dataSourceGoogleFolder(), - "google_netblock_ip_ranges": dataSourceGoogleNetblockIpRanges(), - "google_organization": dataSourceGoogleOrganization(), - "google_project": dataSourceGoogleProject(), - "google_project_services": dataSourceGoogleProjectServices(), - "google_service_account": dataSourceGoogleServiceAccount(), - "google_service_account_key": dataSourceGoogleServiceAccountKey(), - "google_storage_bucket_object": dataSourceGoogleStorageBucketObject(), - "google_storage_object_signed_url": dataSourceGoogleSignedUrl(), - "google_storage_project_service_account": dataSourceGoogleStorageProjectServiceAccount(), + "google_active_folder": dataSourceGoogleActiveFolder(), + "google_billing_account": dataSourceGoogleBillingAccount(), + "google_dns_managed_zone": dataSourceDnsManagedZone(), + "google_client_config": dataSourceGoogleClientConfig(), + "google_cloudfunctions_function": dataSourceGoogleCloudFunctionsFunction(), + "google_compute_address": dataSourceGoogleComputeAddress(), + "google_compute_backend_service": dataSourceGoogleComputeBackendService(), + "google_compute_default_service_account": dataSourceGoogleComputeDefaultServiceAccount(), + "google_compute_forwarding_rule": dataSourceGoogleComputeForwardingRule(), + "google_compute_image": dataSourceGoogleComputeImage(), + "google_compute_instance": dataSourceGoogleComputeInstance(), + "google_compute_global_address": dataSourceGoogleComputeGlobalAddress(), + "google_compute_instance_group": dataSourceGoogleComputeInstanceGroup(), + "google_compute_lb_ip_ranges": dataSourceGoogleComputeLbIpRanges(), + "google_compute_network": dataSourceGoogleComputeNetwork(), + "google_compute_regions": dataSourceGoogleComputeRegions(), + "google_compute_region_instance_group": dataSourceGoogleComputeRegionInstanceGroup(), + "google_compute_subnetwork": dataSourceGoogleComputeSubnetwork(), + "google_compute_zones": dataSourceGoogleComputeZones(), + "google_compute_vpn_gateway": dataSourceGoogleComputeVpnGateway(), + "google_compute_ssl_policy": dataSourceGoogleComputeSslPolicy(), + "google_container_cluster": dataSourceGoogleContainerCluster(), + "google_container_engine_versions": dataSourceGoogleContainerEngineVersions(), + "google_container_registry_repository": dataSourceGoogleContainerRepo(), + "google_container_registry_image": dataSourceGoogleContainerImage(), + "google_iam_policy": dataSourceGoogleIamPolicy(), + "google_iam_role": dataSourceGoogleIamRole(), + "google_kms_secret": dataSourceGoogleKmsSecret(), + "google_folder": dataSourceGoogleFolder(), + "google_netblock_ip_ranges": dataSourceGoogleNetblockIpRanges(), + "google_organization": dataSourceGoogleOrganization(), + "google_project": dataSourceGoogleProject(), + "google_project_services": dataSourceGoogleProjectServices(), + "google_service_account": dataSourceGoogleServiceAccount(), + "google_service_account_key": dataSourceGoogleServiceAccountKey(), + "google_storage_bucket_object": dataSourceGoogleStorageBucketObject(), + "google_storage_object_signed_url": dataSourceGoogleSignedUrl(), + "google_storage_project_service_account": dataSourceGoogleStorageProjectServiceAccount(), + "google_storage_transfer_project_service_account": dataSourceGoogleStorageTransferProjectServiceAccount(), }, ResourcesMap: ResourceMap(), diff --git a/third_party/terraform/website/docs/d/google_storage_transfer_project_service_account.html.markdown b/third_party/terraform/website/docs/d/google_storage_transfer_project_service_account.html.markdown new file mode 100644 index 000000000000..124c9935dde8 --- /dev/null +++ b/third_party/terraform/website/docs/d/google_storage_transfer_project_service_account.html.markdown @@ -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 diff --git a/third_party/terraform/website/google.erb b/third_party/terraform/website/google.erb index ca97403a050b..043629aa083f 100644 --- a/third_party/terraform/website/google.erb +++ b/third_party/terraform/website/google.erb @@ -146,6 +146,9 @@