Skip to content

Cannot use loop in actions_v2 variable #551

Open
@BenjaminVouillaume

Description

@BenjaminVouillaume

Hello 👋

I just upgraded to version 0.14.3, and I'm trying to migrate from actions to actions_v2 in the sentry_issue_alert resource.

I change this code:

actions = jsonencode([
    for slack_notif in local.slack_notifs:
    {
      id         = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction"
      channel    = slack_notif.channel
      channel_id = slack_notif.channel_id
      workspace  = data.sentry_organization_integration.slack.id
      tags       = "${var.owner.slug},${var.project_id},${var.environment}"
    }
  ])

to this code:

actions_v2 = [ for slack_notif in local.slack_notifs :
    { slack_notify_service = {
        channel    = slack_notif.channel
        workspace  = data.sentry_organization_integration.slack.id
        tags       = ["${var.owner.slug}", "${var.project_id}", "${var.environment}"]
    }}
  ]

And when I'm trying to apply I have this error:

╷
│ Error: Value Conversion Error
│
│   with module.service.module.common_alerts_production.sentry_issue_alert.issue,
│   on ../../modules/common_alerts/issue.tf line 34, in resource "sentry_issue_alert" "issue":
│   34:   actions_v2 = [
│   35:   # for slack_notif in local.slack_notifs :
│   36:   for slack_notif in local.slack_notifs :
│   37:     { slack_notify_service = {
│   38:         channel    = slack_notif.channel
│   39:         workspace  = data.sentry_organization_integration.slack.id
│   40:         tags       = ["${var.owner.slug}", "${var.project_id}", "${var.environment}"]
│   41:     }}
│   42:   ]
│
│ An unexpected error was encountered trying to build a value. This is always an error in the provider. Please report the following to the provider developer:
│
│ Received unknown value, however the target type cannot handle unknown values. Use the corresponding `types` package type or a custom type that handles unknown values.
│
│ Path: actions_v2
│ Target Type: *[]provider.IssueAlertActionModel
│ Suggested Type: basetypes.ListValue

I guess it's not possible right now to dynamically build a list of actions in the actions_v2 params because of the types mistmatch.

Can you help me with this ? Or do you see another way to dynamically build the list with the right type ?

Thanks you very much !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions