@@ -140,245 +140,6 @@ resource "google_colab_notebook_execution" "notebook-execution" {
140
140
` , context )
141
141
}
142
142
143
- func TestAccColabNotebookExecution_colabNotebookExecutionFullExample (t * testing.T ) {
144
- t .Parallel ()
145
-
146
- context := map [string ]interface {}{
147
- "project_id" : envvar .GetTestProjectFromEnv (),
148
- "service_account" : envvar .GetTestServiceAccountFromEnv (t ),
149
- "random_suffix" : acctest .RandString (t , 10 ),
150
- }
151
-
152
- acctest .VcrTest (t , resource.TestCase {
153
- PreCheck : func () { acctest .AccTestPreCheck (t ) },
154
- ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
155
- CheckDestroy : testAccCheckColabNotebookExecutionDestroyProducer (t ),
156
- Steps : []resource.TestStep {
157
- {
158
- Config : testAccColabNotebookExecution_colabNotebookExecutionFullExample (context ),
159
- },
160
- {
161
- ResourceName : "google_colab_notebook_execution.notebook-execution" ,
162
- ImportState : true ,
163
- ImportStateVerify : true ,
164
- ImportStateVerifyIgnore : []string {"direct_notebook_source" , "location" , "notebook_execution_job_id" },
165
- },
166
- },
167
- })
168
- }
169
-
170
- func testAccColabNotebookExecution_colabNotebookExecutionFullExample (context map [string ]interface {}) string {
171
- return acctest .Nprintf (`
172
- resource "google_colab_runtime_template" "my_runtime_template" {
173
- name = "tf-test-runtime-template-name%{random_suffix}"
174
- display_name = "Runtime template"
175
- location = "us-central1"
176
-
177
- machine_spec {
178
- machine_type = "e2-standard-4"
179
- }
180
-
181
- network_spec {
182
- enable_internet_access = true
183
- }
184
- }
185
-
186
- resource "google_storage_bucket" "output_bucket" {
187
- name = "tf_test_my_bucket%{random_suffix}"
188
- location = "US"
189
- force_destroy = true
190
- uniform_bucket_level_access = true
191
- }
192
-
193
- resource "google_storage_bucket_object" "notebook" {
194
- name = "hello_world.ipynb"
195
- bucket = google_storage_bucket.output_bucket.name
196
- content = <<EOF
197
- {
198
- "cells": [
199
- {
200
- "cell_type": "code",
201
- "execution_count": null,
202
- "metadata": {},
203
- "outputs": [],
204
- "source": [
205
- "print(\"Hello, World!\")"
206
- ]
207
- }
208
- ],
209
- "metadata": {
210
- "kernelspec": {
211
- "display_name": "Python 3",
212
- "language": "python",
213
- "name": "python3"
214
- },
215
- "language_info": {
216
- "codemirror_mode": {
217
- "name": "ipython",
218
- "version": 3
219
- },
220
- "file_extension": ".py",
221
- "mimetype": "text/x-python",
222
- "name": "python",
223
- "nbconvert_exporter": "python",
224
- "pygments_lexer": "ipython3",
225
- "version": "3.8.5"
226
- }
227
- },
228
- "nbformat": 4,
229
- "nbformat_minor": 4
230
- }
231
- EOF
232
- }
233
-
234
- resource "google_colab_notebook_execution" "notebook-execution" {
235
- notebook_execution_job_id = "tf-test-colab-notebook-execution%{random_suffix}"
236
- display_name = "Notebook execution full"
237
- location = "us-central1"
238
-
239
- execution_timeout = "86400s"
240
- gcs_notebook_source {
241
- uri = "gs://${google_storage_bucket_object.notebook.bucket}/${google_storage_bucket_object.notebook.name}"
242
- generation = google_storage_bucket_object.notebook.generation
243
- }
244
-
245
- service_account = "%{service_account}"
246
-
247
- gcs_output_uri = "gs://${google_storage_bucket.output_bucket.name}"
248
- notebook_runtime_template_resource_name = "projects/${google_colab_runtime_template.my_runtime_template.project}/locations/${google_colab_runtime_template.my_runtime_template.location}/notebookRuntimeTemplates/${google_colab_runtime_template.my_runtime_template.name}"
249
-
250
- depends_on = [
251
- google_storage_bucket_object.notebook,
252
- google_storage_bucket.output_bucket,
253
- google_colab_runtime_template.my_runtime_template,
254
- ]
255
-
256
- }
257
- ` , context )
258
- }
259
-
260
- func TestAccColabNotebookExecution_colabNotebookExecutionDataformExample (t * testing.T ) {
261
- t .Parallel ()
262
- acctest .BootstrapIamMembers (t , []acctest.IamMember {
263
- {
264
- Member : "serviceAccount:service-{project_number}@gcp-sa-dataform.iam.gserviceaccount.com" ,
265
- Role : "roles/cloudkms.cryptoKeyEncrypterDecrypter" ,
266
- },
267
- })
268
-
269
- context := map [string ]interface {}{
270
- "project_id" : envvar .GetTestProjectFromEnv (),
271
- "service_account" : envvar .GetTestServiceAccountFromEnv (t ),
272
- "key_name" : acctest .BootstrapKMSKeyInLocation (t , "us-central1" ).CryptoKey .Name ,
273
- "random_suffix" : acctest .RandString (t , 10 ),
274
- }
275
-
276
- acctest .VcrTest (t , resource.TestCase {
277
- PreCheck : func () { acctest .AccTestPreCheck (t ) },
278
- ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
279
- CheckDestroy : testAccCheckColabNotebookExecutionDestroyProducer (t ),
280
- Steps : []resource.TestStep {
281
- {
282
- Config : testAccColabNotebookExecution_colabNotebookExecutionDataformExample (context ),
283
- },
284
- {
285
- ResourceName : "google_colab_notebook_execution.notebook-execution" ,
286
- ImportState : true ,
287
- ImportStateVerify : true ,
288
- ImportStateVerifyIgnore : []string {"direct_notebook_source" , "location" , "notebook_execution_job_id" },
289
- },
290
- },
291
- })
292
- }
293
-
294
- func testAccColabNotebookExecution_colabNotebookExecutionDataformExample (context map [string ]interface {}) string {
295
- return acctest .Nprintf (`
296
- resource "google_colab_runtime_template" "my_runtime_template" {
297
- name = "tf-test-runtime-template-name%{random_suffix}"
298
- display_name = "Runtime template"
299
- location = "us-central1"
300
-
301
- machine_spec {
302
- machine_type = "e2-standard-4"
303
- }
304
-
305
- network_spec {
306
- enable_internet_access = true
307
- }
308
- }
309
-
310
- resource "google_storage_bucket" "output_bucket" {
311
- name = "tf_test_my_bucket%{random_suffix}"
312
- location = "US"
313
- force_destroy = true
314
- uniform_bucket_level_access = true
315
- }
316
-
317
- resource "google_secret_manager_secret" "secret" {
318
- secret_id = "secret%{random_suffix}"
319
-
320
- replication {
321
- auto {}
322
- }
323
- }
324
-
325
- resource "google_secret_manager_secret_version" "secret_version" {
326
- secret = google_secret_manager_secret.secret.id
327
-
328
- secret_data = "secret-data"
329
- }
330
-
331
- resource "google_dataform_repository" "dataform_repository" {
332
- name = "tf-test-dataform-repository%{random_suffix}"
333
- display_name = "dataform_repository"
334
- npmrc_environment_variables_secret_version = google_secret_manager_secret_version.secret_version.id
335
- kms_key_name = "%{key_name}"
336
-
337
- labels = {
338
- label_foo1 = "label-bar1"
339
- }
340
-
341
- git_remote_settings {
342
- url = "https://github.com/OWNER/REPOSITORY.git"
343
- default_branch = "main"
344
- authentication_token_secret_version = google_secret_manager_secret_version.secret_version.id
345
- }
346
-
347
- workspace_compilation_overrides {
348
- default_database = "database"
349
- schema_suffix = "_suffix"
350
- table_prefix = "prefix_"
351
- }
352
-
353
- }
354
-
355
- resource "google_colab_notebook_execution" "notebook-execution" {
356
- display_name = "Notebook execution Dataform"
357
- location = "us-central1"
358
-
359
- dataform_repository_source {
360
- commit_sha = "randomsha123"
361
- dataform_repository_resource_name = "projects/${google_colab_runtime_template.my_runtime_template.project}/locations/${google_colab_runtime_template.my_runtime_template.location}/repositories/${google_dataform_repository.dataform_repository.name}"
362
- }
363
-
364
- notebook_runtime_template_resource_name = "projects/${google_colab_runtime_template.my_runtime_template.project}/locations/${google_colab_runtime_template.my_runtime_template.location}/notebookRuntimeTemplates/${google_colab_runtime_template.my_runtime_template.name}"
365
-
366
- gcs_output_uri = "gs://${google_storage_bucket.output_bucket.name}"
367
-
368
- service_account = "%{service_account}"
369
-
370
- depends_on = [
371
- google_colab_runtime_template.my_runtime_template,
372
- google_storage_bucket.output_bucket,
373
- google_secret_manager_secret_version.secret_version,
374
- google_dataform_repository.dataform_repository,
375
- google_secret_manager_secret.secret,
376
- ]
377
-
378
- }
379
- ` , context )
380
- }
381
-
382
143
func testAccCheckColabNotebookExecutionDestroyProducer (t * testing.T ) func (s * terraform.State ) error {
383
144
return func (s * terraform.State ) error {
384
145
for name , rs := range s .RootModule ().Resources {
0 commit comments