01 Run get-reservation-purchase-recommendation command (OSX/Linux/UNIX) with custom output filters to get recommendations for which Amazon EC2 Reserved Instances (RIs) to purchase. These recommendations are based on your past usage and indicate opportunities to maximize your cost savings as compared to On-Demand usage. The following command example retrieves purchase recommendations for All upfront EC2 instances with 1-year term, based on the last 30 days of Amazon EC2 instance usage:
aws ce get-reservation-purchase-recommendation
--service "Amazon Elastic Compute Cloud - Compute"
--lookback-period-in-days THIRTY_DAYS
--term-in-years ONE_YEAR
--payment-option ALL_UPFRONT
--service-specification EC2Specification={OfferingClass=STANDARD}
--query 'Recommendations[*].RecommendationDetails[]'
02 The command output should return the Amazon EC2 RI purchase recommendation(s) provided by AWS Cost Management service for your AWS account. AWS recommends the smallest size instance in an instance family. This makes it easier to purchase a size-flexible Reserved Instance. For example, the following command output describes two purchase recommendations, one for c4.large EC2 instances and one for t2.nano instances:
[
{
"AverageUtilization": "100.0000000000",
"RecurringStandardMonthlyCost": "0.0000000000",
"MinimumNumberOfInstancesUsedPerHour": "2.0000000000",
"InstanceDetails": {
"EC2InstanceDetails": {
"Family": "c4",
"SizeFlexEligible": true,
"Region": "Asia Pacific (Sydney)",
"CurrentGeneration": true,
"Platform": "Linux/UNIX",
"Tenancy": "Shared",
"InstanceType": "c4.large"
}
},
"EstimatedMonthlySavingsAmount": "47.9386667800",
"AverageNumberOfInstancesUsedPerHour": "2.0000000000",
"EstimatedBreakEvenInMonths": "7.0568700706",
"CurrencyCode": "USD",
"EstimatedMonthlySavingsPercentage": "41.0000",
"UpfrontCost": "936.0000000000",
"MaximumNormalizedUnitsUsedPerHour": "1.0000000000",
"MaximumNumberOfInstancesUsedPerHour": "2.0000000000",
"RecommendedNumberOfInstancesToPurchase": "2",
"EstimatedMonthlyOnDemandCost": "74.2720000000",
"EstimatedReservationCostForLookbackPeriod": "11.1780820800",
"RecommendedNormalizedUnitsToPurchase": "1.0",
"AverageNormalizedUnitsUsedPerHour": "1.0000000000",
"AccountId": "123456789012",
"MinimumNormalizedUnitsUsedPerHour": "1.0000000000"
},
{
"AverageUtilization": "99.8611111111",
"RecurringStandardMonthlyCost": "0.0000000000",
"MinimumNumberOfInstancesUsedPerHour": "2.0000000000",
"InstanceDetails": {
"EC2InstanceDetails": {
"Family": "t2",
"SizeFlexEligible": true,
"Region": "Asia Pacific (Sydney)",
"CurrentGeneration": true,
"Platform": "Linux/UNIX",
"Tenancy": "Shared",
"InstanceType": "t2.nano"
}
},
"EstimatedMonthlySavingsAmount": "15.9061224889",
"AverageNumberOfInstancesUsedPerHour": "2.0000000000",
"EstimatedBreakEvenInMonths": "7.5165383418",
"CurrencyCode": "USD",
"EstimatedMonthlySavingsPercentage": "37.0000",
"UpfrontCost": "320.0000000000",
"MaximumNormalizedUnitsUsedPerHour": "2.0000000000",
"MaximumNumberOfInstancesUsedPerHour": "2.0000000000",
"RecommendedNumberOfInstancesToPurchase": "2",
"EstimatedMonthlyOnDemandCost": "42.5727888889",
"EstimatedReservationCostForLookbackPeriod": "26.3013696000",
"RecommendedNormalizedUnitsToPurchase": "2.0",
"AverageNormalizedUnitsUsedPerHour": "1.9972222222",
"AccountId": "123456789012",
"MinimumNormalizedUnitsUsedPerHour": "0.0000000000"
}
]
03 Run describe-reserved-instances-offerings command (OSX/Linux/UNIX) to retrieve the pricing details and information about the available Amazon EC2 RI offerings, based on the RI purchase recommendations provided by AWS Cost Management in the previous step:
aws ec2 describe-reserved-instances-offerings
--region ap-southeast-2
--instance-type c4.large
--product-description "Linux/UNIX (Amazon VPC)"
--instance-tenancy default
--offering-type "all upfront"
--min-duration 2592000
--max-duration 31536000
--no-include-marketplace
04 The command output should return the requested RI offering information (including the Reserved Instance offering ID):
{
"ReservedInstancesOfferings": [
{
"OfferingClass": "standard",
"Marketplace": false,
"FixedPrice": 34.0,
"CurrencyCode": "USD",
"PricingDetails": [],
"UsagePrice": 0.0,
"RecurringCharges": [
{
"Amount": 0.0,
"Frequency": "Hourly"
}
],
"OfferingType": "All Upfront",
"ProductDescription": "Linux/UNIX",
"Scope": "Region",
"Duration": 31536000,
"InstanceTenancy": "default",
"ReservedInstancesOfferingId": "1234abcd-1234-abcd-1234-abcd1234abcd",
"InstanceType": "c4.large"
}
]
}
05 Run purchase-reserved-instances-offering command (OSX/Linux/UNIX) with the ID of the Reserved Instance (RI) offering that you want to access, to purchase Amazon EC2 Reserved Instances based on the offering information returned in the previous step:
aws ec2 purchase-reserved-instances-offering
--region ap-southeast-2
--reserved-instances-offering-id 1234abcd-1234-abcd-1234-abcd1234abcd
--instance-count 2
06 The command output should return the reservation ID of your new Amazon EC2 Reserved Instances (RIs):
{
"ReservedInstancesId": "aaaabbbb-aaaa-bbbb-aaaa-aaaabbbbcccc"
}
07 If required, repeat steps no. 3 – 6 to purchase more Amazon EC2 Reserved Instances as specified in the RI purchase recommendations list provided by AWS Cost Management.
08 Repeat step no. 1 – 7 to perform the entire Remediation process for other AWS accounts.