If using whole spices, toast in a pan on medium low until fragrant. Shake pan frequently to prevent burning. Crush into a powder when finished (you can use the heavy bottom of a pan/jar in a bag, spice grinder, mortar & pestle etc.)
Add everything to a blender (or food processor/pound in mortar and pestle) and blitz to combine. If it doesn't want to move, take breaks to scrape the sides frequently (while the blender is TURNED OFF). If that still doesn't work, drizzle in a bit of coconut milk until it starts to blend smoothly.
Adjust according to your preference (more chili for spice, more salt, more lime juice, etc etc)
Use immediately or freeze in ice cube tray until further use.