countの制限
①リソース内のインラインブロックで使用できない
②配列要素の変更に未対応
cat <<-'EOF' > main.tf
provider "aws" {
region = "ap-northeast-1"
}
resource "aws_iam_user" "users01" {
count = length(var.user_names)
name = var.user_names[count.index]
}
EOF
cat <<-'EOF' > variables.tf
variable "user_names" {
description = "user_names"
type = list(string)
default = ["user01","user02","user03"]
}
EOF
cat <<-'EOF' > outputs.tf
output "all_arns" {
value = aws_iam_user.users01[*].arn
description = "all_arns"
}
EOF
terraform init
terraform fmt
terraform apply