Skip to content

Commit

Permalink
POL-838 AWS Savings Plan Recommendations Revamp (#1523)
Browse files Browse the repository at this point in the history
* first

* fixed

* updates

* update

* update

* fix

* update

* fixed

* fix

* update

* update

* fixed

* fix

* tweak
  • Loading branch information
XOmniverse authored Oct 23, 2023
1 parent db78ea8 commit 7257b8c
Show file tree
Hide file tree
Showing 3 changed files with 514 additions and 318 deletions.
11 changes: 11 additions & 0 deletions cost/aws/savings_plan/recommendations/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## v3.0

- Policy now automatically converts savings to local currency when appropriate
- Removed parameter to do the above manually via a user-specified exchange rate
- Added exchange rate context to incident to allow user to derive unmodified values when needed
- Several parameters altered to be more descriptive and intuitive to use
- Added additional context to incident description
- Normalized incident export to be consistent with other policies
- Streamlined code for better readability and faster execution
- Policy now requires a valid Flexera credential

## v2.17

- Added `Term` incident field.
Expand Down
75 changes: 44 additions & 31 deletions cost/aws/savings_plan/recommendations/README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,68 @@
# AWS Savings Plan Recommendations

This Policy Template leverages the [AWS Savings Plans Purchase Recommendation API](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_GetSavingsPlansPurchaseRecommendation.html). It will raise incidents if AWS has any Savings Plan Purchase Recommendations, whose monthly savings exceeds the *Monthly Savings Threshold* parameter in the Policy.
It will email the user specified in `Email addresses of the recipients you wish to notify`
## What it does

> *NOTE: This Policy Template must be appled to the **AWS Organization Master Payer** account.*
This Policy Template reports any Savings Plan Purchase Recommendations generated by AWS. The user can adjust which recommendations are reported via policy parameters.

> *NOTE: This Policy Template must be applied to the **AWS Organization Master Payer** account.*
## Functional Details

Recommendations are obtained via requests to the [AWS Savings Plans Purchase Recommendation API](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_GetSavingsPlansPurchaseRecommendation.html).

### Policy Savings Details

The policy includes the estimated savings. The estimated savings is recognized if the recommended savings plan is purchased. The savings values are provided directly by the [AWS Savings Plans Purchase Recommendation API](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_GetSavingsPlansPurchaseRecommendation.html).

If the Flexera organization is configured to use a currency other than the one the [AWS Savings Plans Purchase Recommendation API](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_GetSavingsPlansPurchaseRecommendation.html) returns, the savings values will be converted using the exchange rate at the time that the policy executes.

## Input Parameters

This policy has the following input parameters required when launching the policy.

- *Look Back Period* - Specify the number of days of past usage to analyze.
- *Savings Plan Term* - Specify he Term length for the Savings Plan.
- *Email Addresses* - Email addresses of the recipients you wish to notify when new incidents are created.
- *Account Number* - The Account number for use with the AWS STS Cross Account Role. Leave blank when using AWS IAM Access key and secret. It only needs to be passed when the desired AWS account is different than the one associated with the Flexera One credential. [more](https://docs.flexera.com/flexera/EN/Automation/ProviderCredentials.htm#automationadmin_1982464505_1123608)
- *Payment Option* - Specify the payment option for the Savings Plan.
- *Savings Plan Type* - Choose between Compute Savings Plans, EC2 Instance Savings Plans or SageMaker Savings Plans
- *Monthly Savings Threshold* - Specify the minimum monthly savings that should result in a Savings Plan purchase recommendation
- *Email addresses to notify* - A list of email addresses to notify
- *Currency Adjustment* - Number to adjust monthly estimated savings by depending on USD conversion (maximum value 5.0)
- *Minimum Savings Threshold* - Minimum potential savings required to generate a recommendation.
- *Look Back Period* - Number of days of prior usage to analyze
- *Account Scope* - The account scope that you want your recommendations for. Select Payer to produce results only for a Master Payer account, or Linked to produce results for all linked accounts as well.
- *Savings Plan Term* - Length of savings plan term to provide recommendations for.
- *Savings Plan Type* - Type of Savings Plan to provide recommendations for.
- *Payment Option* - Savings Plan purchase option to provide recommendations for.

## Policy Actions

The following policy actions are taken on any resources found to be out of compliance.

- Send an email report

## Prerequisites

This policy uses [credentials](https://docs.flexera.com/flexera/EN/Automation/ManagingCredentialsExternal.htm) for connecting to the cloud -- in order to apply this policy you must have a credential registered in the system that is compatible with this policy. If there are no credentials listed when you apply the policy, please contact your cloud admin and ask them to register a credential that is compatible with this policy. The information below should be consulted when creating the credential.
This Policy Template uses [Credentials](https://docs.flexera.com/flexera/EN/Automation/ManagingCredentialsExternal.htm) for authenticating to datasources -- in order to apply this policy you must have a Credential registered in the system that is compatible with this policy. If there are no Credentials listed when you apply the policy, please contact your Flexera Org Admin and ask them to register a Credential that is compatible with this policy. The information below should be consulted when creating the credential(s).

## Credential configuration
- [**AWS Credential**](https://docs.flexera.com/flexera/EN/Automation/ProviderCredentials.htm#automationadmin_1982464505_1121575) (*provider=aws*) which has the following permissions:
- `ce:GetSavingsPlansPurchaseRecommendation`

For administrators [creating and managing credentials](https://docs.flexera.com/flexera/EN/Automation/ManagingCredentialsExternal.htm) to use with this policy, the following information is needed:
Example IAM Permission Policy:

Provider tag value to match this policy: `aws`
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ce:GetSavingsPlansPurchaseRecommendation"
],
"Resource": "*"
}
]
}
```

Required permissions in the provider:
- [**Flexera Credential**](https://docs.flexera.com/flexera/EN/Automation/ProviderCredentials.htm) (*provider=flexera*) which has the following roles:
- `billing_center_viewer`

```javascript
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ce:*"
],
"Resource": [
"*"
]
}
]
}
```
The [Provider-Specific Credentials](https://docs.flexera.com/flexera/EN/Automation/ProviderCredentials.htm) page in the docs has detailed instructions for setting up Credentials for the most common providers.

## Supported Clouds

Expand Down
Loading

0 comments on commit 7257b8c

Please sign in to comment.