Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringList cannot be created with a list(string) #6

Open
1 task done
nbcchen opened this issue Sep 26, 2024 · 1 comment
Open
1 task done

StringList cannot be created with a list(string) #6

nbcchen opened this issue Sep 26, 2024 · 1 comment

Comments

@nbcchen
Copy link

nbcchen commented Sep 26, 2024

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"]
  • ✋ 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

@Chili-Man
Copy link

Chili-Man commented Dec 18, 2024

I'm running into this issue as well, what's the reasoning behind JSON encoding all values when the type is StringList ? This behavior is surprising; according to the AWS documentation, parameters of type StringList should be plain old comma-separated list of values, not JSON: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html#what-is-a-parameter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants