Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

terragrunt does not support provider functions and fails during input-validate #3425

Open
1 of 2 tasks
cordula-grau opened this issue Sep 20, 2024 · 1 comment
Open
1 of 2 tasks
Labels
bug Something isn't working

Comments

@cordula-grau
Copy link

Describe the bug

When using provider functions terragrunt validate-inputs fails with the following error:
Invalid 'for' expression: Extra characters after the end of the 'for' expression. (and 1 other messages)

offending line is:
condition = var.subnet.enable_ipv6 == false || anytrue([ for prefix in self.address_prefixes: provider::assert::cidrv6(prefix) ])

Log Output

09:38:27.973 INFO   Downloading Terraform configurations from file://../../../../../source into ./.terragrunt-cache/GH_-yqcqatzOk6TOWWxlk8evAns/Zl8COh10InqCrREuxj5EItMHqpM
09:38:27.978 DEBUG  Copying files from . into ./.terragrunt-cache/GH_-yqcqatzOk6TOWWxlk8evAns/Zl8COh10InqCrREuxj5EItMHqpM/components/dns
09:38:27.979 DEBUG  Setting working directory to ./.terragrunt-cache/GH_-yqcqatzOk6TOWWxlk8evAns/Zl8COh10InqCrREuxj5EItMHqpM/components/dns
09:38:27.979 DEBUG  The file path ./.terragrunt-cache/GH_-yqcqatzOk6TOWWxlk8evAns/Zl8COh10InqCrREuxj5EItMHqpM/components/dns/provider.tf already exists, but was a previously generated file by terragrunt. Since if_exists for code generation is set to "overwrite_terragrunt", regenerating file.
09:38:27.979 DEBUG  Generated file ./.terragrunt-cache/GH_-yqcqatzOk6TOWWxlk8evAns/Zl8COh10InqCrREuxj5EItMHqpM/components/dns/provider.tf.
09:38:27.980 DEBUG  The file path ./.terragrunt-cache/GH_-yqcqatzOk6TOWWxlk8evAns/Zl8COh10InqCrREuxj5EItMHqpM/components/dns/remotestate.tf already exists, but was a previously generated file by terragrunt. Since if_exists for code generation is set to "overwrite_terragrunt", regenerating file.
09:38:27.980 DEBUG  Generated file ./.terragrunt-cache/GH_-yqcqatzOk6TOWWxlk8evAns/Zl8COh10InqCrREuxj5EItMHqpM/components/dns/remotestate.tf.
09:38:28.078 DEBUG  tfconfig.Diagnostics Invalid 'for' expression: Extra characters after the end of the 'for' expression.
/home/circleci/project/terraform/terraform.go:56 (0x100f473fd)
/home/circleci/project/cli/commands/validate-inputs/action.go:33 (0x10143de54)
/home/circleci/project/cli/commands/terraform/target.go:85 (0x10142f684)
/home/circleci/project/cli/commands/terraform/action.go:215 (0x10142f669)
/home/circleci/project/cli/commands/terraform/action.go:87 (0x10143ddf0)
/home/circleci/project/cli/commands/validate-inputs/action.go:29 (0x10143ddf1)
/home/circleci/project/cli/commands/validate-inputs/command.go:31 (0x101440368)
/home/circleci/project/cli/app.go:239 (0x101a74078)
/home/circleci/go/pkg/mod/golang.org/x/sync@v0.8.0/errgroup/errgroup.go:78 (0x100f47dd8)
/usr/local/go/src/runtime/asm_arm64.s:1222 (0x10031db74)

09:38:28.078 ERROR  Invalid 'for' expression: Extra characters after the end of the 'for' expression.
09:38:28.078 ERROR  Unable to determine underlying exit code, so Terragrunt will exit with error code 1

Steps To Reproduce

terraform {
  required_version = "~> 1.8"
  required_providers {
    assert = {
      source  = "hashicorp/assert"
      version = "~> 0.13"
    }
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 3.8"
    }
  }
}

data "azurerm_subnet" "main" {
  name                 = var.subnet.name
  resource_group_name  = var.subnet.resource_group_name
  virtual_network_name = var.subnet.virtual_network_name

  lifecycle {
    postcondition {
      condition     = var.subnet.enable_ipv6 == false || anytrue([ for prefix in self.address_prefixes: provider::assert::cidrv6(prefix) ])
      error_message = "Subnet does not contain valid IPv6 CIDR. Either use a subnet that contains a valid IPv6 CIDR or disable IPv6 support."
    }
  }
}

variable "subnet" {
   type =    object({
      name                 = string
      virtual_network_name = string
      resource_group_name  = string
      enable_ipv6          = optional(bool, false)
    })
}

Expected behavior

terragrunt validate-inputs should run properly

Nice to haves

  • Terminal output
  • Screenshots

Versions

  • Terragrunt version: v0.67.10
  • OpenTofu/Terraform version: v1.9.6
  • Environment details (Ubuntu 20.04, Windows 10, etc.): MacOS 15.0 / Ubuntu 24.04

Additional context

Add any other context about the problem here.

@cordula-grau cordula-grau added the bug Something isn't working label Sep 20, 2024
@cordula-grau cordula-grau changed the title terragrunt does not supportprovider functions and fails during input-validate terragrunt does not support provider functions and fails during input-validate Sep 20, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants
@cordula-grau and others