Skip to content

Error setting local.raw_value in outputs when creating String values #15

@billyrturner

Description

@billyrturner

Description

We are trying to utilise this module to create different parameters of type String and SecretString.

When creating simple String parameters, we face an error from the outputs.tf of the registry module where it is unable to set raw_value in the locals block. This error does not occur when creating SecretString parameters:

│ Error: Invalid function argument
│ 
│   on .terraform/modules/params/outputs.tf line 15, in locals:
│   15:   raw_value = one(compact([local.stored_value, local.stored_insecure_value]))
│     ├────────────────
│     │ while calling one(list)
│     │ local.stored_insecure_value is "my-value"
│     │ local.stored_value is "my-value"
│ 
│ Invalid value for "list" parameter: must be a list, set, or tuple value with either zero or one elements.

Could the use of one(compact ... )) function nestings in the outputs.tf local block be replaced with coalesce( ... ) to fix this, perhaps?

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

Versions

  • Module version [Required]: v2.0.1

  • Terraform version: 1.11.0

  • Provider version(s): 6.25.0

Reproduction Code [Required]

module "params" {
  source  = "terraform-aws-modules/ssm-parameter/aws"

  for_each = {
    "/My/Param/Name/Here" = {
      value       = "my-value"
      description = "This is my parameter description"
    }
  }

  name            = try(each.value.name, each.key)
  value           = try(each.value.value, null)
  values          = try(each.value.values, [])
  type            = try(each.value.type, null)
  secure_type     = try(each.value.secure_type, null)
  description     = try(each.value.description, null)
  tier            = try(each.value.tier, null)
  key_id          = try(each.value.key_id, null)
  allowed_pattern = try(each.value.allowed_pattern, null)
  data_type       = try(each.value.data_type, null)

}

Steps to reproduce the behavior:

  • Not using workspaces
  • Have cleared local cache

Expected behavior

Expected the module to not error when creating insensitive parameters (Strings in this case).
The error does not occur and creation is successful when creating SecretString parameters

Actual behavior

The below error when creating String type parameters:

│ Error: Invalid function argument
│ 
│   on .terraform/modules/params/outputs.tf line 15, in locals:
│   15:   raw_value = one(compact([local.stored_value, local.stored_insecure_value]))
│     ├────────────────
│     │ while calling one(list)
│     │ local.stored_insecure_value is "my-value"
│     │ local.stored_value is "my-value"
│ 
│ Invalid value for "list" parameter: must be a list, set, or tuple value with either zero or one elements.

Terminal Output Screenshot(s)

Additional context

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