7
2

More than 3 years have passed since last update.

【Terraform】for_each で AWS SSM パラメータストア に パラメータを一括登録する

Posted at

はじめに

TerraformでAWSの環境構築を行う際にfor_eachを利用してAWS SSM (System Manager) パラメータストアにパラメータを一括登録する方法を備忘録として投稿させていただきます。

terraform

variables.tf
variable "list" {
  description = "AWS SSM パラメータストアに登録する名前と値のセット"
  type        = map(string)
  default = {
    "DB/HOST "    = "xxxxx"
    "DB/USER"     = "xxxxx"
    "DB/PASSWORD" = "xxxxx"
    "DB/DATABASE" = "xxxxx"
  }
}
main.tf
resource "aws_ssm_parameter" "list" {
  for_each = var.list

  name  = "/${each.key}"
  value = each.value
  type  = "String"
}

実行結果

qiita-ssm-parameter-01.png

qiita-ssm-parameter-02.png

7
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
2