Explain the mechanics of a Server-Side Request Forgery (SSRF) attack and how to prevent it in a cloud environment.