cloudposse / terraform-aws-ssm-parameter-store

Terraform module to populate AWS Systems Manager (SSM) Parameter Store with values from Terraform. Works great with Chamber.
https://cloudposse.com/accelerate
Apache License 2.0
109 stars 60 forks source link

Feat/allow insecure value #44

Closed KimSambaFX closed 9 months ago

KimSambaFX commented 2 years ago

what

references

https://github.com/cloudposse/terraform-aws-ssm-parameter-store/issues/43 closes #43

KimSambaFX commented 2 years ago

Any activity? @joe-niland

frimik commented 1 year ago

When combining multiple parameters, some with insecure_value set and some with value set, you end up with a problem:

│ Error: Error in function call
│ 
│   on ../../../../modules/vendor/github.com/cloudposse/terraform-aws-ssm-parameter-store/outputs.tf line 32, in output "map":
│   32:   value       = zipmap(local.name_list, local.value_list)
│     ├────────────────
│     │ while calling zipmap(keys, values)
│     │ local.name_list is list of string with 5 elements
│ 
│ Call to function "zipmap" failed: number of keys (5) does not match number of values (1).
╵

I'm testing now with this fix locally in outputs.tf:

  value_list = compact(
    concat(
      [for p in aws_ssm_parameter.default : p.value],
      [for p in aws_ssm_parameter.default : p.insecure_value],   # Added this
      [for p in aws_ssm_parameter.ignore_value_changes : p.value],
      data.aws_ssm_parameter.read.*.value
    )
  )

On top of that, in order to get rid of the insecure_value = (known after apply) state that started appearing on some of my ssm_parameter resources recently I tainted all of them and re-ran apply to have them all recreated...

Oneliner that works... but beware ⚠️ don't blatantly use if you don't know what it's doing:

# terraform state list | grep aws_ssm_parameter | sed -e "s/\(.*\)/terraform taint -lock=false '\1'/" | sh