Change in IAM role for EC2 instance not affecting already running EC2 instance

amazon ec2amazon-iam

I have an IAM role for EC2 instance (so called Instance Profile) with two policies attached, giving full access to SQS and S3. There is an EC2 instance running associated with this role. It runs several apps, that do use temporary credentials and everything is working fine.

Right now, one of my apps needs also access to SNS. I've modified IAM role, adding an Inline policy with policy generator, allowing certain API calls for particular SNS topic. However after modification of IAM role, when trying aws sns list-topics I get following error (respective arn's replaced with triple X):

User: XXX is not authorized to perform: SNS:ListTopics on resource: XXX:*

Does the addition of policy require instance to be restarted? Or do I have to wait for the temporary credentials (/latest/meta-data/iam/security-credentials/iam-role-name) to expire? Can I somehow force expiration of those credentials?

EDIT: The last question seems to be answered by IAM FAQ. Temporary credentials can't be reactivated or extended.

Best Answer

After many different approaches, it turned out that limiting my policy for a single queue was causing all the problems. I assumed that when policy applies to single queue and you do ListTopics, then you will get just the topic you have access to. However, my SNS had several other topics and most probably their existence in ListTopics result was considered a violation of policy. When I replaced particular topic name with '*' and saved the policy, then immidiatelly (no need for expiration of credentials or EC2 instance restarts) it started working.