Terraform-aws-modules/vpc/aws variable cannot be set using the -var and -var-file?

using the below code in-order to create AWS VPC and dependencies. The variable values are set by terragrunt which executing the TF code.
After many re-executions of project includes this code, following bellow appear
Code

module "vpc" {
  source = "terraform-aws-modules/vpc/aws"

  name = var.vpc_name
  cidr = var.vpc_cidr

  azs             = var.azs
  private_subnets = var.private_subnets
  public_subnets  = var.public_subnets

  enable_nat_gateway = var.enable_nat_gateway
  single_nat_gateway = var.single_nat_gateway
  nat_gateway_tags = var.nat_gateway_tags
  private_subnet_names = var.private_subnet_names
  public_subnet_names = var.public_subnet_names
  public_subnet_tags = var.public_subnet_tags
  private_subnet_tags = var.private_subnet_tags
  igw_tags = var.igw_tags
  map_public_ip_on_launch = true
  enable_vpn_gateway = false
  manage_default_security_group = false
  manage_default_route_table = false
  manage_default_network_acl = false
  private_route_table_tags = var.private_route_table_tags
  public_route_table_tags = var.public_route_table_tags
  tags = var.tags
}

Errors

  │ The variable nat_gateway_tags cannot be set using the -var and -var-file
  │ options when applying a saved plan file, because a saved plan includes the
  │ variable values that were set when it was created. The saved plan specifies
  │ "{\"Name\":\"zengo-vpc-qa-nat-gateway\"}" as the value whereas during apply
  │ the value object with 1 attribute "Name" was set by an environment
  │ variable. To declare an ephemeral variable which is not saved in the plan
  │ file, use ephemeral = true.
  ╵
  ╷
  │ Error: Can't change variable when applying a saved plan
  │ 
  │ The variable private_route_table_tags cannot be set using the -var and
  │ -var-file options when applying a saved plan file, because a saved plan
  │ includes the variable values that were set when it was created. The saved
  │ plan specifies "{\"Name\":\"zengo-vpc-qa-private_route_table\"}" as the
  │ value whereas during apply the value object with 1 attribute "Name" was set
  │ by an environment variable. To declare an ephemeral variable which is not
  │ saved in the plan file, use ephemeral = true.

What am I missing here ?
Thx

1 Like

Did you get a resolution on this error?

I am seeing the same issue. just started happening in last few days . no change to terraform or terragrunt version. I have tried updating versions and still get the same error passing maps in input

I have reverted to Terraform version 1.9.8 after experiencing an issue with version 1.10.0, and the problem seems to have been resolved. Something in version 1.10.0 may have caused the error.

1.10.0 (November 27, 2024)

NEW FEATURES:

  • Ephemeral resources: Ephemeral resources are read anew during each phase of Terraform evaluation, and cannot be persisted to state storage. Ephemeral resources always produce ephemeral values.
  • Ephemeral values: Input variables and outputs can now be defined as ephemeral. Ephemeral values may only be used in certain contexts in Terraform configuration, and are not persisted to the plan or state files.
    • ephemeralasnull function: a function takes a value of any type and returns a similar value of the same type with any ephemeral values replaced with non-ephemeral null values and all non-ephemeral values preserved.

You are correct it is 1.10.0 causing the issue
I was setting the terraform version but actually it was pulling the most recent.

So the solution is to just revert to previous version? are there any plans for resolution in the newest versions?