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

Cannot use loop in actions_v2 variable #551

Open
BenjaminVouillaume opened this issue Dec 27, 2024 · 3 comments
Open

Cannot use loop in actions_v2 variable #551

BenjaminVouillaume opened this issue Dec 27, 2024 · 3 comments

Comments

@BenjaminVouillaume
Copy link

BenjaminVouillaume commented Dec 27, 2024

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 !

@jianyuan
Copy link
Owner

Hi @BenjaminVouillaume, this is unexpected. Can you tell me what version of Terraform are you using?

@BenjaminVouillaume
Copy link
Author

Hi @jianyuan,
We are using terraform 1.9.8 right now. We're planning to upgrade to 1.10.x in January.

Thanks

@nikolaik
Copy link

nikolaik commented Jan 15, 2025

I have a similar issue when using conditions_v2 in a module and conditionally setting the value, similar to this:

conditions_v2 = var.some_var == "some_value" ? [{ first_seen_event = {} }] : [{ first_seen_event = {} }] 

this gives:

╷
│ Error: Value Conversion Error
│
│   with module.yolo.sentry_issue_alert.slack,
│   on project_alerts/main.tf line 13, in resource "sentry_issue_alert" "slack":
│   13:   conditions_v2 = var.some_var == "some_value" ? [{ first_seen_event = {} }] : [{ first_seen_event = {} }]
│
│ 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: conditions_v2[0]
│ Target Type: provider.IssueAlertConditionModel
│ Suggested Type: basetypes.ObjectValue

Also a quick question on the design of the resource sentry_issue_alert. Could this issue be solved by moving to allow multiple condition, action and filter blocks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants