-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CIS - Delete filter on deletion of Firewall Rules #3963
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,10 +71,12 @@ func ResourceIBMCISDomain() *schema.Resource { | |
cisDomainVerificationKey: { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Optional: true, | ||
}, | ||
cisDomainCnameSuffix: { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Optional: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
}, | ||
}, | ||
Create: resourceCISdomainCreate, | ||
|
@@ -135,8 +137,11 @@ func resourceCISdomainRead(d *schema.ResourceData, meta interface{}) error { | |
d.Set(cisDomainNameServers, result.Result.NameServers) | ||
d.Set(cisDomainOriginalNameServers, result.Result.OriginalNameServers) | ||
d.Set(cisDomainType, result.Result.Type) | ||
d.Set(cisDomainVerificationKey, result.Result.VerificationKey) | ||
d.Set(cisDomainCnameSuffix, result.Result.CnameSuffix) | ||
|
||
if cisDomainType == "partial" { | ||
d.Set(cisDomainVerificationKey, result.Result.VerificationKey) | ||
d.Set(cisDomainCnameSuffix, result.Result.CnameSuffix) | ||
} | ||
|
||
return nil | ||
} | ||
|
@@ -207,7 +212,7 @@ func ResourceIBMCISDomainValidator() *validate.ResourceValidator { | |
ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, | ||
Type: validate.TypeString, | ||
Optional: true, | ||
AllowedValues: "full, parital"}) | ||
AllowedValues: "full, partial"}) | ||
|
||
ibmCISDomainResourceValidator := validate.ResourceValidator{ | ||
ResourceName: ibmCISDomain, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,6 +238,21 @@ func ResourceIBMCISFirewallrulesDelete(context context.Context, d *schema.Resour | |
return diag.FromErr(fmt.Errorf("[ERROR] Error deleting the custom resolver %s:%s", err, response)) | ||
} | ||
|
||
if id, ok := d.GetOk(cisFilterID); ok { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use same filterID forother rules. If we delete the filterID will not be other firewall rules not effected? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No we can not use same filter for other rules. It throws an error on creating a new rule with an already mapped filterID. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, destroy handles filter deletion but it does not cover old filters. |
||
|
||
cisFilterClient, err := meta.(conns.ClientSession).CisFiltersSession() | ||
if err != nil { | ||
return nil | ||
} | ||
|
||
filter_id := id.(string) | ||
filterOpt := cisFilterClient.NewDeleteFiltersOptions(xAuthtoken, crn, zoneID, filter_id) | ||
_, _, err = cisFilterClient.DeleteFilters(filterOpt) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if a template deletes filter as part of destroy and when a firewall rule makes again same delete call willnot that fail with 404? |
||
if err != nil { | ||
return diag.FromErr(fmt.Errorf("[ERROR] Error deleting Filter: %s", err)) | ||
} | ||
} | ||
|
||
d.SetId("") | ||
return nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this marked as optional we are just setting the value in Read method