Search code examples
terraformterraform-provider-aws

Terraform internal libraries throwing errors for enable_classiclink


I'm using terraform to create a multi-az RDS on AWS. My .tf file shown below is a simple modification of a hashicorp example. When I do terraform plan I get these errors from terraform's internal libraries. Nothing indicates a problem with my .tf files.

Any idea what could cause terraform's internal libraries to throw these errors?

--Edit--

I cloned the hashicorp repo above to a new location and I do not get the errors in that directory. But when I copy the 4 .tf files to another directory and do terraform init and terraform plan the errors occur again. It's as if terraform needs the .git directory or something else in the same directory.

Bizzare.

$ terraform plan
╷
│ Warning: Argument is deprecated
│ 
│   with module.vpc.aws_eip.nat,
│   on .terraform/modules/vpc/main.tf line 970, in resource "aws_eip" "nat":
│  970:   vpc = true
│ 
│ use domain attribute instead
╵
╷
│ Error: Unsupported argument
│ 
│   on .terraform/modules/vpc/main.tf line 36, in resource "aws_vpc" "this":
│   36:   enable_classiclink               = var.enable_classiclink
│ 
│ An argument named "enable_classiclink" is not expected here.
╵
╷
│ Error: Unsupported argument
│ 
│   on .terraform/modules/vpc/main.tf line 37, in resource "aws_vpc" "this":
│   37:   enable_classiclink_dns_support   = var.enable_classiclink_dns_support
│ 
│ An argument named "enable_classiclink_dns_support" is not expected here.
╵
╷
│ Error: Unsupported argument
│ 
│   on .terraform/modules/vpc/main.tf line 1194, in resource "aws_default_vpc" "this":
│ 1194:   enable_classiclink   = var.default_vpc_enable_classiclink
│ 
│ An argument named "enable_classiclink" is not expected here.
╵

Here's my .tf file:

provider "aws" {
  region = var.region
}

data "aws_availability_zones" "available" {}

module "vpc" {
  source = "terraform-aws-modules/vpc/aws"
  version = "2.77.0"
  name = "vpc.rds.multi-az"
  cidr = "10.0.0.0/16"
  azs = data.aws_availability_zones.available.names
  public_subnets = ["10.0.4.0/24", "10.0.5.0/24", "10.0.6.0/24"]
  enable_dns_hostnames = true
  enable_dns_support = true
}

resource "aws_db_subnet_group" "rds_multi_az" {
  name = "rds.multi-az"
  subnet_ids = module.vpc.public_subnets
}

resource "aws_security_group" "rds_multi_az" {
  name = "rds.multi-az"
  vpc_id = module.vpc.vpc_id

  ingress {
    from_port = 5432
    to_port = 5432
    protocol = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }

  egress {
    from_port = 5432
    to_port = 5432
    protocol = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "aws_db_parameter_group" "rds_multi_az" {
  name = "rds.multi-az"
  family = "postgres14"
  parameter {
    name  = "log_connections"
    value = "1"
  }
}

resource "aws_db_instance" "rds_multi_az" {
  identifier = "rds.multi-az"
  instance_class = "db.t3.micro"
  allocated_storage = 5
  engine = "postgres"
  engine_version = "14.7"
  username = "multiaz"
  password = var.db_password
  db_subnet_group_name = aws_db_subnet_group.rds_multi_az.name
  vpc_security_group_ids = [aws_security_group]
  parameter_group_name = aws_db_parameter_group.rds_multi_az.name
  publicly_accessible = true
  skip_final_snapshot = true
  multi_az = true
}

Solution

  • The issue was that I had not kept the .terraform.lock.hcl file from the repo. Once that was added terraform plan worked.

    When I do terraform init -upgrade I get the same errors from terraform plan. It looks like hashicorp's example code can't be upgraded.

    I've opened an issue here.