Route53 problem: set of string required

This is a strange problem i’m having trying to set a record for an aws_route53_record, has anyone seen this before?

Plan: 10 to add, 0 to change, 0 to destroy.
│ Error: Incorrect attribute value type
│   on ../terraform-modules/route53/ line 14, in resource "aws_route53_record" "private-record-docker":
│   14:   records   = var.docker1["ec2_ip"]
│     ├────────────────
│     │ var.docker1["ec2_ip"] is ""
│ Inappropriate value for attribute "records": set of string required.

The variable is:

variable "docker1" {
  type = map
  default = {
    "ec2_ip"                 = ""

in main:

module "route53" {
  source = "../terraform-modules/route53"
  docker1              = var.docker1

And in the module, variable:

variable "docker1" {
  type = object({
    ec2_ip            = string

In the module main:

resource "aws_route53_record" "private-record-docker" {
  zone_id   =
  name      = "docker.${var.tags.Environment}.${var.tags.Customer}"
  type      = "A"
  ttl       = "300"
  records   = var.docker1["ec2_ip"]
1 Like

It’s not particularly strange - as per the error message, the records input expects a set of strings, but you are passing it an actual string.

If you check the documentation for the resource type, you’ll see that records is documented as being able to take multiple string values, and that when only one is passed, it’s surrounded in square brackets to wrap the single string into a data structure that can be iterated over.

Model your configuration after the pattern from the example in the documentation, and it should be fine.

doh. all it needed was the square brackets… I can’t believe I missed that. All the time I wasted trying to find what could be the problem too.
Thx for the reply!