@@ -245,6 +245,46 @@ func TestAccCloudFunctionsFunction_update(t *testing.T) {
245
245
})
246
246
}
247
247
248
+ func TestAccCloudFunctionsFunction_buildworkerpool (t * testing.T ) {
249
+ t .Parallel ()
250
+
251
+ var function cloudfunctions.CloudFunction
252
+
253
+ funcResourceName := "google_cloudfunctions_function.function"
254
+ functionName := fmt .Sprintf ("tf-test-%s" , randString (t , 10 ))
255
+ bucketName := fmt .Sprintf ("tf-test-bucket-%d" , randInt (t ))
256
+ location := "us-central1"
257
+ zipFilePath := createZIPArchiveForCloudFunctionSource (t , testHTTPTriggerPath )
258
+ proj := getTestProjectFromEnv ()
259
+
260
+ defer os .Remove (zipFilePath ) // clean up
261
+
262
+ vcrTest (t , resource.TestCase {
263
+ PreCheck : func () { testAccPreCheck (t ) },
264
+ Providers : testAccProviders ,
265
+ CheckDestroy : testAccCheckCloudFunctionsFunctionDestroyProducer (t ),
266
+ Steps : []resource.TestStep {
267
+ {
268
+ Config : testAccCloudFunctionsFunction_buildworkerpool (functionName , bucketName , zipFilePath , location ),
269
+ Check : resource .ComposeTestCheckFunc (
270
+ testAccCloudFunctionsFunctionExists (
271
+ t , funcResourceName , & function ),
272
+ resource .TestCheckResourceAttr (funcResourceName ,
273
+ "name" , functionName ),
274
+ resource .TestCheckResourceAttr (funcResourceName ,
275
+ "build_worker_pool" , fmt .Sprintf ("projects/%s/locations/%s/workerPools/pool-%s" , proj , location , functionName )),
276
+ ),
277
+ },
278
+ {
279
+ ResourceName : funcResourceName ,
280
+ ImportState : true ,
281
+ ImportStateVerify : true ,
282
+ ImportStateVerifyIgnore : []string {"build_environment_variables" },
283
+ },
284
+ },
285
+ })
286
+ }
287
+
248
288
func TestAccCloudFunctionsFunction_pubsub (t * testing.T ) {
249
289
t .Parallel ()
250
290
@@ -766,6 +806,44 @@ resource "google_cloudfunctions_function" "function" {
766
806
` , bucketName , zipFilePath , functionName )
767
807
}
768
808
809
+ func testAccCloudFunctionsFunction_buildworkerpool (functionName string , bucketName string , zipFilePath string , location string ) string {
810
+ return fmt .Sprintf (`
811
+ resource "google_storage_bucket" "bucket" {
812
+ name = "%s"
813
+ location = "US"
814
+ }
815
+
816
+ resource "google_storage_bucket_object" "archive" {
817
+ name = "index.zip"
818
+ bucket = google_storage_bucket.bucket.name
819
+ source = "%s"
820
+ }
821
+
822
+ resource "google_cloudbuild_worker_pool" "pool" {
823
+ name = "pool-%[3]s"
824
+ location = "%s"
825
+ worker_config {
826
+ disk_size_gb = 100
827
+ machine_type = "e2-standard-4"
828
+ no_external_ip = false
829
+ }
830
+ }
831
+
832
+ resource "google_cloudfunctions_function" "function" {
833
+ name = "%[3]s"
834
+ runtime = "nodejs10"
835
+ description = "test function"
836
+ docker_registry = "CONTAINER_REGISTRY"
837
+ available_memory_mb = 128
838
+ source_archive_bucket = google_storage_bucket.bucket.name
839
+ source_archive_object = google_storage_bucket_object.archive.name
840
+ trigger_http = true
841
+ timeout = 61
842
+ entry_point = "helloGET"
843
+ build_worker_pool = google_cloudbuild_worker_pool.pool.id
844
+ }` , bucketName , zipFilePath , functionName , location )
845
+ }
846
+
769
847
func testAccCloudFunctionsFunction_pubsub (functionName string , bucketName string ,
770
848
topic string , zipFilePath string ) string {
771
849
return fmt .Sprintf (`
0 commit comments