Open jhabikal21 opened 9 months ago
This is a feature not a bug. You are suppose to use dynamic field to generate rules within policy.
For example:
resource "prismacloudcompute_container_runtime_policy" "ruleset" {
learning_disabled = var.disable_container_learning
dynamic "rule" {
for_each = local.my_apps
content {
name = "${rule.value.name}-runtime-policy"
}
}
}
Describe the bug
I am using terraform resource prismacloudcompute_ci_image_vulnerability_policy to provision CI image vulnerability rules however its not working correct with loop.
Expected behavior
It should provision multiple rules based on input provided.
Current behavior
Only the 0th index element gets created and the terraform destroy doesn't work.
Steps to reproduce
resource "prismacloudcompute_ci_image_vulnerability_policy" "ruleset" { for_each = local.ci_image_vulnerability_policy_map
rule { name = each.key effect = each.value.effect collections = each.value.collections
} } `
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
Terraform will perform the following actions:
prismacloudcompute_ci_image_vulnerability_policy.ruleset["Fail high and critical vulnerabilities, alert the rest"] will be created
resource "prismacloudcompute_ci_image_vulnerability_policy" "ruleset" {
id = (known after apply)
rule {
collections = [
effect = "ignore"
name = "Fail high and critical vulnerabilities, alert the rest"
alert_threshold {
block_threshold {
prismacloudcompute_ci_image_vulnerability_policy.ruleset["NOC Test"] will be created
resource "prismacloudcompute_ci_image_vulnerability_policy" "ruleset" {
id = (known after apply)
rule {
collections = [
name = "NOC Test"
alert_threshold {
block_threshold {
Plan: 2 to add, 0 to change, 0 to destroy.
Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve.
Enter a value: yes
prismacloudcompute_ci_image_vulnerability_policy.ruleset["NOC Test"]: Creating... prismacloudcompute_ci_image_vulnerability_policy.ruleset["Fail high and critical vulnerabilities, alert the rest"]: Creating... prismacloudcompute_ci_image_vulnerability_policy.ruleset["Fail high and critical vulnerabilities, alert the rest"]: Creation complete after 1s [id=ciImagesVulnerability] prismacloudcompute_ci_image_vulnerability_policy.ruleset["NOC Test"]: Creation complete after 2s [id=ciImagesVulnerability]
Apply complete! Resources: 2 added, 0 changed, 0 destroyed. PS C:\Users\253905\OneDrive - Resideo\Data-Backup\Bikal-downloads\prisma-cloud-tar\prisma-saas-onboarding> terraform version Terraform v1.6.6 on windows_amd64
Your version of Terraform is out of date! The latest version is 1.7.2. You can update by downloading from https://www.terraform.io/downloads.html `
This is from state file "instances": [ { "index_key": "Fail high and critical vulnerabilities, alert the rest", "schema_version": 0, "attributes": { "id": "ciImagesVulnerability", "rule": [ { "alert_threshold": [ { "disabled": false, "value": 1 } ], "block_message": "", "block_threshold": [ { "enabled": false, "value": 1 } ], "collections": [ "All" ], "cve_rule": [], "disabled": false, "effect": "alert", "grace_days": 0, "grace_days_policy": [ { "critical": 0, "high": 0, "low": 0, "medium": 0 } ], "name": "NOC Test", "notes": "", "only_fixed": false, "tag_rule": [], "verbose": false } ] }, "sensitive_attributes": [], "private": "bnVsbA==" }, { "index_key": "NOC Test", "schema_version": 0, "attributes": { "id": "ciImagesVulnerability", "rule": [ { "alert_threshold": [ { "disabled": false, "value": 1 } ], "block_message": "", "block_threshold": [ { "enabled": false, "value": 1 } ], "collections": [ "All" ], "cve_rule": [], "disabled": false, "effect": "alert", "grace_days": 0, "grace_days_policy": [ { "critical": 0, "high": 0, "low": 0, "medium": 0 } ], "name": "NOC Test", "notes": "", "only_fixed": false, "tag_rule": [], "verbose": false } ] }, "sensitive_attributes": [], "private": "bnVsbA==" } ]
Screenshots
![Uploading image.png…]()