Hi, community,
I received this error while trying to introduce a new variable, “private_ip” to associate it when the instances are created via code in module-ec2, since some customers want to use their own private IPs no matter what instances we provision for them.
Here is the relevant code from /terraform/module-ec2/variables.tf:
locals {
project_title = title(var.project)
}
variable "customer" {
description = "Name of the infrastructure"
default = ""
}
...
variable "private_ip" {
description = "Specify the private IPs if there is any the customers want to maintain, in the '["private_ip1", "private_ip2", "private_ip3"]' format"
type = list(string)
default = [""]
}
Here is the relevant code from /terraform/module-ec2/ec2.tf(where I want to attach the designated private IPs when instances are created):
resource "aws_eip" "instance" {
count = var.dc_node_count
instance = element(aws_instance.instance.*.id, count.index)
associate_with_private_ip = var.private_ip[count.index]
vpc = true
tags = {
Name = var.name
Customer = var.customer
env = var.env
project = var.project
}
}
But after trying several different solutions, the ‘terraform plan’ error " On module-ec2/variables.tf line 402(the description line of defining private_ip): An argument definition must end with a newline" is never gone(We use terraform 0.12). There might be multiple places which I need to improve.
Any wisdom or answer is much appreciated. Thanks!!