Skip to content

Zones outputs are not easily consumable, they are not primitives but objects. #93

@tymik

Description

@tymik

Description

When the Zones subpart is used as a module, it returns non-primitive outputs that are not easily consumable by other modules - they need to be transformed first to get a distilled value.
I cannot find any justification by myself to provide objects in outputs that are perfect to return primitive values like string or array and where their names suggest one can expect a primitive values there.

To get the route53_zone_name value I needed to use:

values(dependency.route53_public_zone.outputs.route53_zone_name)[0]

Instead of:

dependency.route53_public_zone.outputs.route53_zone_name

Which introduces unnecessary complications to the code and is not a common outputs usage - I have never met complex outputs for simple things like this before.

  • ✋ I have searched the open/closed issues and my issue is not listed.

Versions

  • Module version [Required]: 2.10.2

  • Terraform version: Terraform v1.3.9

  • Provider version(s): + provider registry.terraform.io/hashicorp/aws v5.8.0

Reproduction Code [Required]

include "root" {
  path = find_in_parent_folders()
}

terraform {
  source = "tfr:///terraform-aws-modules/route53/aws//modules/zones?version=2.10.2"
}

inputs = {
  # AWS provider settings
  aws_role_arn = "my.role.arn"
  aws_region   = "eu-central-1"

  zones = {
    "my.example.com" = {
      comment = "my.example.com (internal)"
    }
  }

}

Steps to reproduce the behavior:

  1. Use zones module in one place.
  2. Try to consume outputs in records module in another place (basically any module that could use e.g. zone_name)

Expected behavior

Outputs look like this:

route53_zone_name = "my.example.com"
route53_zone_name_servers = [
    "ns-1.awsdns-2.org",
    "ns-3.awsdns-4.co.uk",
    "ns-5.awsdns-6.com",
    "ns-7.awsdns-8.net",
  ]
route53_zone_zone_arn = "arn:aws:route53:::hostedzone/IDOFTHEZONE"
route53_zone_zone_id = "IDOFTHEZONE"

Actual behavior

Outputs look like this:

route53_zone_name = {
  "my.example.com" = "my.example.com"
}
route53_zone_name_servers = {
  "my.example.com" = tolist([
    "ns-1.awsdns-2.org",
    "ns-3.awsdns-4.co.uk",
    "ns-5.awsdns-6.com",
    "ns-7.awsdns-8.net",
  ])
}
route53_zone_zone_arn = {
  "my.example.com" = "arn:aws:route53:::hostedzone/IDOFTHEZONE"
}
route53_zone_zone_id = {
  "my.example.com" = "IDOFTHEZONE"
}

Additional context

I use it with Terragrunt, but that shouldn't change much to the initial problem I think.
I might try to prepare PR with fix if you are OK with that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions