This template creates an IAM role and an SSM association to automate the stopping of an EC2 instance. The IAM role has the necessary permissions to execute the automation and the SSM association specifies the target instance to stop.

CloudFormation Template