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

Error: Circular reference found #1565

Closed
sagar2610 opened this issue Oct 24, 2022 · 3 comments · Fixed by #1566
Closed

Error: Circular reference found #1565

sagar2610 opened this issue Oct 24, 2022 · 3 comments · Fixed by #1566
Labels

Comments

@sagar2610
Copy link

sagar2610 commented Oct 24, 2022

Introduction

After installing the new version, 0.42.0, I start getting circular dependency errors in my local variables.

locals.tf

locals {
  resource_prefix            = "${var.project}-${var.usecase}"
  resource_prefix_underscore = "${var.project}_${var.usecase}"
}

test.tf


locals {
  pilot_ecrs = [
    "${local.resource_prefix}-main",
    "${local.resource_prefix}-tests"
  ]
}

module "prereq" {
  source               = "../../test"
  tags                 = local.default_tags
  resource_prefix      = local.pilot_resource_prefix
  kms_key_arns         = local.kmskey_arns
  ecr_repos            = local.pilot_ecrs
}
./infrastructure/project
Failed to prepare rule checking; failed to eval an expression in prerequisites.tf:27; prerequisites.tf:13,8-29: circular reference found; local.ecrs -> local.resource_prefix -> local.resource_prefix:

Error: circular reference found

  on prerequisites.tf line 13, in locals:
  13:     "${local.resource_prefix}-tests"

local.ecrs -> local.resource_prefix -> local.resource_prefix

-->

Expected Behavior

Actual behavior

Step to Reproduce

Additional Context

@miguelangelmorenochacon
Copy link

miguelangelmorenochacon commented Oct 24, 2022

Same problem here, I've reproduced it with

locals {
  sample_value = "whatever"

  sample_map = merge({
    sample-key = {
      another-sample-key = local.sample_value
    }
    sample-key-2 = {
      another-sample-key = local.sample_value
    }
  })
}

resource "null_resource" "sample" {
  for_each = local.sample_map
}
Failed to check ruleset; Failed to check `google_project_iam_member_invalid_member` rule: tflint-fix.tf:9,28-46: circular reference found; local.sample_map -> local.sample_value -> local.sample_value

@wata727
Copy link
Member

wata727 commented Oct 24, 2022

Thank you for reporting this issue. I'm working on a fix for this bug.

@wata727
Copy link
Member

wata727 commented Oct 24, 2022

v0.42.1 has been released.
https://github.com/terraform-linters/tflint/releases/tag/v0.42.1

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

Successfully merging a pull request may close this issue.

3 participants