AWS CloudFormation Service Role
A service role is an AWS Identity and Access Management (IAM) role that allows AWS CloudFormation to make calls to resources in a stack on your behalf. You can specify an IAM role that allows AWS CloudFormation to create, update, or delete your stack resources. By default, AWS CloudFormation uses a temporary session that it generates from your user credentials for stack operations. If you specify a service role, AWS CloudFormation uses the role's credentials.
Use a service role to explicitly specify the actions that AWS CloudFormation can perform which might not always be the same actions that you or other users can do. For example, you might have administrative privileges, but you can limit AWS CloudFormation access to only Amazon EC2 actions.
You create the service role and its permission policy with the IAM service. For more
information about creating a service role, see Creating a Role to Delegate Permissions
to an AWS Service in the IAM User Guide. Specify AWS CloudFormation
cloudformation.amazonaws.com) as the service that can assume the role.
To associate a service role with a stack, specify the role when you create the stack. For
details, see Setting Stack Options. You
can also change the service role when you update or delete the stack.
Before you specify a service role, ensure that you have permission to pass it (
iam:PassRole permission specifies which roles you can use.
When you specify a service role, AWS CloudFormation always uses that role for all operations that are performed on that stack. Other users that have permissions to perform operations on this stack will be able to use this role, even if they don't have permission to pass it. If the role includes permissions that the user shouldn't have, you can unintentionally escalate a user's permissions. Ensure that the role grants least privilege.