Skip to content

Commit

Permalink
Merge pull request #6820 from harness/gov-policy-update
Browse files Browse the repository at this point in the history
add new aws recommendations
  • Loading branch information
joeyouss committed Jun 18, 2024
2 parents 374aa8c + b305a58 commit 3cc9287
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ You can see a list of all recommendations offered by Harness for each Cloud prov

| Cloud | Cost Correlation | First Class Region Filter Support | Recommendations | Multi-Policy | Autostopping (EC2/VM/Instance) |
|-------|------------------|---------------------------------|------------------|--------------|--------------------------------|
| AWS | `aws.ec2`, `aws.ebs`, `aws.rds`, `aws.ebs-snapshot`, `aws.elastic-ip`, `aws.elb` | Yes ✅ | Yes ✅ | Yes ✅ | Yes ✅ |
| AWS | `aws.ec2`, `aws.ebs`, `aws.rds`, `aws.ebs-snapshot`, `aws.elastic-ip`, `aws.elb`, `cache-cluster`, `s3`, `redshift`, `redshift-snapshot` | Yes ✅ | Yes ✅ | Yes ✅ | Yes ✅ |
| GCP | `gcp.instance`, `gcp.disk`, `gcp.snapshot`, `gcp.sql-instance`, `gcp.image` | No ❌ | Yes ✅ | Yes ✅ | No ❌ |
| Azure | Every Resource in Billing Report | Yes ✅ | Yes ✅ | Yes ✅ | No ❌ |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,238 @@ policies:

---

### Recommendation: under-utilized-elasticcache-cluster
**Description:** Delete underutilized cache cluster with CPU utilization less than 5% in the last 7 days.

**Policy Used:**

```yaml
policies:
- name: under-utilized-elasticcache-cluster
resource: cache-cluster
description: |
Delete underutilised cache cluster with CPU utilisation less than 5% in last 7 days
filters:
- type: metrics
name: CPUUtilization
days: 7
period: 86400
value: 5
op: less-than
actions:
- type: delete
skip-snapshot: false
```

**Savings Computed:** The policy identifies a list of resources on which potential savings are calculated by summing up the cost of each resource for the last 30 days.

**Permissions Required:**
- **Dry Run:**
- ```elasticache:DescribeCacheClusters```
- **Run Once:**
- ```elasticache:DescribeCacheClusters```
- ```elasticache:DeleteCacheCluster```
- ```elasticache:DeleteReplicationGroup```


### Recommendation: s3-lifecycle-configuration

**Description:** Configure lifecycle for S3 buckets wherever it is absent which would help to reduce storage spend

**Policy Used:**

```yaml
policies:
- name: s3-lifecycle-configuration
resource: aws.s3
description: |
Configure lifecycle for s3 buckets wherever it is absent which would help to reduce storage spend
filters:
- type : value
key : Lifecycle
value : absent
actions:
- type: configure-lifecycle
rules:
- ID: harness-default-lifecycle
Status: Enabled
Filter:
Prefix: ''
Expiration:
ExpiredObjectDeleteMarker: True
AbortIncompleteMultipartUpload:
DaysAfterInitiation: 7
NoncurrentVersionExpiration:
NoncurrentDays: 30
NewerNoncurrentVersions: 6
```

**Savings Computed**:
To estimate the percentage cost savings from the given S3 lifecycle policies, we need to look at the specific actions and apply some reasonable assumptions. Here's a step-by-step approach:

1. Abort Incomplete Multipart Uploads after 7 days:
- Assumption: 5% of all uploads are incomplete and are not cleaned up without this policy.
- Cost Impact: Each incomplete multipart upload that is aborted saves the storage cost of the data uploaded so far.

2. Expire Noncurrent Versions after 30 days (keeping 6 versions):
- Assumption: Each object has, on average, 10 noncurrent versions stored. Expiring noncurrent versions after 30 days, keeping only the latest 6, will delete 4 out of every 10 noncurrent versions.
- Cost Impact: Deleting 40% of noncurrent versions reduces the total storage used by these versions.

**Example Calculation**

Let's assume the following for a single S3 bucket:

**Total Storage Used**: 1 TB (1,024 GB) in the S3 Standard storage class.

**Storage Distribution:**
- Current versions: 50% (512 GB)
- Noncurrent versions: 40% (410 GB)
- Incomplete multipart uploads: 10% (102 GB)

**Calculations:**

<DocImage path={require('../static/policy_comparison.png')} width="100%" height="100%" title="Click to view full size image" />

**Total Savings**
<DocImage path={require('../static/savings1.png')} width="60%" height="60%" title="Click to view full size image" />

References:
- [AWS S3 Lifecycle Policies](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html)
- [AWS S3 Pricing](https://aws.amazon.com/s3/pricing/)
- [Managing S3 Costs](https://aws.amazon.com/blogs/storage/optimizing-costs-with-amazon-s3-lifecycle-configurations/)

**Permissions Required:**
- **Dry Run:**
- ```s3:GetLifecycleConfiguration```
- **Run Once:**
- ```s3:GetLifecycleConfiguration```
- ```s3:PutLifecycleConfiguration```


### Recommendation: s3-intelligent-tiering-configuration

**Description:** Configure intelligent tiering for S3 buckets wherever it is disabled which would help to reduce storage spend.

**Policy Used:**

```yaml
policies:
- name: s3-intelligent-tiering-configuration
resource: aws.s3
description: |
Configure intelligent tiering for s3 buckets wherever it is disabled which would help to reduce storage spend.
filters:
- not:
- type: intelligent-tiering
attrs:
- Status: Enabled
actions:
- type: set-intelligent-tiering
Id: harness-default
IntelligentTieringConfiguration:
Id: harness-default
Status: Enabled
Tierings:
- Days: 90
AccessTier: ARCHIVE_ACCESS
- Days: 180
AccessTier: DEEP_ARCHIVE_ACCESS
```

**Savings Computed:**
- **Frequent Access Tier:** This tier is equivalent in cost to the standard S3 storage, so no savings here.
- **Infrequent Access Tier:** Data not accessed for 30 days moves here, saving approximately 45% compared to standard S3 storage​.
- **Archive Instant Access Tier:** Data not accessed for 90 days moves here, with savings of up to 68% compared to standard storage​.
- **Archive Access Tier:** If configured, data not accessed for 90 days can move here, offering around 71% savings​.
- **Deep Archive Access Tier:** Data not accessed for 180 days can be moved to this tier, providing up to 95% savings.

**Example Calculation**

Assume you have 1 TB of data stored in S3 standard storage:

<DocImage path={require('../static/example1.png')} width="60%" height="60%" title="Click to view full size image" />

**Example Scenario**

If 20% of your data transitions to the Infrequent Access tier after 30 days, 20% moves to Archive Access after 90 days, and 10% moves to Deep Archive Access after 180 days, your costs might look like this:

<DocImage path={require('../static/example2.png')} width="50%" height="50%" title="Click to view full size image" />

This results in a cost savings of approximately 32.76% compared to keeping all data in standard S3 storage ($23.00 per month vs. $15.463 per month).

References:
- [AWS intelligent tiering](https://aws.amazon.com/s3/storage-classes/intelligent-tiering/)
- [AWS S3 Pricing](https://aws.amazon.com/s3/pricing/)

**Permissions Required:**
- **Dry Run:**
- ```s3:GetBucketIntelligentTieringConfiguration```
- **Run Once:**
- ```s3:GetBucketIntelligentTieringConfiguration```
- ```s3:PutIntelligentTieringConfiguration```


### Recommendation: delete-underutilized-redshift-cluster

**Description:** Delete any Amazon Redshift cluster where CPU Utilization has been less than 5% for the last 7 days

**Policy Used:**

```yaml
policies:
- name: delete-underutilized-redshift-cluster
resource: redshift
description: |
Delete redshift cluster where CPU Utilization is less than 5% for last 7 days
filters:
- type: metrics
name: CPUUtilization
days: 7
period: 86400
value: 5
op: less-than
actions:
- delete
```

**Savings Computed:** The policy identifies a list of resources on which potential savings are calculated by summing up the cost of each resource for the last 30 days.

**Permissions Required:**
- **Dry Run:**
- ```redshift:DescribeClusters```
- **Run Once:**
- ```redshift:DescribeClusters```
- ```redshift:DeleteCluster```


### Recommendation: delete-redshift-old-manual-snapshots

**Description:** Delete all redshift snapshots older than 35 days with a lifetime retention period

**Policy Used:**

```yaml

policies:
- name: delete-redshift-old-manual-snapshots
resource: redshift-snapshot
description: |
Delete all redshift snapshot older than 35 days with lifetime retention period
filters:
- "ManualSnapshotRetentionPeriod": -1
- type: age
days: 35
op: gt
actions:
- delete
```
**Savings Computed:** The policy identifies a list of resources on which potential savings are calculated by summing up the cost of each resource for the last 30 days.

**Permissions Required:**
- **Dry Run:**
- ```redshift:DescribeClusterSnapshots```
- **Run Once:**
- ```redshift:DeleteClusterSnapshot```
- ```redshift:DescribeClusterSnapshots```

---
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3cc9287

Please sign in to comment.