Skip to content

Commit

Permalink
dlp_job_trigger: clarify how to use multiple actions with example (#9458
Browse files Browse the repository at this point in the history
) (#16527)

[upstream:b18bedc8b5be293e20bcb653efdcc08991b6fc39]

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Nov 14, 2023
1 parent 473488f commit d7b77a8
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/9458.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ be based on the time of the execution of the last run of the JobTrigger.`,
"actions": {
Type: schema.TypeList,
Optional: true,
Description: `A task to execute on the completion of a job.`,
Description: `Configuration block for the actions to execute on the completion of a job. Can be specified multiple times, but only one for each type. Each action block supports fields documented below. This argument is processed in [attribute-as-blocks mode](https://www.terraform.io/docs/configuration/attr-as-blocks.html).`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"deidentify": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,77 @@ resource "google_data_loss_prevention_job_trigger" "with_trigger_id" {
`, context)
}

func TestAccDataLossPreventionJobTrigger_dlpJobTriggerMultipleActionsExample(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"project": envvar.GetTestProjectFromEnv(),
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckDataLossPreventionJobTriggerDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccDataLossPreventionJobTrigger_dlpJobTriggerMultipleActionsExample(context),
},
{
ResourceName: "google_data_loss_prevention_job_trigger.basic",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"trigger_id", "parent"},
},
},
})
}

func testAccDataLossPreventionJobTrigger_dlpJobTriggerMultipleActionsExample(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_data_loss_prevention_job_trigger" "basic" {
parent = "projects/%{project}"
description = "Description"
display_name = "Displayname"
triggers {
schedule {
recurrence_period_duration = "86400s"
}
}
inspect_job {
inspect_template_name = "fake"
actions {
save_findings {
output_config {
table {
project_id = "project"
dataset_id = "dataset"
}
}
}
}
actions {
pub_sub {
topic = "projects/project/topics/topic-name"
}
}
storage_config {
cloud_storage_options {
file_set {
url = "gs://mybucket/directory/"
}
}
}
}
}
`, context)
}

func testAccCheckDataLossPreventionJobTriggerDestroyProducer(t *testing.T) func(s *terraform.State) error {
return func(s *terraform.State) error {
for name, rs := range s.RootModule().Resources {
Expand Down
47 changes: 46 additions & 1 deletion website/docs/r/data_loss_prevention_job_trigger.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,51 @@ resource "google_data_loss_prevention_job_trigger" "with_trigger_id" {
}
}
```
## Example Usage - Dlp Job Trigger Multiple Actions


```hcl
resource "google_data_loss_prevention_job_trigger" "basic" {
parent = "projects/my-project-name"
description = "Description"
display_name = "Displayname"
triggers {
schedule {
recurrence_period_duration = "86400s"
}
}
inspect_job {
inspect_template_name = "fake"
actions {
save_findings {
output_config {
table {
project_id = "project"
dataset_id = "dataset"
}
}
}
}
actions {
pub_sub {
topic = "projects/project/topics/topic-name"
}
}
storage_config {
cloud_storage_options {
file_set {
url = "gs://mybucket/directory/"
}
}
}
}
}
```

## Argument Reference

Expand Down Expand Up @@ -555,7 +600,7 @@ The following arguments are supported:

* `actions` -
(Optional)
A task to execute on the completion of a job.
Configuration block for the actions to execute on the completion of a job. Can be specified multiple times, but only one for each type. Each action block supports fields documented below. This argument is processed in [attribute-as-blocks mode](https://www.terraform.io/docs/configuration/attr-as-blocks.html).
Structure is [documented below](#nested_actions).


Expand Down

0 comments on commit d7b77a8

Please sign in to comment.