Creating an EC2 Instance with an IAM Role is easy when you do it via the AWS Console but doing this with CloudFormation is not as direct. You will need an Instance Profile to connect an EC2 with an IAM Role.
When writing a CloudFormation Template that needs to use the value of an Elastic IP to a file inside an EC2 Instance, you will most likely encounter a Circular dependency between resources error.
I encountered this when configuring OpenSwan IPSec VPN in CloudFormation.
You can try the CloudFormation template below to see the error above.
CloudFormation Template with Circular Dependency Error