@@ -411,6 +411,101 @@ resource "google_cloud_run_service" "default" {
411
411
` , context )
412
412
}
413
413
414
+ func TestAccEventarcTrigger_eventarcTriggerWithFirestoreSourceExample (t * testing.T ) {
415
+ t .Parallel ()
416
+
417
+ context := map [string ]interface {}{
418
+ "project_id" : envvar .GetTestProjectFromEnv (),
419
+ "random_suffix" : acctest .RandString (t , 10 ),
420
+ }
421
+
422
+ acctest .VcrTest (t , resource.TestCase {
423
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
424
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
425
+ CheckDestroy : testAccCheckEventarcTriggerDestroyProducer (t ),
426
+ Steps : []resource.TestStep {
427
+ {
428
+ Config : testAccEventarcTrigger_eventarcTriggerWithFirestoreSourceExample (context ),
429
+ },
430
+ {
431
+ ResourceName : "google_eventarc_trigger.primary" ,
432
+ ImportState : true ,
433
+ ImportStateVerify : true ,
434
+ ImportStateVerifyIgnore : []string {"labels" , "location" , "terraform_labels" },
435
+ },
436
+ },
437
+ })
438
+ }
439
+
440
+ func testAccEventarcTrigger_eventarcTriggerWithFirestoreSourceExample (context map [string ]interface {}) string {
441
+ return acctest .Nprintf (`
442
+ resource "google_firestore_database" "database" {
443
+ project = "%{project_id}"
444
+ name = "tf-test-some-database%{random_suffix}"
445
+ location_id = "us-central1"
446
+ type = "FIRESTORE_NATIVE"
447
+
448
+ delete_protection_state = "DELETE_PROTECTION_DISABLED"
449
+ deletion_policy = "DELETE"
450
+ }
451
+
452
+ resource "google_eventarc_trigger" "primary" {
453
+ name = "tf-test-some-trigger%{random_suffix}"
454
+ location = "us-central1"
455
+ matching_criteria {
456
+ attribute = "type"
457
+ value = "google.cloud.firestore.document.v1.written"
458
+ }
459
+ matching_criteria {
460
+ attribute = "database"
461
+ value = google_firestore_database.database.name
462
+ }
463
+ destination {
464
+ cloud_run_service {
465
+ service = google_cloud_run_service.default.name
466
+ region = "us-central1"
467
+ }
468
+ }
469
+ event_data_content_type = "application/protobuf"
470
+ service_account = google_service_account.trigger_service_account.email
471
+ depends_on = [google_project_iam_member.event_receiver]
472
+ }
473
+
474
+ resource "google_service_account" "trigger_service_account" {
475
+ account_id = "tf-test-trigger-sa%{random_suffix}"
476
+ }
477
+
478
+ resource "google_project_iam_member" "event_receiver" {
479
+ project = google_service_account.trigger_service_account.project
480
+ role = "roles/eventarc.eventReceiver"
481
+ member = "serviceAccount:${google_service_account.trigger_service_account.email}"
482
+ }
483
+
484
+ resource "google_cloud_run_service" "default" {
485
+ name = "tf-test-some-service%{random_suffix}"
486
+ location = "us-central1"
487
+
488
+ template {
489
+ spec {
490
+ containers {
491
+ image = "gcr.io/cloudrun/hello"
492
+ ports {
493
+ container_port = 8080
494
+ }
495
+ }
496
+ container_concurrency = 50
497
+ timeout_seconds = 100
498
+ }
499
+ }
500
+
501
+ traffic {
502
+ percent = 100
503
+ latest_revision = true
504
+ }
505
+ }
506
+ ` , context )
507
+ }
508
+
414
509
func testAccCheckEventarcTriggerDestroyProducer (t * testing.T ) func (s * terraform.State ) error {
415
510
return func (s * terraform.State ) error {
416
511
for name , rs := range s .RootModule ().Resources {
0 commit comments