pulumi / pulumi-converter-terraform

Apache License 2.0
9 stars 3 forks source link

Converting a route53 route in https://github.com/terraform-aws-modules/terraform-aws-acm fails due to invalid argument to `element` #202

Open brandonpollack23 opened 1 week ago

brandonpollack23 commented 1 week ago
resource "validation" "aws:route53/record:Record" {
  options {
    dependsOn = [this]
    range     = (myCreateCertificate || myCreateRoute53RecordsOnly) && validationMethod == "DNS" && createRoute53Records && (validateCertificate || myCreateRoute53RecordsOnly) ? length(myDistinctDomainNames) : 0

  }
  zoneId         = notImplemented("lookup(var.zones,element(local.validation_domains,count.index)[\"domain_name\"],var.zone_id)")
  name           = element(validationDomains, range.value)["resource_record_name"]
  type           = element(validationDomains, range.value)["resource_record_type"]
  ttl            = dnsTtl
  records        = [element(validationDomains, range.value)["resource_record_value"]]
  allowOverwrite = validationAllowOverwriteRecords
}

is generated by

resource "aws_route53_record" "validation" {
  count = (local.create_certificate || local.create_route53_records_only) && var.validation_method == "DNS" && var.create_route53_records && (var.validate_certificate || local.create_route53_records_only) ? length(local.distinct_domain_names) : 0

  zone_id = lookup(var.zones, element(local.validation_domains, count.index)["domain_name"], var.zone_id)
  name    = element(local.validation_domains, count.index)["resource_record_name"]
  type    = element(local.validation_domains, count.index)["resource_record_type"]
  ttl     = var.dns_ttl

  records = [
    element(local.validation_domains, count.index)["resource_record_value"]
  ]

  allow_overwrite = var.validation_allow_overwrite_records

  depends_on = [aws_acm_certificate.this]
}

and zone id appears invalid in the generated code with the error:

  error: main.pp:36,28-45: the first argument to 'element' must be a list or tuple;
                error: main.pp:37,28-45: the first argument to 'element' must be a list or tuple;
                error: main.pp:39,29-46: the first argument to 'element' must be a list or tuple;
brandonpollack23 commented 1 week ago

I think this is because the function that creates said list is notImplemented:

notImplemented("distinct(\n[fork,vintry(aws_acm_certificate.this[0].domain_validation_options,var.acm_certificate_domain_validation_options):merge(\ntomap(v),{domain_name=replace(v.domain_name,\"*.\",\"\")}\n)]\n)")