Skip to content

Commit 78052a3

Browse files
Update create_url updateMask for google_chronicle_rule_deployment res… (#13053) (#9312)
[upstream:0817a8e79f08467fe5101fcee50a753e7b75bf29] Signed-off-by: Modular Magician <[email protected]>
1 parent 4143c73 commit 78052a3

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

.changelog/13053.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
chronicle: fixed creation issues when optional fields were missing for `google_chronicle_rule_deployment` resource
3+
```

google-beta/services/chronicle/resource_chronicle_rule_deployment.go

+18-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func resourceChronicleRuleDeploymentCreate(d *schema.ResourceData, meta interfac
196196
obj["runFrequency"] = runFrequencyProp
197197
}
198198

199-
url, err := tpgresource.ReplaceVars(d, config, "{{ChronicleBasePath}}projects/{{project}}/locations/{{location}}/instances/{{instance}}/rules/{{rule}}/deployment?updateMask=enabled,alerting,archived,runFrequency")
199+
url, err := tpgresource.ReplaceVars(d, config, "{{ChronicleBasePath}}projects/{{project}}/locations/{{location}}/instances/{{instance}}/rules/{{rule}}/deployment")
200200
if err != nil {
201201
return err
202202
}
@@ -216,6 +216,23 @@ func resourceChronicleRuleDeploymentCreate(d *schema.ResourceData, meta interfac
216216
}
217217

218218
headers := make(http.Header)
219+
// Read the config and update the mask only if set by the user in terraform code
220+
221+
params := []string{"enabled", "alerting", "archived", "run_frequency"}
222+
var existingParams []string
223+
224+
// Populating existingParams with the params that exist
225+
for _, param := range params {
226+
if _, ok := d.GetOk(param); ok {
227+
existingParams = append(existingParams, param)
228+
}
229+
}
230+
231+
// Updating the url to have updateMask
232+
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(existingParams, ",")})
233+
if err != nil {
234+
return err
235+
}
219236
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
220237
Config: config,
221238
Method: "PATCH",

0 commit comments

Comments
 (0)