{"id":1925,"date":"2023-12-02T09:13:59","date_gmt":"2023-12-02T15:13:59","guid":{"rendered":"https:\/\/blog.ls-al.com\/?p=1925"},"modified":"2023-12-02T09:13:59","modified_gmt":"2023-12-02T15:13:59","slug":"terraform-aws-param-store-with-json","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/terraform-aws-param-store-with-json\/","title":{"rendered":"Terraform AWS Param Store with json"},"content":{"rendered":"
Since it took me a while to get this syntax sorted I am noting this for future use.<\/p>\n
\nNOTE: This is non-sensitive parameters not secrets. You are probably better of using secrets manager for secrets. And I did not try but the Param Store SecureString type will probably not work for below.<\/p>\n<\/blockquote>\n
I stored this json in Param Store as StringList with Value<\/p>\n
{"email":"riaan@email.com","engine_version":"3.11.20","host_instance_type":"mq.t3.micro"}<\/p>\n
test<\/h3>\n
\u276f aws ssm get-parameter --name "\/microservice\/blah\/development" --region us-east-1 | jq\n{\n "Parameter": {\n "Name": "\/microservice\/blah\/development",\n "Type": "StringList",\n "Value": "{\\"email\\":\\"riaan@email.com\\",\\"engine_version\\":\\"3.11.20\\",\\"host_instance_type\\":\\"mq.t3.micro\\"}",\n "Version": 6,\n "LastModifiedDate": "2023-12-01T08:53:33.920000-06:00",\n "ARN": "arn:aws:ssm:us-east-1:xxx:parameter\/microservice\/blah\/development",\n "DataType": "text"\n }\n}<\/code><\/pre>\n
get it to a local var<\/h3>\n
data "aws_ssm_parameter" "cfg" {\n provider = aws.target1\n name = "\/microservice\/blah\/development"\n}\n\nlocals {\n cfg = jsondecode(data.aws_ssm_parameter.cfg.value)\n}<\/code><\/pre>\n
in terraform reference like this<\/h3>\n
#engine_version = "3.11.20"\n engine_version = local.cfg.engine_version<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"
Since it took me a while to get this syntax sorted I am noting this for future use. NOTE: This<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73,106,88],"tags":[],"class_list":["post-1925","post","type-post","status-publish","format-standard","hentry","category-aws","category-json","category-terraform"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1925","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=1925"}],"version-history":[{"count":1,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1925\/revisions"}],"predecessor-version":[{"id":1926,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1925\/revisions\/1926"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=1925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=1925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=1925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}