-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for optional watchlist_id in google_chronicle_watchlis…
…t resource (#12673)
- Loading branch information
1 parent
843d813
commit 8dbff06
Showing
5 changed files
with
45 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
mmv1/templates/terraform/encoders/chronicle_watchlist.go.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// watchlist_id is needed to qualify the URL but cannot be sent in the body | ||
delete(obj, "watchlistId") | ||
return obj, nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
mmv1/templates/terraform/examples/chronicle_watchlist_without_id.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
resource "google_chronicle_watchlist" "{{$.PrimaryResourceId}}" { | ||
provider = "google-beta" | ||
location = "us" | ||
instance = "{{index $.TestEnvVars "chronicle_id"}}" | ||
description = "{{index $.Vars "description"}}" | ||
display_name = "{{index $.Vars "name"}}" | ||
multiplying_factor = 1 | ||
entity_population_mechanism { | ||
manual { | ||
|
||
} | ||
} | ||
watchlist_user_preferences { | ||
pinned = true | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
mmv1/templates/terraform/post_create/chronicle_watchlist_id.go.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
if tpgresource.IsEmptyValue(reflect.ValueOf(d.Get("watchlist_id"))) { | ||
// watchlist id is set by API when unset and required to GET the connection | ||
// it is set by reading the "name" field rather than a field in the response | ||
if err := d.Set("watchlist_id", flattenChronicleWatchlistWatchlistId("", d, config)); err != nil { | ||
return fmt.Errorf("Error reading Watchlist ID: %s", err) | ||
} | ||
} |