I have done this, and it's fine. Check on Apple upgrade prices vs Crucial and it's highly likely you'll save money buying from outside Apple. Crucial will walk you through buying correct RAM.
When the 27-inch iMac first came out I wrote this article on upgrading RAM in a 27-inch iMac.
The RAM and Apple prices will have changed a little but the basics remain true. Let us know how you get along.
The Google ad under this thread should point you to Crucial.