Cost Optimization: EC2 Right Sizing
Cost Optimization: EC2 Right Sizing

Automated Deployment

Before you launch the automated deployment, please review the architecture, configuration and other considerations discussed in this guide. Follow the step-by-step instructions in this section to configure and deploy the EC2 Right Sizing solution into your account.

Time to deploy: Approximately 25 minutes

What We'll Cover

The procedure for deploying this architecture on AWS consists of the following steps. For detailed instructions, follow the links for each step.

Step 1. Launch the Stack

  • Launch the AWS CloudFormation template into your AWS account.

  • Enter values for required parameters: Stack Name, SSH Key, Access CIDR Block

  • Review the other template parameters, and adjust if necessary.

Step 2. Download the Right-Sizing Results

  • Download the .csv file from Amazon S3.

  • Delete the solution’s AWS CloudFormation stack.

Step 1. Launch the Stack

This automated AWS CloudFormation template deploys the EC2 Right Sizing solution on the AWS Cloud.


You are responsible for the cost of the AWS services used while running this solution. See the Cost section for more details. For full details, see the pricing webpage for each AWS service you will be using in this solution.

  1. Log in to the AWS Management Console and click the button below to launch the cost-optimization-ec2-right-sizing AWS CloudFormation template.

                                EC2 Right Sizing launch button

    You can also download the template as a starting point for your own implementation.

  2. The template is launched in the US East (N. Virginia) by default. To launch the EC2 Right Sizing solution in a different AWS Region, use the region selector in the console navigation bar.


    This solution uses an AWS Lambda function to configure the stack resources. AWS Lambda is currently available in specific AWS Regions only, therefore you must launch this solution an AWS Region where the service is available. For the most current service availability by AWS Region, see AWS service offerings by region.

  3. On the Select Template page, verify that you selected the correct template and choose Next.

  4. On the Specify Details page, assign a name to your EC2 Right Sizing solution stack.

  5. Under Parameters, review the parameters for the template, and modify them as necessary. This solution uses the following default values.

    Parameter Default Description
    SSH Key <Requires Input> Public and private key pair, which allows you to connect securely to the Amazon EC2 instance. When you created an AWS account, this is the key pair you created in your preferred AWS Region.
    Access CIDR Block <Requires Input> This IP address range will have access to the EC2 instance.
    Terminate Resources Yes Choose Yes to automatically terminate the Redshift cluster and EC2 instance once the results have been stored in the S3 bucket. Choose No to keep these resources running (you can manually delete them with the AWS CloudFormation stack at a later time).


    This option enables you to terminate resources as soon as possible to avoid incurring unnecessary costs. To delete all solution resources (VPC, S3 bucket) you must delete the AWS CloudFormation stack, which is discussed in Step 2. Download the Right-Sizing Results.

    Send Anonymous Usage Data Yes Send anonymous data to AWS to help us understand solution usage and related cost savings across our customer base as a whole. To opt out of this feature, choose No. For more information, see Appendix C.
  6. Choose Next.

  7. On the Options page, you can specify tags (key-value pairs) for resources in your stack and set additional options, and then choose Next.

  8. On the Review page, review and confirm the settings. Be sure to check the box acknowledging that the template will create AWS Identity and Access Management (IAM) resources.

  9. Choose Create to deploy the stack.

    You can view the status of the stack in the AWS CloudFormation console in the Status column. After all stack resources have successfully launched, you will see the message CREATE_COMPLETE. This can take 20 or more minutes depending on the number of resources in your account.

  10. To see details for the stack resources, choose the Outputs tab. The following table describes some of these outputs in more detail.

    Key Description

    Amazon S3 bucket created to hold CloudWatch metrics and the right-sizing results


    Amazon Redshift cluster created by the solution


    Endpoint of the Amazon Redshift cluster created by the solution


This solution deploys an AWS Lambda function, solution-helper, which runs only during initial configuration or when resources are updated or deleted. You will see the solution-helper function in the AWS Lambda console, which is necessary to manage associated resources for as long as the solution is running.

Step 2. Download the Right-Sizing Results

After the EC2 Right Sizing stack launch completes, download the .csv file that contains the right-sizing analysis for your Amazon EC2 resources. See Appendix A for information on how recommendations are calculated.

  1. In the AWS CloudFormation console, in the Outputs tab, note the name of the Amazon S3 bucket (BucketName output) that the solution created.

  2. Open the Amazon S3 console and navigate to the applicable bucket.

  3. The bucket should contain the right-sizing results file result_rightsizingXXXXXXXXX.csv. Download this file to a different location.

    Note that the bucket contains other files that you can download: YYYY-MM-DD-before336hour-with60min.csv.gz, which is the raw CloudWatch metrics data, and ec2pricelist.csv, which is the latest Amazon EC2 pricing information.

  4. Review the right-sizing results file. It includes Amazon EC2 instance data such as AWS Region, current instance type, instance ID, resource tags, maximum CPU usage and IOPS, suggested instance type, and estimated monthly savings.


    This solution provides prescriptive instance type recommendations. Before incorporating these changes into your overall capacity management processes, we recommend that you test the proposed Amazon EC2 instances to ensure they are properly sized to fulfill their expected role.

  5. After you verify that your downloaded files are valid, delete all files in the Amazon S3 bucket.


    You must delete all objects in the Amazon S3 bucket to successfully delete the AWS CloudFormation stack.

  6. In the AWS CloudFormation console, delete the stack to delete all solution-related resources.


    If you chose not to terminate Amazon Redshift and Amazon EC2 resources automatically in the previous procedure, they will be terminated when you delete the stack.

                Example right-sizing analysis

Figure 2: Example right-sizing analysis