Skip to content

atlassian-operations_notification_policy Value Conversion Error with filter attributeΒ #80

@brodster2

Description

@brodster2

Provider Version: v1.1.10
Terraform Version: v1.12.2

Hello πŸ‘‹, when trying to set the optional filter attribute of the atlassian-operations_notification_policy using dynamic values I receive this error

β”‚ Error: Value Conversion Error
β”‚ 
β”‚   with atlassian-operations_notification_policy.standard,
β”‚ An unexpected error was encountered trying to convert into a Terraform value. This is
β”‚ always an error in the provider. Please report the following to the provider developer:
β”‚ 
β”‚ Cannot use attr.Value basetypes.ListValue, only basetypes.ObjectValue is supported
β”‚ because basetypes.ObjectType is the type in the schema

Steps to reproduce

locals {
  # example of user config parsed from a YAML file
  notification_policies = {
    close-splunk-alerts = {
      auto_close = {
        duration = {
          amount = 1
          unit = "minutes"
        }
      }
      description = "Close any alerts where Splunk is mentioned"
      filter = {
        conditions = [
          {
            expected_value = "Splunk"
            field = "message"
            operation = "contains"
          },
        ]
        type = "match-all-conditions"
      }
    }
  }
}

resource "atlassian-operations_notification_policy" "standard" {
  for_each    = local.notification_policies
  name        = each.key
  description = try(each.value.description, null)
  enabled     = try(each.value.enabled, true)
  team_id     = atlassian-operations_team.this.id
  type        = "notification"
  order       = try(each.value.order, null)
   filter = try({
     type       = each.value.filter.type
     conditions = try(each.value.filter.conditions, [])
   }, null)
  time_restriction  = try(each.value.time_restriction, null)
}

Run terraform validate


Since filter is documented as an optional value I wrap it in a try() in case filter isn't provided. When I do this I get the Value Conversion Error above ☝️, without the try it works but then becomes required in our user input config. The puzzling thing is that when creating an atlassian-operations_alert_policy I am able to do:

filter = try({
    type       = each.value.filter.type
    conditions = try(each.value.filter.conditions, [])
  }, null)

without getting the same error when the schemas for both filter attributes look the same:

I'm also unable to just do

filter = try(each.value.filter, null)

without getting the same error

whereas I can do this with time_restriction

time_restriction  = try(each.value.time_restriction, null)

and time_restriction seems to have the same kind of schema as filter, a schema.SingleNestedAttribute containing a schema.ListNestedAttribute

So this seems to be an issue specific to the atlassian-operations_notification_policy with the same approach working with other resources.


Other than this, thanks for the effort you've put into this provider it's great to have πŸ‘

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions