I have a aws_iam_role which I want to add a policy to. Typically, I would create a policy with aws_iam_role and attach it to the role with aws_iam_role_policy_attachment.
However, I've seen some documentation which uses aws_iam_role_policy which, to my eyes, appears to do the same thing.
Am I correct or is there a subtle difference which I'm missing?
The difference is Managed policies and inline policies
When you create an
aws_iam_policy, that is a managed policy and can be re-used.When you create a
aws_iam_role_policythat's an inline policyCode to reproduce the above state