1.
Add peppercorns, star anise, thyme, garlic, chili pepper flakes to a mason or other glass jar. Slice onion and place in the jar over the spices.
2.
In a small saucepan over medium heat, bring vinegar, water, sugar, and salt to a simmer. Stir until sugar and salt dissolve, then pour mixture over onions and spices.
3.
Let cool to room temperature, then place lid on securely and refrigerate until ready to use, at least 2 hours. Onions will keep in the refrigerator for up to 1 month.