2014-08-25 18:48:20 +00:00
|
|
|
package google
|
|
|
|
|
|
|
|
import (
|
2015-07-27 19:35:52 +00:00
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
2017-12-08 21:57:55 +00:00
|
|
|
"os"
|
2015-07-27 19:35:52 +00:00
|
|
|
|
2017-01-27 14:32:42 +00:00
|
|
|
"github.com/hashicorp/terraform/helper/mutexkv"
|
2014-08-25 18:48:20 +00:00
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
2014-09-28 18:51:39 +00:00
|
|
|
"github.com/hashicorp/terraform/terraform"
|
2014-08-25 18:48:20 +00:00
|
|
|
)
|
|
|
|
|
2017-01-27 14:32:42 +00:00
|
|
|
// Global MutexKV
|
|
|
|
var mutexKV = mutexkv.NewMutexKV()
|
|
|
|
|
2014-08-25 18:48:20 +00:00
|
|
|
// Provider returns a terraform.ResourceProvider.
|
2014-09-28 18:51:39 +00:00
|
|
|
func Provider() terraform.ResourceProvider {
|
2014-08-25 18:48:20 +00:00
|
|
|
return &schema.Provider{
|
|
|
|
Schema: map[string]*schema.Schema{
|
2015-11-12 22:13:07 +00:00
|
|
|
"credentials": &schema.Schema{
|
2016-04-04 21:56:35 +00:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
|
|
|
|
"GOOGLE_CREDENTIALS",
|
|
|
|
"GOOGLE_CLOUD_KEYFILE_JSON",
|
2016-04-10 23:31:40 +00:00
|
|
|
"GCLOUD_KEYFILE_JSON",
|
2016-04-04 21:56:35 +00:00
|
|
|
}, nil),
|
2015-11-12 22:13:07 +00:00
|
|
|
ValidateFunc: validateCredentials,
|
2015-07-23 20:53:44 +00:00
|
|
|
},
|
|
|
|
|
2014-08-25 19:55:08 +00:00
|
|
|
"project": &schema.Schema{
|
2016-04-10 23:31:40 +00:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
|
|
|
|
"GOOGLE_PROJECT",
|
2018-03-29 18:43:45 +00:00
|
|
|
"GOOGLE_CLOUD_PROJECT",
|
2016-04-10 23:31:40 +00:00
|
|
|
"GCLOUD_PROJECT",
|
|
|
|
"CLOUDSDK_CORE_PROJECT",
|
|
|
|
}, nil),
|
2014-08-25 19:55:08 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
"region": &schema.Schema{
|
2016-04-10 23:31:40 +00:00
|
|
|
Type: schema.TypeString,
|
2018-01-03 22:09:46 +00:00
|
|
|
Optional: true,
|
2016-04-10 23:31:40 +00:00
|
|
|
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
|
|
|
|
"GOOGLE_REGION",
|
|
|
|
"GCLOUD_REGION",
|
|
|
|
"CLOUDSDK_COMPUTE_REGION",
|
|
|
|
}, nil),
|
2014-08-25 19:55:08 +00:00
|
|
|
},
|
2017-12-06 22:30:04 +00:00
|
|
|
|
|
|
|
"zone": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
|
|
|
|
"GOOGLE_ZONE",
|
|
|
|
"GCLOUD_ZONE",
|
|
|
|
"CLOUDSDK_COMPUTE_ZONE",
|
|
|
|
}, nil),
|
|
|
|
},
|
2014-08-25 18:48:20 +00:00
|
|
|
},
|
|
|
|
|
2016-08-10 04:44:53 +00:00
|
|
|
DataSourcesMap: map[string]*schema.Resource{
|
2018-02-21 21:37:23 +00:00
|
|
|
"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(),
|
2018-09-18 16:02:48 +00:00
|
|
|
"google_compute_backend_service": dataSourceGoogleComputeBackendService(),
|
2018-03-12 16:41:15 +00:00
|
|
|
"google_compute_default_service_account": dataSourceGoogleComputeDefaultServiceAccount(),
|
2018-09-18 16:02:48 +00:00
|
|
|
"google_compute_forwarding_rule": dataSourceGoogleComputeForwardingRule(),
|
2018-02-21 21:37:23 +00:00
|
|
|
"google_compute_image": dataSourceGoogleComputeImage(),
|
2018-09-18 16:02:48 +00:00
|
|
|
"google_compute_instance": dataSourceGoogleComputeInstance(),
|
|
|
|
"google_compute_instance_group": dataSourceGoogleComputeInstanceGroup(),
|
2018-02-21 21:37:23 +00:00
|
|
|
"google_compute_global_address": dataSourceGoogleComputeGlobalAddress(),
|
|
|
|
"google_compute_lb_ip_ranges": dataSourceGoogleComputeLbIpRanges(),
|
|
|
|
"google_compute_network": dataSourceGoogleComputeNetwork(),
|
2018-09-18 16:02:48 +00:00
|
|
|
"google_compute_regions": dataSourceGoogleComputeRegions(),
|
|
|
|
"google_compute_region_instance_group": dataSourceGoogleComputeRegionInstanceGroup(),
|
2018-02-21 21:37:23 +00:00
|
|
|
"google_compute_subnetwork": dataSourceGoogleComputeSubnetwork(),
|
|
|
|
"google_compute_zones": dataSourceGoogleComputeZones(),
|
|
|
|
"google_compute_vpn_gateway": dataSourceGoogleComputeVpnGateway(),
|
2018-03-26 23:53:35 +00:00
|
|
|
"google_compute_ssl_policy": dataSourceGoogleComputeSslPolicy(),
|
2018-02-21 21:37:23 +00:00
|
|
|
"google_container_cluster": dataSourceGoogleContainerCluster(),
|
|
|
|
"google_container_engine_versions": dataSourceGoogleContainerEngineVersions(),
|
|
|
|
"google_container_registry_repository": dataSourceGoogleContainerRepo(),
|
|
|
|
"google_container_registry_image": dataSourceGoogleContainerImage(),
|
|
|
|
"google_iam_policy": dataSourceGoogleIamPolicy(),
|
2018-11-19 22:34:49 +00:00
|
|
|
"google_iam_role": dataSourceGoogleIamRole(),
|
2018-02-21 21:37:23 +00:00
|
|
|
"google_kms_secret": dataSourceGoogleKmsSecret(),
|
2018-04-05 23:59:47 +00:00
|
|
|
"google_folder": dataSourceGoogleFolder(),
|
2018-06-04 23:31:09 +00:00
|
|
|
"google_netblock_ip_ranges": dataSourceGoogleNetblockIpRanges(),
|
2018-02-21 21:37:23 +00:00
|
|
|
"google_organization": dataSourceGoogleOrganization(),
|
2018-09-18 16:02:48 +00:00
|
|
|
"google_project": dataSourceGoogleProject(),
|
|
|
|
"google_project_services": dataSourceGoogleProjectServices(),
|
2018-06-01 00:31:45 +00:00
|
|
|
"google_service_account": dataSourceGoogleServiceAccount(),
|
|
|
|
"google_service_account_key": dataSourceGoogleServiceAccountKey(),
|
2018-02-21 21:37:23 +00:00
|
|
|
"google_storage_object_signed_url": dataSourceGoogleSignedUrl(),
|
|
|
|
"google_storage_project_service_account": dataSourceGoogleStorageProjectServiceAccount(),
|
2016-08-10 04:44:53 +00:00
|
|
|
},
|
|
|
|
|
2018-04-30 21:30:43 +00:00
|
|
|
ResourcesMap: mergeResourceMaps(
|
|
|
|
GeneratedComputeResourcesMap,
|
2018-11-16 22:53:46 +00:00
|
|
|
GeneratedDnsResourcesMap,
|
2018-05-21 19:01:06 +00:00
|
|
|
GeneratedRedisResourcesMap,
|
2018-05-17 23:33:30 +00:00
|
|
|
GeneratedResourceManagerResourcesMap,
|
2018-10-17 22:38:59 +00:00
|
|
|
GeneratedStorageResourcesMap,
|
2018-10-03 23:09:24 +00:00
|
|
|
GeneratedMonitoringResourcesMap,
|
2018-04-30 21:30:43 +00:00
|
|
|
map[string]*schema.Resource{
|
Add google_app_engine_application resource.
Deprecate the app_engine sub-block of google_project, and create a
google_app_engine_application resource instead. Also, add some tests for
its behaviour, as well as some documentation for it.
Note that this is largely an implementation of the ideas discussed in
#2118, except we're not using CustomizeDiff to reject deletions without
our special flag set, because CustomizeDiff apparently doesn't run on
Delete. Who knew? This leaves us rejecting the deletion at apply time,
which is less than ideal, but the only other option I see is to silently
not delete the resource, and that's... not ideal, either.
This also stops the app_engine sub-block on google_project from forcing
new when it's removed, and sets it to computed, so users can safely move
from using the sub-block to using the resource without state surgery or
deleting their entire project. This does mean it's impossible to delete
an App Engine application from a sub-block now, but seeing as that was
the same situation before, and we just papered over it by making the
project recreate itself in that situation, and people Were Not Fans of
that, I'm considering that an acceptable casualty.
2018-10-02 09:59:17 +00:00
|
|
|
"google_app_engine_application": resourceAppEngineApplication(),
|
2018-04-30 21:30:43 +00:00
|
|
|
"google_bigquery_dataset": resourceBigQueryDataset(),
|
|
|
|
"google_bigquery_table": resourceBigQueryTable(),
|
|
|
|
"google_bigtable_instance": resourceBigtableInstance(),
|
|
|
|
"google_bigtable_table": resourceBigtableTable(),
|
2018-11-19 22:17:59 +00:00
|
|
|
"google_billing_account_iam_binding": ResourceIamBindingWithImport(IamBillingAccountSchema, NewBillingAccountIamUpdater, BillingAccountIdParseFunc),
|
|
|
|
"google_billing_account_iam_member": ResourceIamMemberWithImport(IamBillingAccountSchema, NewBillingAccountIamUpdater, BillingAccountIdParseFunc),
|
|
|
|
"google_billing_account_iam_policy": ResourceIamPolicyWithImport(IamBillingAccountSchema, NewBillingAccountIamUpdater, BillingAccountIdParseFunc),
|
2018-05-07 19:53:34 +00:00
|
|
|
"google_cloudbuild_trigger": resourceCloudBuildTrigger(),
|
2018-04-30 21:30:43 +00:00
|
|
|
"google_cloudfunctions_function": resourceCloudFunctionsFunction(),
|
|
|
|
"google_cloudiot_registry": resourceCloudIoTRegistry(),
|
2018-09-11 20:13:11 +00:00
|
|
|
"google_composer_environment": resourceComposerEnvironment(),
|
2018-04-30 21:30:43 +00:00
|
|
|
"google_compute_autoscaler": resourceComputeAutoscaler(),
|
|
|
|
"google_compute_address": resourceComputeAddress(),
|
2018-09-11 20:08:14 +00:00
|
|
|
"google_compute_attached_disk": resourceComputeAttachedDisk(),
|
2018-04-30 21:30:43 +00:00
|
|
|
"google_compute_backend_service": resourceComputeBackendService(),
|
|
|
|
"google_compute_disk": resourceComputeDisk(),
|
2018-12-14 01:51:11 +00:00
|
|
|
"google_compute_snapshot": resourceComputeSnapshot(),
|
2018-04-30 21:30:43 +00:00
|
|
|
"google_compute_firewall": resourceComputeFirewall(),
|
|
|
|
"google_compute_forwarding_rule": resourceComputeForwardingRule(),
|
|
|
|
"google_compute_global_forwarding_rule": resourceComputeGlobalForwardingRule(),
|
|
|
|
"google_compute_health_check": resourceComputeHealthCheck(),
|
|
|
|
"google_compute_image": resourceComputeImage(),
|
|
|
|
"google_compute_instance": resourceComputeInstance(),
|
2018-06-28 23:09:23 +00:00
|
|
|
"google_compute_instance_from_template": resourceComputeInstanceFromTemplate(),
|
2018-04-30 21:30:43 +00:00
|
|
|
"google_compute_instance_group": resourceComputeInstanceGroup(),
|
|
|
|
"google_compute_instance_group_manager": resourceComputeInstanceGroupManager(),
|
|
|
|
"google_compute_instance_template": resourceComputeInstanceTemplate(),
|
|
|
|
"google_compute_network": resourceComputeNetwork(),
|
|
|
|
"google_compute_network_peering": resourceComputeNetworkPeering(),
|
|
|
|
"google_compute_project_metadata": resourceComputeProjectMetadata(),
|
|
|
|
"google_compute_project_metadata_item": resourceComputeProjectMetadataItem(),
|
|
|
|
"google_compute_region_autoscaler": resourceComputeRegionAutoscaler(),
|
|
|
|
"google_compute_region_backend_service": resourceComputeRegionBackendService(),
|
|
|
|
"google_compute_region_instance_group_manager": resourceComputeRegionInstanceGroupManager(),
|
|
|
|
"google_compute_route": resourceComputeRoute(),
|
|
|
|
"google_compute_router": resourceComputeRouter(),
|
|
|
|
"google_compute_router_interface": resourceComputeRouterInterface(),
|
|
|
|
"google_compute_router_peer": resourceComputeRouterPeer(),
|
|
|
|
"google_compute_security_policy": resourceComputeSecurityPolicy(),
|
|
|
|
"google_compute_shared_vpc_host_project": resourceComputeSharedVpcHostProject(),
|
|
|
|
"google_compute_shared_vpc_service_project": resourceComputeSharedVpcServiceProject(),
|
|
|
|
"google_compute_ssl_certificate": resourceComputeSslCertificate(),
|
|
|
|
"google_compute_ssl_policy": resourceComputeSslPolicy(),
|
|
|
|
"google_compute_subnetwork": resourceComputeSubnetwork(),
|
|
|
|
"google_compute_target_https_proxy": resourceComputeTargetHttpsProxy(),
|
|
|
|
"google_compute_target_tcp_proxy": resourceComputeTargetTcpProxy(),
|
|
|
|
"google_compute_target_pool": resourceComputeTargetPool(),
|
|
|
|
"google_compute_url_map": resourceComputeUrlMap(),
|
|
|
|
"google_compute_vpn_gateway": resourceComputeVpnGateway(),
|
|
|
|
"google_compute_vpn_tunnel": resourceComputeVpnTunnel(),
|
|
|
|
"google_container_cluster": resourceContainerCluster(),
|
|
|
|
"google_container_node_pool": resourceContainerNodePool(),
|
|
|
|
"google_dataflow_job": resourceDataflowJob(),
|
|
|
|
"google_dataproc_cluster": resourceDataprocCluster(),
|
|
|
|
"google_dataproc_job": resourceDataprocJob(),
|
|
|
|
"google_dns_record_set": resourceDnsRecordSet(),
|
|
|
|
"google_endpoints_service": resourceEndpointsService(),
|
|
|
|
"google_folder": resourceGoogleFolder(),
|
|
|
|
"google_folder_iam_binding": ResourceIamBindingWithImport(IamFolderSchema, NewFolderIamUpdater, FolderIdParseFunc),
|
|
|
|
"google_folder_iam_member": ResourceIamMemberWithImport(IamFolderSchema, NewFolderIamUpdater, FolderIdParseFunc),
|
|
|
|
"google_folder_iam_policy": ResourceIamPolicyWithImport(IamFolderSchema, NewFolderIamUpdater, FolderIdParseFunc),
|
|
|
|
"google_folder_organization_policy": resourceGoogleFolderOrganizationPolicy(),
|
|
|
|
"google_logging_billing_account_sink": resourceLoggingBillingAccountSink(),
|
2018-05-18 15:55:04 +00:00
|
|
|
"google_logging_billing_account_exclusion": ResourceLoggingExclusion(BillingAccountLoggingExclusionSchema, NewBillingAccountLoggingExclusionUpdater, billingAccountLoggingExclusionIdParseFunc),
|
2018-04-30 21:30:43 +00:00
|
|
|
"google_logging_organization_sink": resourceLoggingOrganizationSink(),
|
2018-05-18 15:55:04 +00:00
|
|
|
"google_logging_organization_exclusion": ResourceLoggingExclusion(OrganizationLoggingExclusionSchema, NewOrganizationLoggingExclusionUpdater, organizationLoggingExclusionIdParseFunc),
|
2018-04-30 21:30:43 +00:00
|
|
|
"google_logging_folder_sink": resourceLoggingFolderSink(),
|
2018-05-18 15:55:04 +00:00
|
|
|
"google_logging_folder_exclusion": ResourceLoggingExclusion(FolderLoggingExclusionSchema, NewFolderLoggingExclusionUpdater, folderLoggingExclusionIdParseFunc),
|
2018-04-30 21:30:43 +00:00
|
|
|
"google_logging_project_sink": resourceLoggingProjectSink(),
|
2018-05-18 15:55:04 +00:00
|
|
|
"google_logging_project_exclusion": ResourceLoggingExclusion(ProjectLoggingExclusionSchema, NewProjectLoggingExclusionUpdater, projectLoggingExclusionIdParseFunc),
|
2018-04-30 21:30:43 +00:00
|
|
|
"google_kms_key_ring": resourceKmsKeyRing(),
|
|
|
|
"google_kms_key_ring_iam_binding": ResourceIamBindingWithImport(IamKmsKeyRingSchema, NewKmsKeyRingIamUpdater, KeyRingIdParseFunc),
|
|
|
|
"google_kms_key_ring_iam_member": ResourceIamMemberWithImport(IamKmsKeyRingSchema, NewKmsKeyRingIamUpdater, KeyRingIdParseFunc),
|
|
|
|
"google_kms_key_ring_iam_policy": ResourceIamPolicyWithImport(IamKmsKeyRingSchema, NewKmsKeyRingIamUpdater, KeyRingIdParseFunc),
|
|
|
|
"google_kms_crypto_key": resourceKmsCryptoKey(),
|
|
|
|
"google_kms_crypto_key_iam_binding": ResourceIamBindingWithImport(IamKmsCryptoKeySchema, NewKmsCryptoKeyIamUpdater, CryptoIdParseFunc),
|
|
|
|
"google_kms_crypto_key_iam_member": ResourceIamMemberWithImport(IamKmsCryptoKeySchema, NewKmsCryptoKeyIamUpdater, CryptoIdParseFunc),
|
|
|
|
"google_sourcerepo_repository": resourceSourceRepoRepository(),
|
|
|
|
"google_spanner_instance": resourceSpannerInstance(),
|
2018-05-02 17:37:25 +00:00
|
|
|
"google_spanner_instance_iam_binding": ResourceIamBindingWithImport(IamSpannerInstanceSchema, NewSpannerInstanceIamUpdater, SpannerInstanceIdParseFunc),
|
|
|
|
"google_spanner_instance_iam_member": ResourceIamMemberWithImport(IamSpannerInstanceSchema, NewSpannerInstanceIamUpdater, SpannerInstanceIdParseFunc),
|
|
|
|
"google_spanner_instance_iam_policy": ResourceIamPolicyWithImport(IamSpannerInstanceSchema, NewSpannerInstanceIamUpdater, SpannerInstanceIdParseFunc),
|
2018-04-30 21:30:43 +00:00
|
|
|
"google_spanner_database": resourceSpannerDatabase(),
|
2018-05-02 17:44:39 +00:00
|
|
|
"google_spanner_database_iam_binding": ResourceIamBindingWithImport(IamSpannerDatabaseSchema, NewSpannerDatabaseIamUpdater, SpannerDatabaseIdParseFunc),
|
|
|
|
"google_spanner_database_iam_member": ResourceIamMemberWithImport(IamSpannerDatabaseSchema, NewSpannerDatabaseIamUpdater, SpannerDatabaseIdParseFunc),
|
|
|
|
"google_spanner_database_iam_policy": ResourceIamPolicyWithImport(IamSpannerDatabaseSchema, NewSpannerDatabaseIamUpdater, SpannerDatabaseIdParseFunc),
|
2018-04-30 21:30:43 +00:00
|
|
|
"google_sql_database": resourceSqlDatabase(),
|
|
|
|
"google_sql_database_instance": resourceSqlDatabaseInstance(),
|
2018-11-14 18:59:15 +00:00
|
|
|
"google_sql_ssl_cert": resourceSqlSslCert(),
|
2018-04-30 21:30:43 +00:00
|
|
|
"google_sql_user": resourceSqlUser(),
|
|
|
|
"google_organization_iam_binding": ResourceIamBindingWithImport(IamOrganizationSchema, NewOrganizationIamUpdater, OrgIdParseFunc),
|
|
|
|
"google_organization_iam_custom_role": resourceGoogleOrganizationIamCustomRole(),
|
|
|
|
"google_organization_iam_member": ResourceIamMemberWithImport(IamOrganizationSchema, NewOrganizationIamUpdater, OrgIdParseFunc),
|
|
|
|
"google_organization_iam_policy": ResourceIamPolicyWithImport(IamOrganizationSchema, NewOrganizationIamUpdater, OrgIdParseFunc),
|
|
|
|
"google_organization_policy": resourceGoogleOrganizationPolicy(),
|
|
|
|
"google_project": resourceGoogleProject(),
|
|
|
|
"google_project_iam_policy": resourceGoogleProjectIamPolicy(),
|
|
|
|
"google_project_iam_binding": ResourceIamBindingWithImport(IamProjectSchema, NewProjectIamUpdater, ProjectIdParseFunc),
|
|
|
|
"google_project_iam_member": ResourceIamMemberWithImport(IamProjectSchema, NewProjectIamUpdater, ProjectIdParseFunc),
|
|
|
|
"google_project_service": resourceGoogleProjectService(),
|
|
|
|
"google_project_iam_custom_role": resourceGoogleProjectIamCustomRole(),
|
|
|
|
"google_project_organization_policy": resourceGoogleProjectOrganizationPolicy(),
|
|
|
|
"google_project_usage_export_bucket": resourceProjectUsageBucket(),
|
|
|
|
"google_project_services": resourceGoogleProjectServices(),
|
|
|
|
"google_pubsub_topic": resourcePubsubTopic(),
|
|
|
|
"google_pubsub_topic_iam_binding": ResourceIamBindingWithImport(IamPubsubTopicSchema, NewPubsubTopicIamUpdater, PubsubTopicIdParseFunc),
|
|
|
|
"google_pubsub_topic_iam_member": ResourceIamMemberWithImport(IamPubsubTopicSchema, NewPubsubTopicIamUpdater, PubsubTopicIdParseFunc),
|
|
|
|
"google_pubsub_topic_iam_policy": ResourceIamPolicyWithImport(IamPubsubTopicSchema, NewPubsubTopicIamUpdater, PubsubTopicIdParseFunc),
|
|
|
|
"google_pubsub_subscription": resourcePubsubSubscription(),
|
|
|
|
"google_pubsub_subscription_iam_binding": ResourceIamBindingWithImport(IamPubsubSubscriptionSchema, NewPubsubSubscriptionIamUpdater, PubsubSubscriptionIdParseFunc),
|
|
|
|
"google_pubsub_subscription_iam_member": ResourceIamMemberWithImport(IamPubsubSubscriptionSchema, NewPubsubSubscriptionIamUpdater, PubsubSubscriptionIdParseFunc),
|
|
|
|
"google_pubsub_subscription_iam_policy": ResourceIamPolicyWithImport(IamPubsubSubscriptionSchema, NewPubsubSubscriptionIamUpdater, PubsubSubscriptionIdParseFunc),
|
|
|
|
"google_runtimeconfig_config": resourceRuntimeconfigConfig(),
|
|
|
|
"google_runtimeconfig_variable": resourceRuntimeconfigVariable(),
|
|
|
|
"google_service_account": resourceGoogleServiceAccount(),
|
|
|
|
"google_service_account_iam_binding": ResourceIamBindingWithImport(IamServiceAccountSchema, NewServiceAccountIamUpdater, ServiceAccountIdParseFunc),
|
|
|
|
"google_service_account_iam_member": ResourceIamMemberWithImport(IamServiceAccountSchema, NewServiceAccountIamUpdater, ServiceAccountIdParseFunc),
|
|
|
|
"google_service_account_iam_policy": ResourceIamPolicyWithImport(IamServiceAccountSchema, NewServiceAccountIamUpdater, ServiceAccountIdParseFunc),
|
|
|
|
"google_service_account_key": resourceGoogleServiceAccountKey(),
|
|
|
|
"google_storage_bucket": resourceStorageBucket(),
|
|
|
|
"google_storage_bucket_acl": resourceStorageBucketAcl(),
|
|
|
|
// Legacy roles such as roles/storage.legacyBucketReader are automatically added
|
|
|
|
// when creating a bucket. For this reason, it is better not to add the authoritative
|
|
|
|
// google_storage_bucket_iam_policy resource.
|
|
|
|
"google_storage_bucket_iam_binding": ResourceIamBinding(IamStorageBucketSchema, NewStorageBucketIamUpdater),
|
|
|
|
"google_storage_bucket_iam_member": ResourceIamMember(IamStorageBucketSchema, NewStorageBucketIamUpdater),
|
2018-05-08 21:00:48 +00:00
|
|
|
"google_storage_bucket_iam_policy": ResourceIamPolicy(IamStorageBucketSchema, NewStorageBucketIamUpdater),
|
2018-04-30 21:30:43 +00:00
|
|
|
"google_storage_bucket_object": resourceStorageBucketObject(),
|
|
|
|
"google_storage_object_acl": resourceStorageObjectAcl(),
|
|
|
|
"google_storage_default_object_acl": resourceStorageDefaultObjectAcl(),
|
|
|
|
"google_storage_notification": resourceStorageNotification(),
|
|
|
|
},
|
|
|
|
),
|
2014-08-25 18:48:20 +00:00
|
|
|
|
|
|
|
ConfigureFunc: providerConfigure,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
2015-11-12 22:13:07 +00:00
|
|
|
credentials := d.Get("credentials").(string)
|
2014-08-25 18:48:20 +00:00
|
|
|
config := Config{
|
2015-11-12 22:13:07 +00:00
|
|
|
Credentials: credentials,
|
2015-07-27 19:35:52 +00:00
|
|
|
Project: d.Get("project").(string),
|
|
|
|
Region: d.Get("region").(string),
|
2017-12-06 22:30:04 +00:00
|
|
|
Zone: d.Get("zone").(string),
|
2014-08-25 18:48:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := config.loadAndValidate(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2014-08-25 19:55:08 +00:00
|
|
|
return &config, nil
|
2014-08-25 18:48:20 +00:00
|
|
|
}
|
2015-07-27 19:35:52 +00:00
|
|
|
|
2015-11-12 22:13:07 +00:00
|
|
|
func validateCredentials(v interface{}, k string) (warnings []string, errors []error) {
|
|
|
|
if v == nil || v.(string) == "" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
creds := v.(string)
|
2017-12-08 21:57:55 +00:00
|
|
|
// if this is a path and we can stat it, assume it's ok
|
|
|
|
if _, err := os.Stat(creds); err == nil {
|
|
|
|
return
|
|
|
|
}
|
2015-11-12 22:13:07 +00:00
|
|
|
var account accountFile
|
|
|
|
if err := json.Unmarshal([]byte(creds), &account); err != nil {
|
2015-07-27 21:07:38 +00:00
|
|
|
errors = append(errors,
|
2015-11-12 22:13:07 +00:00
|
|
|
fmt.Errorf("credentials are not valid JSON '%s': %s", creds, err))
|
2015-07-27 19:35:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|