{"id":2244,"date":"2021-12-16T19:03:58","date_gmt":"2021-12-16T16:03:58","guid":{"rendered":"https:\/\/artem.services\/?p=2200"},"modified":"2022-06-08T20:37:59","modified_gmt":"2022-06-08T17:37:59","slug":"2244","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=2244&lang=en","title":{"rendered":"\u00a0Terraform &#8212; AWS SSM: Extract content"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-99\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/terraform.png\" alt=\"\" width=\"1210\" height=\"418\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/terraform.png 1210w, https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/terraform-300x104.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/terraform-768x265.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/terraform-1024x354.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/terraform-954x330.png 954w\" sizes=\"(max-width: 1210px) 100vw, 1210px\" \/><\/p>\n<p>The SSM Parameter Store contains the following JSON:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n{\r\n  &quot;username&quot;: &quot;admin&quot;,\r\n  &quot;password&quot;: &quot;password&quot;\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><span class=\"VIiyi\" lang=\"en\"><span class=\"JLqJ4b ChMk0b\" data-language-for-alternatives=\"en\" data-language-to-translate-into=\"ru\" data-phrase-index=\"0\" data-number-of-phrases=\"2\"><span class=\"Q4iAWc\">It is necessary to extract the login and password, and use their values in the Terraform code.<\/span><\/span> <span class=\"JLqJ4b ChMk0b\" data-language-for-alternatives=\"en\" data-language-to-translate-into=\"ru\" data-phrase-index=\"1\" data-number-of-phrases=\"2\"><span class=\"Q4iAWc\">To do this, you can use the following construction:<\/span><\/span><\/span><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# Should be there before the apply\r\ndata &quot;aws_ssm_parameter&quot; &quot;rds-admin-user&quot; {\r\n  name  = &quot;\/ARTEM-SERVICES\/PROD\/RDS\/CREDENTIALS&quot;\r\n}\r\n\r\nlocals {\r\n  additional_rds_username      = jsondecode(data.aws_ssm_parameter.rds-admin-user.value)[&quot;username&quot;]\r\n  additional_rds_user_password = jsondecode(data.aws_ssm_parameter.rds-admin-user.value)[&quot;password&quot;]\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><span class=\"VIiyi\" lang=\"en\"><span class=\"JLqJ4b ChMk0b\" data-language-for-alternatives=\"en\" data-language-to-translate-into=\"ru\" data-phrase-index=\"0\" data-number-of-phrases=\"1\"><span class=\"Q4iAWc\">And use variables:<\/span><\/span><\/span><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nlocal.additional_rds_username\r\nlocal.additional_rds_user_password\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The SSM Parameter Store contains the following JSON: &nbsp; It is necessary to extract the login and password, and use their values in the Terraform code. To do this, you can use the following construction: &nbsp; And use variables: &nbsp; &nbsp;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[541],"tags":[543,1815,883,555],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/2244"}],"collection":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2244"}],"version-history":[{"count":2,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/2244\/revisions"}],"predecessor-version":[{"id":2246,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/2244\/revisions\/2246"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}