

# Creating automation rules with Amazon CloudFormation
<a name="creating-automation-rules-with-cloudformation"></a>

Amazon Compute Optimizer integrates with Amazon CloudFormation, enabling you to define and deploy automation rules with infrastructure-as-code. You can create a template that describes the automation rules you want, and Amazon CloudFormation provisions and configures those rules for you. When you use Amazon CloudFormation, you can reuse your template to set up your automation rules consistently and repeatedly across multiple Amazon Web Services accounts.

## Compute Optimizer and Amazon CloudFormation templates
<a name="cfn-automation-rules-templates"></a>

To provision and configure automation rules, you must understand how [Amazon CloudFormation templates](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/template-guide.html) work. Templates are text files in JSON or YAML format. These templates describe the resources that you want to provision in your Amazon CloudFormation stacks.

If you're unfamiliar with JSON or YAML, you can use Amazon CloudFormation Designer to help you get started with Amazon CloudFormation templates. For more information, see [What is Amazon CloudFormation Designer?](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/working-with-templates-cfn-designer.html) in the *Amazon CloudFormation User Guide*.

You can create Amazon CloudFormation templates for the following types of automation rules:
+ Account rules that apply recommended actions only to your account
+ Organization rules that centrally apply recommended actions across member accounts

For more information, including examples of JSON and YAML templates for automation rules, see [AWS::ComputeOptimizer::AutomationRule](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/aws-resource-computeoptimizer-automationrule.html) in the *Amazon CloudFormation User Guide*.

## Learn more about Amazon CloudFormation
<a name="cfn-automation-rules-learn-more"></a>

To learn more about Amazon CloudFormation, see the following resources:
+ [Amazon CloudFormation](https://aws.amazon.com/cloudformation/)
+ [Amazon CloudFormation User Guide](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/Welcome.html)
+ [Amazon CloudFormation API Reference](https://docs.amazonaws.cn/AWSCloudFormation/latest/APIReference/Welcome.html)
+ [Amazon CloudFormation Command Line Interface User Guide](https://docs.amazonaws.cn/cloudformation-cli/latest/userguide/what-is-cloudformation-cli.html)