for_each 표현식 을 사용하여 해결. 3 cat < iam.tf provider "aws" { region = "ap-northeast-2" } resource "aws_iam_user" "myiam" { for_each = toset(var.user_names) name = each.value } EOT 4 cat < variables.tf variable "user_names" { description = "Create IAM users with these names" type = list(string) default = ["gasida", "akbun", "fullmoon"] } EOT 5 출력 변수로 지정해서 출력을 보자~~ cat < outputs.tf output "all_users" { value = aws_iam_user.myiam } EOT 6 terraform plan && terraform apply -auto-approve 7 terraform state list 8 terraform output 9 arn만 가져 오고 싶다면? cat < outputs.tf output "all_users" { value = values(aws_iam_user.myiam)[*].arn } EOT terraform apply -auto-approve terraform output 10 리스트 중간값을 제외하는 부분을 다시 테스트 해보자~ akbun 삭제 cat < variables.tf variable "user_names" { description = "Create IAM users with these names" type = list(string) default = ["gasida", "fullmoon"] } EOT 11 terraform plan # aws_iam_user.myiam["akbun"] will be destroyed 12 삭제 terraform destroy -auto-approve aws iam list-users | jq