Preheat oven to 350ºF. Melt margarine in large skillet over medium high heat. Add onion and garlic and sauté over medium heat 2-3 minutes, or until soft. Add corn, herbs, chilies, tomatoes and their juice, chili powder, cumin and salt to skillet. Stir to combine and cook 8-10 minutes.
Meanwhile, combine buttermilk and cornmeal in small saucepan and bring to a boil over medium heat. Reduce heat and cook, whisking constantly, 3-4 minutes, or until mixture is thickened.
Remove pan from heat, add egg, and stir well to blend. Add cornmeal mixture to skillet and stir until all ingredients are well combined.
Turn mixture into shallow 2 quart baking dish or 4 individual gratin dishes. Place pie in oven and bake, uncovered, 20 minutes.
Sprinkle pie top with grated cheese and bake another 5-10 minutes, or until cheese is melted. Remove pie from oven and serve immediately.
Notes
If you want make the recipe vegan, substitute the cheddar cheese with a vegan cheese alternative and use a flax or chia egg replacement instead of the egg.