Skip to content

Commit a4a67eb

Browse files
Add an example for cloud_run_v2_job resource using multi-container (#13794) (#22568)
[upstream:e4e1b85b6bce1201ff4c1d45c745282abcb1c5ad] Signed-off-by: Modular Magician <[email protected]>
1 parent 4501323 commit a4a67eb

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

google/services/cloudrunv2/resource_cloud_run_v2_job_generated_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,54 @@ resource "google_cloud_run_v2_job" "default" {
486486
`, context)
487487
}
488488

489+
func TestAccCloudRunV2Job_cloudrunv2JobMulticontainerExample(t *testing.T) {
490+
t.Parallel()
491+
492+
context := map[string]interface{}{
493+
"random_suffix": acctest.RandString(t, 10),
494+
}
495+
496+
acctest.VcrTest(t, resource.TestCase{
497+
PreCheck: func() { acctest.AccTestPreCheck(t) },
498+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
499+
CheckDestroy: testAccCheckCloudRunV2JobDestroyProducer(t),
500+
Steps: []resource.TestStep{
501+
{
502+
Config: testAccCloudRunV2Job_cloudrunv2JobMulticontainerExample(context),
503+
},
504+
{
505+
ResourceName: "google_cloud_run_v2_job.default",
506+
ImportState: true,
507+
ImportStateVerify: true,
508+
ImportStateVerifyIgnore: []string{"annotations", "deletion_protection", "labels", "location", "name", "terraform_labels"},
509+
},
510+
},
511+
})
512+
}
513+
514+
func testAccCloudRunV2Job_cloudrunv2JobMulticontainerExample(context map[string]interface{}) string {
515+
return acctest.Nprintf(`
516+
resource "google_cloud_run_v2_job" "default" {
517+
name = "tf-test-cloudrun-job%{random_suffix}"
518+
location = "us-central1"
519+
deletion_protection = false
520+
521+
template {
522+
template {
523+
containers {
524+
name = "job-1"
525+
image = "us-docker.pkg.dev/cloudrun/container/job"
526+
}
527+
containers {
528+
name = "job-2"
529+
image = "us-docker.pkg.dev/cloudrun/container/job"
530+
}
531+
}
532+
}
533+
}
534+
`, context)
535+
}
536+
489537
func testAccCheckCloudRunV2JobDestroyProducer(t *testing.T) func(s *terraform.State) error {
490538
return func(s *terraform.State) error {
491539
for name, rs := range s.RootModule().Resources {

website/docs/r/cloud_run_v2_job.html.markdown

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,34 @@ resource "google_cloud_run_v2_job" "default" {
369369
}
370370
}
371371
```
372+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
373+
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=cloudrunv2_job_multicontainer&open_in_editor=main.tf" target="_blank">
374+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
375+
</a>
376+
</div>
377+
## Example Usage - Cloudrunv2 Job Multicontainer
378+
379+
380+
```hcl
381+
resource "google_cloud_run_v2_job" "default" {
382+
name = "cloudrun-job"
383+
location = "us-central1"
384+
deletion_protection = false
385+
386+
template {
387+
template {
388+
containers {
389+
name = "job-1"
390+
image = "us-docker.pkg.dev/cloudrun/container/job"
391+
}
392+
containers {
393+
name = "job-2"
394+
image = "us-docker.pkg.dev/cloudrun/container/job"
395+
}
396+
}
397+
}
398+
}
399+
```
372400

373401
## Argument Reference
374402

0 commit comments

Comments
 (0)