The difference that I see between your main.tf and the one in Solution is the way in which attributes are accessed.
You’ve used dot notation instead of square-bracket notation that is used in the Solution, both are correct in this case, hence it worked.
Map/object attributes with names that are valid identifiers can also be accessed using the dot-separated attribute notation, like local.object.attrname . In cases where a map might contain arbitrary user-specified keys, we recommend using only the square-bracket index notation (local.map["keyname"] )