terraform-aws-ssm-parameter icon indicating copy to clipboard operation
terraform-aws-ssm-parameter copied to clipboard

StringList cannot be created with a list(string)

Open nbcchen opened this issue 1 year ago β€’ 0 comments

Description

I tried these examples

  1. https://github.com/terraform-aws-modules/terraform-aws-ssm-parameter/blob/master/README.md?plain=1#L99-L101
  2. https://github.com/terraform-aws-modules/terraform-aws-ssm-parameter/blob/master/README.md?plain=1#L110-L113

But they don't actually create StringList of comma-separated values like this

item1,item2

instead they create a JSON representation of the Terraform list

["item1","item2"]
  • [x] βœ‹ I have searched the open/closed issues and my issue is not listed.

⚠️ Note

Before you submit an issue, please perform the following first:

  1. Remove the local .terraform directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!): rm -rf .terraform/
  2. Re-initialize the project root to pull down modules: terraform init
  3. Re-attempt your terraform plan or apply and check if the issue still persists

Versions

  • Module version [Required]: latest

  • Terraform version: >= 1.7.4

  • Provider version(s): aws 5.68.0

Reproduction Code [Required]

variable "env" {
  default = "dev"
}

variable "application" {
  default = "test"
}

variable "parameters" {
  type = map(object({
    value           = optional(any)
    values          = optional(list(any), [])
    description     = optional(string)
    allowed_pattern = optional(string)
    data_type       = optional(string)
  }))
  default = {
    
    values = ["item1","item2"]
 }
}

locals {
  parameters = {
    for key, value in var.parameters :
    format("/%s/%s/%s", var.env, var.application, upper(key)) => value
  }
}

provider "aws" {
  region = var.region
}
module "ssm_parameters" {
  for_each        = merge(local.parameters, var.additional_parameters)
  source          = "terraform-aws-modules/ssm-parameter/aws"
  name            = each.key
  value           = try(tostring(each.value.value), null)
  values          = try(each.value.values, [])
  description     = try(each.value.description, null)
  allowed_pattern = try(each.value.allowed_pattern, null)
  data_type       = try(each.value.data_type, null)
}

Steps to reproduce the behavior:

Not using workspace. .terraform directory was cleared.

Expected behavior

item1,item2

Actual behavior

["item1", "item2"]

Terminal Output Screenshot(s)

Additional context

nbcchen avatar Sep 26 '24 02:09 nbcchen