When we create resources in the Terraform template, if there are multiple duplicate resources, we can specify the number through count, and it will automatically execute a loop similar to for loop, and then we can point to each of them through count.index The index value of the secondary loop. To understand from the programming thinking, we execute a for loop, each time the loop gets the value of index, the value of the element is obtained from an array of corresponding length and assigned to the parameter of name
For example, I create 3 IAM users, each with three different names. Note that to save trouble, my variables can be directly defined in the same file instead of creating a variable.tf file and a terraform.tfvars file separately
Execute the command to see the effect
Has been successfully created.