-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathprovider.go.erb
494 lines (462 loc) · 30.4 KB
/
provider.go.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
<% autogen_exception -%>
package google
import (
"encoding/json"
"fmt"
"os"
"github.com/hashicorp/terraform-plugin-sdk/helper/mutexkv"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
googleoauth "golang.org/x/oauth2/google"
)
// Global MutexKV
var mutexKV = mutexkv.NewMutexKV()
// Provider returns a terraform.ResourceProvider.
func Provider() terraform.ResourceProvider {
provider := &schema.Provider{
Schema: map[string]*schema.Schema{
"credentials": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_CREDENTIALS",
"GOOGLE_CLOUD_KEYFILE_JSON",
"GCLOUD_KEYFILE_JSON",
}, nil),
ValidateFunc: validateCredentials,
},
"access_token": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_OAUTH_ACCESS_TOKEN",
}, nil),
ConflictsWith: []string{"credentials"},
},
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_PROJECT",
"GOOGLE_CLOUD_PROJECT",
"GCLOUD_PROJECT",
"CLOUDSDK_CORE_PROJECT",
}, nil),
},
"region": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_REGION",
"GCLOUD_REGION",
"CLOUDSDK_COMPUTE_REGION",
}, nil),
},
"zone": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_ZONE",
"GCLOUD_ZONE",
"CLOUDSDK_COMPUTE_ZONE",
}, nil),
},
"scopes": &schema.Schema{
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"batching": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"send_after": {
Type: schema.TypeString,
Optional: true,
Default: "10s",
ValidateFunc: validateNonNegativeDuration(),
},
"enable_batching": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
},
},
},
"user_project_override": {
Type: schema.TypeBool,
Optional: true,
},
"request_timeout": {
Type: schema.TypeString,
Optional: true,
},
// Generated Products
<% products.each do |product| -%>
"<%= product[:definitions].name.underscore -%>_custom_endpoint": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateCustomEndpoint,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_<%= product[:definitions].name.underscore.upcase -%>_CUSTOM_ENDPOINT",
}, <%= product[:definitions].name -%>DefaultBasePath),
},
<% end -%>
// Handwritten Products / Versioned / Atypical Entries
CloudBillingCustomEndpointEntryKey: CloudBillingCustomEndpointEntry,
ComposerCustomEndpointEntryKey: ComposerCustomEndpointEntry,
ComputeBetaCustomEndpointEntryKey: ComputeBetaCustomEndpointEntry,
ContainerCustomEndpointEntryKey: ContainerCustomEndpointEntry,
ContainerBetaCustomEndpointEntryKey: ContainerBetaCustomEndpointEntry,
DataprocBetaCustomEndpointEntryKey: DataprocBetaCustomEndpointEntry,
DataflowCustomEndpointEntryKey: DataflowCustomEndpointEntry,
DnsBetaCustomEndpointEntryKey: DnsBetaCustomEndpointEntry,
IamCredentialsCustomEndpointEntryKey: IamCredentialsCustomEndpointEntry,
ResourceManagerV2Beta1CustomEndpointEntryKey: ResourceManagerV2Beta1CustomEndpointEntry,
RuntimeConfigCustomEndpointEntryKey: RuntimeConfigCustomEndpointEntry,
IAMCustomEndpointEntryKey: IAMCustomEndpointEntry,
ServiceNetworkingCustomEndpointEntryKey: ServiceNetworkingCustomEndpointEntry,
ServiceUsageCustomEndpointEntryKey: ServiceUsageCustomEndpointEntry,
CloudIoTCustomEndpointEntryKey: CloudIoTCustomEndpointEntry,
StorageTransferCustomEndpointEntryKey: StorageTransferCustomEndpointEntry,
BigtableAdminCustomEndpointEntryKey: BigtableAdminCustomEndpointEntry,
},
DataSourcesMap: map[string]*schema.Resource{
"google_active_folder": dataSourceGoogleActiveFolder(),
"google_billing_account": dataSourceGoogleBillingAccount(),
"google_bigquery_default_service_account": dataSourceGoogleBigqueryDefaultServiceAccount(),
"google_client_config": dataSourceGoogleClientConfig(),
"google_client_openid_userinfo": dataSourceGoogleClientOpenIDUserinfo(),
"google_cloudfunctions_function": dataSourceGoogleCloudFunctionsFunction(),
"google_composer_image_versions": dataSourceGoogleComposerImageVersions(),
"google_compute_address": dataSourceGoogleComputeAddress(),
"google_compute_backend_service": dataSourceGoogleComputeBackendService(),
"google_compute_backend_bucket": dataSourceGoogleComputeBackendBucket(),
"google_compute_default_service_account": dataSourceGoogleComputeDefaultServiceAccount(),
"google_compute_forwarding_rule": dataSourceGoogleComputeForwardingRule(),
"google_compute_global_address": dataSourceGoogleComputeGlobalAddress(),
"google_compute_image": dataSourceGoogleComputeImage(),
"google_compute_instance": dataSourceGoogleComputeInstance(),
"google_compute_instance_serial_port": dataSourceGoogleComputeInstanceSerialPort(),
"google_compute_instance_group": dataSourceGoogleComputeInstanceGroup(),
"google_compute_lb_ip_ranges": dataSourceGoogleComputeLbIpRanges(),
"google_compute_network": dataSourceGoogleComputeNetwork(),
"google_compute_network_endpoint_group": dataSourceGoogleComputeNetworkEndpointGroup(),
"google_compute_node_types": dataSourceGoogleComputeNodeTypes(),
"google_compute_regions": dataSourceGoogleComputeRegions(),
"google_compute_region_instance_group": dataSourceGoogleComputeRegionInstanceGroup(),
<% unless version == 'ga' -%>
"google_compute_resource_policy": dataSourceGoogleComputeResourcePolicy(),
<% end -%>
"google_compute_router": dataSourceGoogleComputeRouter(),
"google_compute_ssl_certificate": dataSourceGoogleComputeSslCertificate(),
"google_compute_ssl_policy": dataSourceGoogleComputeSslPolicy(),
"google_compute_subnetwork": dataSourceGoogleComputeSubnetwork(),
"google_compute_vpn_gateway": dataSourceGoogleComputeVpnGateway(),
"google_compute_zones": dataSourceGoogleComputeZones(),
"google_container_cluster": dataSourceGoogleContainerCluster(),
"google_container_engine_versions": dataSourceGoogleContainerEngineVersions(),
"google_container_registry_image": dataSourceGoogleContainerImage(),
"google_container_registry_repository": dataSourceGoogleContainerRepo(),
"google_dns_keys": dataSourceDNSKeys(),
"google_dns_managed_zone": dataSourceDnsManagedZone(),
"google_iam_policy": dataSourceGoogleIamPolicy(),
"google_iam_role": dataSourceGoogleIamRole(),
"google_iam_testable_permissions": dataSourceGoogleIamTestablePermissions(),
"google_kms_crypto_key": dataSourceGoogleKmsCryptoKey(),
"google_kms_crypto_key_version": dataSourceGoogleKmsCryptoKeyVersion(),
"google_kms_key_ring": dataSourceGoogleKmsKeyRing(),
"google_kms_secret": dataSourceGoogleKmsSecret(),
"google_kms_secret_ciphertext": dataSourceGoogleKmsSecretCiphertext(),
<% unless version == 'ga' -%>
"google_firebase_web_app": dataSourceGoogleFirebaseWebApp(),
"google_firebase_web_app_config": dataSourceGoogleFirebaseWebappConfig(),
<% end -%>
"google_folder": dataSourceGoogleFolder(),
"google_folder_organization_policy": dataSourceGoogleFolderOrganizationPolicy(),
"google_monitoring_notification_channel": dataSourceMonitoringNotificationChannel(),
"google_monitoring_app_engine_service": dataSourceMonitoringServiceAppEngine(),
"google_monitoring_uptime_check_ips": dataSourceGoogleMonitoringUptimeCheckIps(),
"google_netblock_ip_ranges": dataSourceGoogleNetblockIpRanges(),
"google_organization": dataSourceGoogleOrganization(),
"google_project": dataSourceGoogleProject(),
"google_projects": dataSourceGoogleProjects(),
"google_project_organization_policy": dataSourceGoogleProjectOrganizationPolicy(),
"google_secret_manager_secret_version": dataSourceSecretManagerSecretVersion(),
"google_service_account": dataSourceGoogleServiceAccount(),
"google_service_account_access_token": dataSourceGoogleServiceAccountAccessToken(),
"google_service_account_key": dataSourceGoogleServiceAccountKey(),
"google_sql_ca_certs": dataSourceGoogleSQLCaCerts(),
"google_storage_bucket_object": dataSourceGoogleStorageBucketObject(),
"google_storage_object_signed_url": dataSourceGoogleSignedUrl(),
"google_storage_project_service_account": dataSourceGoogleStorageProjectServiceAccount(),
"google_storage_transfer_project_service_account": dataSourceGoogleStorageTransferProjectServiceAccount(),
"google_tpu_tensorflow_versions": dataSourceTpuTensorflowVersions(),
},
ResourcesMap: ResourceMap(),
}
provider.ConfigureFunc = func(d *schema.ResourceData) (interface{}, error) {
terraformVersion := provider.TerraformVersion
if terraformVersion == "" {
// Terraform 0.12 introduced this field to the protocol
// We can therefore assume that if it's missing it's 0.10 or 0.11
terraformVersion = "0.11+compatible"
}
return providerConfigure(d, provider, terraformVersion)
}
return provider
}
<%
resource_count = 0
iam_resource_count = 0
products.each do |product|
product_definition = product[:definitions]
product_definition.objects.reject { |r| r.exclude || r.not_in_version?(product_definition.version_obj_or_closest(version)) }.each do |object|
resource_count += 1 unless object&.exclude_resource
iam_policy = object&.iam_policy
unless iam_policy.nil? || iam_policy.exclude
iam_resource_count += 3
end
end
end
-%>
// Generated resources: <%= resource_count %>
// Generated IAM resources: <%= iam_resource_count %>
// Total generated resources: <%= resource_count + iam_resource_count %>
func ResourceMap() map[string]*schema.Resource {
resourceMap, _ := ResourceMapWithErrors()
return resourceMap
}
func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
return mergeResourceMaps(
map[string]*schema.Resource{
<%
products.each do |product|
product_definition = product[:definitions]
config = product[:overrides]
product_definition.objects.each do |object|
next if object.exclude || object.not_in_version?(product_definition.version_obj_or_closest(version))
tf_product = (config.legacy_name || product_definition.name).underscore
terraform_name = object.legacy_name || "google_#{tf_product}_#{object.name.underscore}"
-%>
<% unless object&.exclude_resource -%>
"<%= terraform_name -%>": resource<%= product_definition.name + object.name -%>(),
<% end -%>
<%
iam_policy = object&.iam_policy
unless iam_policy.nil? || iam_policy.exclude
iam_class_name = product_definition.name + object.name
-%>
"<%= terraform_name -%>_iam_binding": ResourceIamBinding(<%= iam_class_name -%>IamSchema, <%= iam_class_name -%>IamUpdaterProducer, <%= iam_class_name -%>IdParseFunc),
"<%= terraform_name -%>_iam_member": ResourceIamMember(<%= iam_class_name -%>IamSchema, <%= iam_class_name -%>IamUpdaterProducer, <%= iam_class_name -%>IdParseFunc),
"<%= terraform_name -%>_iam_policy": ResourceIamPolicy(<%= iam_class_name -%>IamSchema, <%= iam_class_name -%>IamUpdaterProducer, <%= iam_class_name -%>IdParseFunc),
<%
end # unless iam_policy.nil? || iam_policy.exclude
end # product_definition.objects.each do
end # products.each do
-%>
},
map[string]*schema.Resource{
"google_app_engine_application": resourceAppEngineApplication(),
"google_bigquery_table": resourceBigQueryTable(),
"google_bigtable_gc_policy": resourceBigtableGCPolicy(),
"google_bigtable_instance": resourceBigtableInstance(),
"google_bigtable_instance_iam_binding": ResourceIamBinding(IamBigtableInstanceSchema, NewBigtableInstanceUpdater, BigtableInstanceIdParseFunc),
"google_bigtable_instance_iam_member": ResourceIamMember(IamBigtableInstanceSchema, NewBigtableInstanceUpdater, BigtableInstanceIdParseFunc),
"google_bigtable_instance_iam_policy": ResourceIamPolicy(IamBigtableInstanceSchema, NewBigtableInstanceUpdater, BigtableInstanceIdParseFunc),
"google_bigtable_table": resourceBigtableTable(),
"google_billing_account_iam_binding": ResourceIamBinding(IamBillingAccountSchema, NewBillingAccountIamUpdater, BillingAccountIdParseFunc),
"google_billing_account_iam_member": ResourceIamMember(IamBillingAccountSchema, NewBillingAccountIamUpdater, BillingAccountIdParseFunc),
"google_billing_account_iam_policy": ResourceIamPolicy(IamBillingAccountSchema, NewBillingAccountIamUpdater, BillingAccountIdParseFunc),
"google_cloudfunctions_function": resourceCloudFunctionsFunction(),
"google_cloudiot_registry": resourceCloudIoTRegistry(),
"google_composer_environment": resourceComposerEnvironment(),
"google_compute_attached_disk": resourceComputeAttachedDisk(),
"google_compute_instance": resourceComputeInstance(),
"google_compute_instance_from_template": resourceComputeInstanceFromTemplate(),
"google_compute_instance_group": resourceComputeInstanceGroup(),
"google_compute_instance_group_manager": resourceComputeInstanceGroupManager(),
"google_compute_instance_template": resourceComputeInstanceTemplate(),
"google_compute_network_peering": resourceComputeNetworkPeering(),
"google_compute_project_default_network_tier": resourceComputeProjectDefaultNetworkTier(),
"google_compute_project_metadata": resourceComputeProjectMetadata(),
"google_compute_project_metadata_item": resourceComputeProjectMetadataItem(),
"google_compute_region_instance_group_manager": resourceComputeRegionInstanceGroupManager(),
"google_compute_router_interface": resourceComputeRouterInterface(),
"google_compute_security_policy": resourceComputeSecurityPolicy(),
"google_compute_shared_vpc_host_project": resourceComputeSharedVpcHostProject(),
"google_compute_shared_vpc_service_project": resourceComputeSharedVpcServiceProject(),
"google_compute_target_pool": resourceComputeTargetPool(),
"google_container_cluster": resourceContainerCluster(),
"google_container_node_pool": resourceContainerNodePool(),
"google_container_registry": resourceContainerRegistry(),
"google_dataflow_job": resourceDataflowJob(),
"google_dataproc_cluster": resourceDataprocCluster(),
"google_dataproc_cluster_iam_binding": ResourceIamBinding(IamDataprocClusterSchema, NewDataprocClusterUpdater, DataprocClusterIdParseFunc),
"google_dataproc_cluster_iam_member": ResourceIamMember(IamDataprocClusterSchema, NewDataprocClusterUpdater, DataprocClusterIdParseFunc),
"google_dataproc_cluster_iam_policy": ResourceIamPolicy(IamDataprocClusterSchema, NewDataprocClusterUpdater, DataprocClusterIdParseFunc),
"google_dataproc_job": resourceDataprocJob(),
"google_dataproc_job_iam_binding": ResourceIamBinding(IamDataprocJobSchema, NewDataprocJobUpdater, DataprocJobIdParseFunc),
"google_dataproc_job_iam_member": ResourceIamMember(IamDataprocJobSchema, NewDataprocJobUpdater, DataprocJobIdParseFunc),
"google_dataproc_job_iam_policy": ResourceIamPolicy(IamDataprocJobSchema, NewDataprocJobUpdater, DataprocJobIdParseFunc),
"google_dns_record_set": resourceDnsRecordSet(),
"google_endpoints_service": resourceEndpointsService(),
"google_folder": resourceGoogleFolder(),
"google_folder_iam_binding": ResourceIamBinding(IamFolderSchema, NewFolderIamUpdater, FolderIdParseFunc),
"google_folder_iam_member": ResourceIamMember(IamFolderSchema, NewFolderIamUpdater, FolderIdParseFunc),
"google_folder_iam_policy": ResourceIamPolicy(IamFolderSchema, NewFolderIamUpdater, FolderIdParseFunc),
"google_folder_organization_policy": resourceGoogleFolderOrganizationPolicy(),
"google_healthcare_dataset_iam_binding": ResourceIamBindingWithBatching(IamHealthcareDatasetSchema, NewHealthcareDatasetIamUpdater, DatasetIdParseFunc, IamBatchingEnabled),
"google_healthcare_dataset_iam_member": ResourceIamMemberWithBatching(IamHealthcareDatasetSchema, NewHealthcareDatasetIamUpdater, DatasetIdParseFunc, IamBatchingEnabled),
"google_healthcare_dataset_iam_policy": ResourceIamPolicy(IamHealthcareDatasetSchema, NewHealthcareDatasetIamUpdater, DatasetIdParseFunc),
"google_healthcare_dicom_store_iam_binding": ResourceIamBindingWithBatching(IamHealthcareDicomStoreSchema, NewHealthcareDicomStoreIamUpdater, DicomStoreIdParseFunc, IamBatchingEnabled),
"google_healthcare_dicom_store_iam_member": ResourceIamMemberWithBatching(IamHealthcareDicomStoreSchema, NewHealthcareDicomStoreIamUpdater, DicomStoreIdParseFunc, IamBatchingEnabled),
"google_healthcare_dicom_store_iam_policy": ResourceIamPolicy(IamHealthcareDicomStoreSchema, NewHealthcareDicomStoreIamUpdater, DicomStoreIdParseFunc),
"google_healthcare_fhir_store_iam_binding": ResourceIamBindingWithBatching(IamHealthcareFhirStoreSchema, NewHealthcareFhirStoreIamUpdater, FhirStoreIdParseFunc, IamBatchingEnabled),
"google_healthcare_fhir_store_iam_member": ResourceIamMemberWithBatching(IamHealthcareFhirStoreSchema, NewHealthcareFhirStoreIamUpdater, FhirStoreIdParseFunc, IamBatchingEnabled),
"google_healthcare_fhir_store_iam_policy": ResourceIamPolicy(IamHealthcareFhirStoreSchema, NewHealthcareFhirStoreIamUpdater, FhirStoreIdParseFunc),
"google_healthcare_hl7_v2_store_iam_binding": ResourceIamBindingWithBatching(IamHealthcareHl7V2StoreSchema, NewHealthcareHl7V2StoreIamUpdater, Hl7V2StoreIdParseFunc, IamBatchingEnabled),
"google_healthcare_hl7_v2_store_iam_member": ResourceIamMemberWithBatching(IamHealthcareHl7V2StoreSchema, NewHealthcareHl7V2StoreIamUpdater, Hl7V2StoreIdParseFunc, IamBatchingEnabled),
"google_healthcare_hl7_v2_store_iam_policy": ResourceIamPolicy(IamHealthcareHl7V2StoreSchema, NewHealthcareHl7V2StoreIamUpdater, Hl7V2StoreIdParseFunc),
"google_logging_billing_account_sink": resourceLoggingBillingAccountSink(),
"google_logging_billing_account_exclusion": ResourceLoggingExclusion(BillingAccountLoggingExclusionSchema, NewBillingAccountLoggingExclusionUpdater, billingAccountLoggingExclusionIdParseFunc),
"google_logging_billing_account_bucket_config": ResourceLoggingBillingAccountBucketConfig(),
"google_logging_organization_sink": resourceLoggingOrganizationSink(),
"google_logging_organization_exclusion": ResourceLoggingExclusion(OrganizationLoggingExclusionSchema, NewOrganizationLoggingExclusionUpdater, organizationLoggingExclusionIdParseFunc),
"google_logging_organization_bucket_config": ResourceLoggingOrganizationBucketConfig(),
"google_logging_folder_sink": resourceLoggingFolderSink(),
"google_logging_folder_exclusion": ResourceLoggingExclusion(FolderLoggingExclusionSchema, NewFolderLoggingExclusionUpdater, folderLoggingExclusionIdParseFunc),
"google_logging_folder_bucket_config": ResourceLoggingFolderBucketConfig(),
"google_logging_project_sink": resourceLoggingProjectSink(),
"google_logging_project_exclusion": ResourceLoggingExclusion(ProjectLoggingExclusionSchema, NewProjectLoggingExclusionUpdater, projectLoggingExclusionIdParseFunc),
"google_logging_project_bucket_config": ResourceLoggingProjectBucketConfig(),
"google_kms_key_ring_iam_binding": ResourceIamBinding(IamKmsKeyRingSchema, NewKmsKeyRingIamUpdater, KeyRingIdParseFunc),
"google_kms_key_ring_iam_member": ResourceIamMember(IamKmsKeyRingSchema, NewKmsKeyRingIamUpdater, KeyRingIdParseFunc),
"google_kms_key_ring_iam_policy": ResourceIamPolicy(IamKmsKeyRingSchema, NewKmsKeyRingIamUpdater, KeyRingIdParseFunc),
"google_kms_crypto_key_iam_binding": ResourceIamBinding(IamKmsCryptoKeySchema, NewKmsCryptoKeyIamUpdater, CryptoIdParseFunc),
"google_kms_crypto_key_iam_member": ResourceIamMember(IamKmsCryptoKeySchema, NewKmsCryptoKeyIamUpdater, CryptoIdParseFunc),
"google_kms_crypto_key_iam_policy": ResourceIamPolicy(IamKmsCryptoKeySchema, NewKmsCryptoKeyIamUpdater, CryptoIdParseFunc),
"google_monitoring_dashboard": resourceMonitoringDashboard(),
"google_service_networking_connection": resourceServiceNetworkingConnection(),
"google_spanner_instance_iam_binding": ResourceIamBinding(IamSpannerInstanceSchema, NewSpannerInstanceIamUpdater, SpannerInstanceIdParseFunc),
"google_spanner_instance_iam_member": ResourceIamMember(IamSpannerInstanceSchema, NewSpannerInstanceIamUpdater, SpannerInstanceIdParseFunc),
"google_spanner_instance_iam_policy": ResourceIamPolicy(IamSpannerInstanceSchema, NewSpannerInstanceIamUpdater, SpannerInstanceIdParseFunc),
"google_spanner_database_iam_binding": ResourceIamBinding(IamSpannerDatabaseSchema, NewSpannerDatabaseIamUpdater, SpannerDatabaseIdParseFunc),
"google_spanner_database_iam_member": ResourceIamMember(IamSpannerDatabaseSchema, NewSpannerDatabaseIamUpdater, SpannerDatabaseIdParseFunc),
"google_spanner_database_iam_policy": ResourceIamPolicy(IamSpannerDatabaseSchema, NewSpannerDatabaseIamUpdater, SpannerDatabaseIdParseFunc),
"google_sql_database_instance": resourceSqlDatabaseInstance(),
"google_sql_ssl_cert": resourceSqlSslCert(),
"google_sql_user": resourceSqlUser(),
"google_organization_iam_binding": ResourceIamBinding(IamOrganizationSchema, NewOrganizationIamUpdater, OrgIdParseFunc),
"google_organization_iam_custom_role": resourceGoogleOrganizationIamCustomRole(),
"google_organization_iam_member": ResourceIamMember(IamOrganizationSchema, NewOrganizationIamUpdater, OrgIdParseFunc),
"google_organization_iam_policy": ResourceIamPolicy(IamOrganizationSchema, NewOrganizationIamUpdater, OrgIdParseFunc),
"google_organization_iam_audit_config": ResourceIamAuditConfig(IamOrganizationSchema, NewOrganizationIamUpdater, OrgIdParseFunc),
"google_organization_policy": resourceGoogleOrganizationPolicy(),
"google_project": resourceGoogleProject(),
"google_project_iam_policy": ResourceIamPolicy(IamPolicyProjectSchema, NewProjectIamPolicyUpdater, ProjectIdParseFunc),
"google_project_iam_binding": ResourceIamBindingWithBatching(IamProjectSchema, NewProjectIamUpdater, ProjectIdParseFunc, IamBatchingEnabled),
"google_project_iam_member": ResourceIamMemberWithBatching(IamProjectSchema, NewProjectIamUpdater, ProjectIdParseFunc, IamBatchingEnabled),
"google_project_iam_audit_config": ResourceIamAuditConfigWithBatching(IamProjectSchema, NewProjectIamUpdater, ProjectIdParseFunc, IamBatchingEnabled),
"google_project_service": resourceGoogleProjectService(),
"google_project_iam_custom_role": resourceGoogleProjectIamCustomRole(),
"google_project_organization_policy": resourceGoogleProjectOrganizationPolicy(),
"google_project_usage_export_bucket": resourceProjectUsageBucket(),
"google_pubsub_subscription_iam_binding": ResourceIamBinding(IamPubsubSubscriptionSchema, NewPubsubSubscriptionIamUpdater, PubsubSubscriptionIdParseFunc),
"google_pubsub_subscription_iam_member": ResourceIamMember(IamPubsubSubscriptionSchema, NewPubsubSubscriptionIamUpdater, PubsubSubscriptionIdParseFunc),
"google_pubsub_subscription_iam_policy": ResourceIamPolicy(IamPubsubSubscriptionSchema, NewPubsubSubscriptionIamUpdater, PubsubSubscriptionIdParseFunc),
"google_runtimeconfig_config": resourceRuntimeconfigConfig(),
"google_runtimeconfig_variable": resourceRuntimeconfigVariable(),
"google_service_account": resourceGoogleServiceAccount(),
"google_service_account_iam_binding": ResourceIamBinding(IamServiceAccountSchema, NewServiceAccountIamUpdater, ServiceAccountIdParseFunc),
"google_service_account_iam_member": ResourceIamMember(IamServiceAccountSchema, NewServiceAccountIamUpdater, ServiceAccountIdParseFunc),
"google_service_account_iam_policy": ResourceIamPolicy(IamServiceAccountSchema, NewServiceAccountIamUpdater, ServiceAccountIdParseFunc),
"google_service_account_key": resourceGoogleServiceAccountKey(),
"google_storage_bucket": resourceStorageBucket(),
"google_storage_bucket_acl": resourceStorageBucketAcl(),
"google_storage_bucket_object": resourceStorageBucketObject(),
"google_storage_object_acl": resourceStorageObjectAcl(),
"google_storage_default_object_acl": resourceStorageDefaultObjectAcl(),
"google_storage_notification": resourceStorageNotification(),
"google_storage_transfer_job": resourceStorageTransferJob(),
},
)
}
func providerConfigure(d *schema.ResourceData, p *schema.Provider, terraformVersion string) (interface{}, error) {
config := Config{
Project: d.Get("project").(string),
Region: d.Get("region").(string),
Zone: d.Get("zone").(string),
UserProjectOverride: d.Get("user_project_override").(bool),
terraformVersion: terraformVersion,
}
if v, ok := d.GetOk("request_timeout"); ok {
var err error
config.RequestTimeout, err = time.ParseDuration(v.(string))
if err != nil {
return nil, err
}
}
// Add credential source
if v, ok := d.GetOk("access_token"); ok {
config.AccessToken = v.(string)
} else if v, ok := d.GetOk("credentials"); ok {
config.Credentials = v.(string)
}
scopes := d.Get("scopes").([]interface{})
if len(scopes) > 0 {
config.Scopes = make([]string, len(scopes))
}
for i, scope := range scopes {
config.Scopes[i] = scope.(string)
}
batchCfg, err := expandProviderBatchingConfig(d.Get("batching"))
if err != nil {
return nil, err
}
config.BatchingConfig = batchCfg
// Generated products
<% products.map.each do |product| -%>
config.<%= product[:definitions].name -%>BasePath = d.Get("<%= product[:definitions].name.underscore -%>_custom_endpoint").(string)
<% end -%>
// Handwritten Products / Versioned / Atypical Entries
config.CloudBillingBasePath = d.Get(CloudBillingCustomEndpointEntryKey).(string)
config.ComposerBasePath = d.Get(ComposerCustomEndpointEntryKey).(string)
config.ComputeBetaBasePath = d.Get(ComputeBetaCustomEndpointEntryKey).(string)
config.ContainerBasePath = d.Get(ContainerCustomEndpointEntryKey).(string)
config.ContainerBetaBasePath = d.Get(ContainerBetaCustomEndpointEntryKey).(string)
config.DataprocBetaBasePath = d.Get(DataprocBetaCustomEndpointEntryKey).(string)
config.DataflowBasePath = d.Get(DataflowCustomEndpointEntryKey).(string)
config.DnsBetaBasePath = d.Get(DnsBetaCustomEndpointEntryKey).(string)
config.IamCredentialsBasePath = d.Get(IamCredentialsCustomEndpointEntryKey).(string)
config.ResourceManagerV2Beta1BasePath = d.Get(ResourceManagerV2Beta1CustomEndpointEntryKey).(string)
config.RuntimeConfigBasePath = d.Get(RuntimeConfigCustomEndpointEntryKey).(string)
config.IAMBasePath = d.Get(IAMCustomEndpointEntryKey).(string)
config.ServiceNetworkingBasePath = d.Get(ServiceNetworkingCustomEndpointEntryKey).(string)
config.ServiceUsageBasePath = d.Get(ServiceUsageCustomEndpointEntryKey).(string)
config.CloudIoTBasePath = d.Get(CloudIoTCustomEndpointEntryKey).(string)
config.StorageTransferBasePath = d.Get(StorageTransferCustomEndpointEntryKey).(string)
config.BigtableAdminBasePath = d.Get(BigtableAdminCustomEndpointEntryKey).(string)
if err := config.LoadAndValidate(p.StopContext()); err != nil {
return nil, err
}
return &config, nil
}
func validateCredentials(v interface{}, k string) (warnings []string, errors []error) {
if v == nil || v.(string) == "" {
return
}
creds := v.(string)
// if this is a path and we can stat it, assume it's ok
if _, err := os.Stat(creds); err == nil {
return
}
if _, err := googleoauth.CredentialsFromJSON(context.Background(), []byte(creds)); err != nil {
errors = append(errors,
fmt.Errorf("JSON credentials in %q are not valid: %s", creds, err))
}
return
}