Skip to content
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

fix(CIS): updating managed ruleset documents #5488

Merged
merged 4 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func dataIBMCISRulesetEntrypointVersionsRead(d *schema.ResourceData, meta interf
rulesetOutput[CISRulesetsPhase] = *rulesetObj.Phase
rulesetOutput[CISRulesetsLastUpdatedAt] = *rulesetObj.LastUpdated
rulesetOutput[CISRulesetsVersion] = *rulesetObj.Version
rulesetOutput[CISRulesetsId] = *&rulesetObj.ID

rulesetList = append(rulesetList, rulesetOutput)

Expand All @@ -143,6 +144,7 @@ func dataIBMCISRulesetEntrypointVersionsRead(d *schema.ResourceData, meta interf
rulesetOutput[CISRulesetsPhase] = *rulesetObj.Phase
rulesetOutput[CISRulesetsLastUpdatedAt] = *rulesetObj.LastUpdated
rulesetOutput[CISRulesetsVersion] = *rulesetObj.Version
rulesetOutput[CISRulesetsId] = *&rulesetObj.ID

rulesetList = append(rulesetList, rulesetOutput)

Expand All @@ -167,7 +169,7 @@ func dataIBMCISRulesetEntrypointVersionsRead(d *schema.ResourceData, meta interf
rulesetObj := flattenCISRulesets(*result.Result)

d.SetId(dataSourceCISRulesetsCheckID(d))
d.Set(CISRulesetsListOutput, rulesetObj)
d.Set(CISRulesetsEntryPointOutput, rulesetObj)
d.Set(cisID, crn)

} else {
Expand All @@ -181,7 +183,7 @@ func dataIBMCISRulesetEntrypointVersionsRead(d *schema.ResourceData, meta interf
rulesetObj := flattenCISRulesets(*result.Result)

d.SetId(dataSourceCISRulesetsCheckID(d))
d.Set(CISRulesetsListOutput, rulesetObj)
d.Set(CISRulesetsEntryPointOutput, rulesetObj)
d.Set(cisID, crn)
}

Expand All @@ -198,7 +200,7 @@ func dataIBMCISRulesetEntrypointVersionsRead(d *schema.ResourceData, meta interf
rulesetObj := flattenCISRulesets(*result.Result)

d.SetId(dataSourceCISRulesetsCheckID(d))
d.Set(CISRulesetsListOutput, rulesetObj)
d.Set(CISRulesetsEntryPointOutput, rulesetObj)
d.Set(cisID, crn)

} else {
Expand All @@ -212,7 +214,7 @@ func dataIBMCISRulesetEntrypointVersionsRead(d *schema.ResourceData, meta interf
rulesetObj := flattenCISRulesets(*result.Result)

d.SetId(dataSourceCISRulesetsCheckID(d))
d.Set(CISRulesetsListOutput, rulesetObj)
d.Set(CISRulesetsEntryPointOutput, rulesetObj)
d.Set(cisID, crn)
}
}
Expand Down
4 changes: 2 additions & 2 deletions ibm/service/cis/data_source_ibm_cis_ruleset_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func dataIBMCISRulesetVersionsRead(d *schema.ResourceData, meta interface{}) err
rulesetObj := flattenCISRulesets(*result.Result)

d.SetId(dataSourceCISRulesetsCheckID(d))
d.Set(CISRulesetsListOutput, rulesetObj)
d.Set(CISRulesetsObjectOutput, rulesetObj)
d.Set(cisID, crn)

} else {
Expand Down Expand Up @@ -149,7 +149,7 @@ func dataIBMCISRulesetVersionsRead(d *schema.ResourceData, meta interface{}) err
rulesetObj := flattenCISRulesets(*result.Result)

d.SetId(dataSourceCISRulesetsCheckID(d))
d.Set(CISRulesetsListOutput, rulesetObj)
d.Set(CISRulesetsObjectOutput, rulesetObj)
d.Set(cisID, crn)

} else {
Expand Down
1 change: 1 addition & 0 deletions ibm/service/cis/data_source_ibm_cis_rulesets.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ func flattenCISRulesets(rulesetObj rulesetsv1.RulesetDetails) interface{} {
rulesetOutput[CISRulesetsPhase] = *rulesetObj.Phase
rulesetOutput[CISRulesetsLastUpdatedAt] = *rulesetObj.LastUpdated
rulesetOutput[CISRulesetsVersion] = *rulesetObj.Version
rulesetOutput[CISRulesetsId] = *&rulesetObj.ID

ruleDetailsList := make([]map[string]interface{}, 0)
for _, ruleDetailsObj := range rulesetObj.Rules {
Expand Down
6 changes: 3 additions & 3 deletions website/docs/d/cis_ruleset_versions.html.markdown
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
subcategory: "Internet services"
layout: "ibm"
page_title: "IBM: ibm_cis_versions"
page_title: "IBM: ibm_cis_ruleset_versions"
description: |-
Get information on an IBM Cloud Internet Services ruleset version.
---

# ibm_cis_versions
# ibm_cis_ruleset_versions

Retrieve information about an IBM Cloud Internet Services Instance/Zone ruleset's version data sources. For more information, see [IBM Cloud Internet Services].

## Example usage

```terraform
data "ibm_cis_versions" "tests" {
data "ibm_cis_ruleset_versions" "tests" {
cis_id = ibm_cis.instance.id
domain_id = data.ibm_cis_domain.cis_domain.domain_id
ruleset_id = data.ibm_cis_ruleset.cis_ruleset.ruleset_id
Expand Down
5 changes: 3 additions & 2 deletions website/docs/r/cis_ruleset.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: |-
Provides a IBM CIS ruleset resource.
---

# ibm_cis_rulesets
# ibm_cis_ruleset
Provides an IBM Cloud Internet Services ruleset resource, to update and delete the ruleset of an Instance or Domain. For more information about IBM Cloud Internet Services ruleset, see [ruleset instance](https://cloud.ibm.com/docs/cis?topic=cis-managed-rules-overview).
**As there is no option to create a ruleset resource, it is required to use import module to generate the respective resource configurations([Reference](https://test.cloud.ibm.com/docs/cis?topic=cis-terraform-generating-configuration)) and use the import command to populate the state file, as stated at the end of this page.**

Expand Down Expand Up @@ -65,7 +65,8 @@ Review the argument references that you can specify for your resource.
- `rules` (optional, list) Rules which are required to be added/modified.

Nested scheme of `rules`
- `action` (String). Action of the rule.
- `id` (Required, String) ID of the rule.
- `action` (Required, String). Action of the rule.
- `description` (Optional, String) Description of the rule.
- `enable` (Optional, Boolean) Enables/Disables the rule.
- `expression` (Optional, String) Expression used by the rule to match the incoming request.
Expand Down
6 changes: 3 additions & 3 deletions website/docs/r/cis_ruleset_version_detach.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

subcategory: "Internet services"
layout: "ibm"
page_title: "IBM: ibm_cis_version_detach"
page_title: "IBM: ibm_cis_ruleset_version_detach"
description: |-
Provides an IBM CIS ruleset version resource.
---

# ibm_cis_version_detach
# ibm_cis_ruleset_version_detach
Provides an IBM Cloud Internet Services ruleset version resource of an instance or domain to be detached. This allow ruleset version to delete. For more information about IBM Cloud Internet Services ruleset version detach, see [ruleset instance](https://cloud.ibm.com/docs/cis?topic=cis-managed-rules-overview).

## Example usage

```terraform
# delete ruleset of a domain or instance

resource "ibm_cis_version_detach" "tests" {
resource "ibm_cis_ruleset_version_detach" "tests" {
cis_id = ibm_cis.instance.id
domain_id = data.ibm_cis_domain.cis_domain.domain_id
ruleset_id = "<id of the ruleset>"
Expand Down
Loading