You kind of answered the question yourself:
A map can contain any type as long as all the elements are of the same type
So, with this, what does map(object)
mean? It means it is a map, where the type of all of the values in the map must be on object. This is most useful when you further define the types of those objects. For example:
variable "allowed_security_groups" {
type = map(object({
id = string
}))
}
This is a map where every value must be an object with an attribute id
. This sort of type definition can be very useful for modules that need to iterate over something with complex inputs.
resource "aws_vpc_security_group_ingress_rule" "allowed_security_groups" {
for_each = var.allowed_security_groups
security_group_id = aws_security_group.this.id
# The type declaration guarantees that every iteratee has an id attribute
referenced_security_group_id = each.value.id
from_port = 443
to_port = 443
}