IBM-Cloud / terraform-provider-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
336 stars 645 forks source link

[ibm_scc_profile_attachment] scope.properties.value string required - error on exclusions #5387

Open jmoliva opened 1 month ago

jmoliva commented 1 month ago

Community Note

Terraform CLI and Terraform IBM Provider Version

Terraform v1.7.5 on darwin_amd64

Affected Resource(s)

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

{
  "profile_id": "1db9a6ab-2ebc-4fb6-bfc1-9d41ed836fed",
  "instance_id": "76889510-2832-41d1-96b0-1a81c7554048",
  "scope": [
    {
      "environment": "ibm-cloud",
      "properties": [
        {
          "name": "scope_id",
          "value": "9038e96c569df567d2d0a9aee33ace34"
        },
        {
          "name": "scope_type",
          "value": "account"
        },
        {
          "name": "exclusions",
          "value": []
        }
      ],
      "id": "250d654d-1a0b-48bc-b4ba-2d0bb2d3ba2b"
    }
  ],
  "status": "disabled",
  "schedule": "daily",
  "notifications": {
    "enabled": false,
    "controls": {
      "threshold_limit": 15,
      "failed_control_ids": []
    }
  },
  "attachment_parameters": [
    {
      "parameter_name": "exclude_security_groups",
      "parameter_display_name": "Exclude the security groups",
      "parameter_type": "string_list",
      "parameter_value": "['toto','tata']",
      "assessment_type": "automated",
      "assessment_id": "rule-a1fff3f6-6428-4ad4-9be2-2171ce09fb8f"
    }
  ],
  "name": "ca002",
  "description": "ca002"
}

Debug Output

2024-05-23T16:47:05.137+0200 [ERROR] prepareFinalInputVariableValue: module.custom_attachment["3a7bcee1-3392-4be1-a6f5-cf809621b65e"].var.scope has unsuitable type
  got:  {{{} [{{{} map[environment:{{{} %!s(cty.primitiveTypeKind=83)}} id:{{{} %!s(cty.primitiveTypeKind=83)}} properties:{{{} [{{{} map[name:{{{} %!s(cty.primitiveTypeKind=83)}} value:{{{} %!s(cty.primitiveTypeKind=83)}}] map[]}} {{{} map[name:{{{} %!s(cty.primitiveTypeKind=83)}} value:{{{} %!s(cty.primitiveTypeKind=83)}}] map[]}} {{{} map[name:{{{} %!s(cty.primitiveTypeKind=83)}} value:{{{} []}}] map[]}}]}}] map[]}}]}}
  want: {{{} {{{} map[environment:{{{} %!s(cty.primitiveTypeKind=83)}} properties:{{{} {{{} map[name:{{{} %!s(cty.primitiveTypeKind=83)}} value:{{{} %!s(cty.primitiveTypeKind=83)}}] map[name:{} value:{}]}}}}] map[environment:{}]}}}}
2024-05-23T16:47:05.138+0200 [ERROR] vertex "module.custom_attachment[\"3a7bcee1-3392-4be1-a6f5-cf809621b65e\"].var.scope" error: Invalid value for input variable
2024-05-23T16:47:05.138+0200 [ERROR] vertex "module.custom_attachment.var.scope (expand)" error: Invalid value for input variable

and as a result

│ Error: Invalid value for input variable
│
│   on custom_attachment.tf line 18, in module "custom_attachment":
│   18:   scope                 = each.value.scope
│
│ The given value is not suitable for module.custom_attachment["3a7bcee1-3392-4be1-a6f5-cf809621b65e"].var.scope declared at custom_attachment_module/variables.tf:37,1-17: element 0: attribute
│ "properties": element 2: attribute "value": string required.

Panic Output

Expected Behavior

The provider should create the attachment.

Note that the problem happens with an exclusion list empty or not.

Actual Behavior

The provider gives an error on the exclusion element because it is a list

Steps to Reproduce

  1. terraform plan

Important Factoids

References