All checks
Medium CloudFormation · regional

CloudFormation stacks should have associated service roles

Checks that a CloudFormation stack has a service role, so CloudFormation acts with that role's permissions instead of those of whoever runs the operation, keeping what the stack may change separate from what its users may do. A stack created by a service-managed StackSet always fails, because AWS cannot attach a role to it.

service
CloudFormation
severity
Medium
scope
evaluated in every region

How to fix it

  • Can't be undone: A stack's service role cannot be removed later, only replaced by another role, and anyone allowed to update the stack acts through it without needing iam:PassRole.
  • Can break clients: Every later update, rollback and delete of this stack runs as the role, so a permission it lacks for any of the stack's resources makes that operation fail.

In the console

CloudFormation → Stacks → the stack → Update → Use existing template → Configure stack options → Permissions

IAM role
A role cloudformation.amazonaws.com can assume, with only the permissions this stack's resources need
Capabilities
I acknowledge that this template may create IAM resources, if the template has any

With the AWS CLI

  • Overwrites existing settings: update-stack sets every template parameter you leave out to its template default, so repeat ParameterKey=<key>,UsePreviousValue=true for each one.
aws cloudformation update-stack --stack-name <stack-name> --use-previous-template --role-arn <service-role-arn> --parameters ParameterKey=<parameter-key>,UsePreviousValue=true --region <region>

With Terraform

resource "aws_cloudformation_stack" "this" {
  name         = var.stack_name
  template_url = var.template_url
  iam_role_arn = var.service_role_arn
}

See which of your accounts this check is failing on.

Book a live scan