Terraform can silently discard duplicate map entries
Terraform users report that duplicate map keys can replace earlier entries without a clear error, risking lost configuration. Existing linting may miss collisions in dynamic or merged maps, while warnings can be easy to overlook. Workarounds include third-party scripts and restructuring maps as lists before converting them.
For terraform infrastructure developers. Mentioned from Nov 2017 to May 2024 on GitHub.
10 different people described this problem in 3 separate discussions.
- Indie fit
- 4.0/10
- Pain
- 5.6/10
- Frequency
- 8.6/10
- Willingness to pay
- 0.0/10
- Momentum
- 5.0/10
- Who pays
- Professionals
- Competition
- Medium
- Build difficulty
- Medium
What people said
Quoted word for word. Follow a link to read the whole discussion.
I struck this today, and it's very dangerous. In terraform.tfvars it will happily let you define a map with the same key multiple times as per the example above and doesn't throw an error, but it discards all but one of the map objects with that key
Notice the loss of the 1st db1 map entry. There was no error and no warning. It just silently replaced the 1st map entry with the 2nd
Build brief
See what to build and who will buy it
- 1 product idea with the smallest useful version and pricing
- 4 places to find your first customers
- 9 more quotes from people who have this problem
- Current workarounds, existing solutions and risks