Skip to content

Commit 59fe41e

Browse files
committed
updating control
1 parent cbb51f7 commit 59fe41e

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed
Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,50 @@
1-
Description: Identify and remove old AWS Elastic Block Store (EBS) volume snapshots for cost optimization.
2-
ID: aws_ebs_volumes_too_old_snapshots
1+
ID: aws_ec2_ami_too_old
2+
Title: EC2 AMI Too Old
3+
Description: Ensure EC2 Amazon Machine Images (AMIs) aren't too old
34
IntegrationType:
45
- aws_cloud_account
56
Query:
67
Engine: CloudQL-v0.0.1
78
ListOfTables:
9+
- aws_backup_managed
810
- aws_ebs_snapshot
11+
- aws_ec2_ami
912
Parameters:
10-
- key: awsEbsSnapshotAgeMaxDays
11-
required: false
12-
PrimaryTable: aws_ebs_snapshot
13+
- Key: awsEbsAmiAgeMaxDays
14+
Required: true
15+
DefaultValue: "365"
16+
PrimaryTable: aws_ec2_ami
1317
QueryToExecute: |
1418
SELECT
15-
snapshot_id AS resource,
19+
image_id AS resource,
1620
platform_resource_id,
1721
platform_integration_id,
1822
CASE
19-
WHEN start_time + ({{.awsEbsSnapshotAgeMaxDays}}::INT || ' days')::interval < now()
20-
THEN 'alarm'
23+
WHEN is_aws_backup_managed THEN 'skip'
24+
WHEN root_device_type <> 'ebs' THEN 'skip'
25+
WHEN creation_date + ('{{.awsEbsAmiAgeMaxDays}} days')::interval < NOW()
26+
THEN 'alarm'
2127
ELSE 'ok'
2228
END AS status,
2329
CASE
24-
WHEN start_time + ({{.awsEbsSnapshotAgeMaxDays}}::INT || ' days')::interval < now()
25-
THEN snapshot_id || ' snapshot is older than 30 days'
26-
ELSE snapshot_id || ' snapshot is not older than 30 days'
30+
WHEN is_aws_backup_managed THEN name || ' is managed by aws'
31+
WHEN root_device_type <> 'ebs' THEN name || ' is not stored in ebs'
32+
WHEN creation_date + ('{{.awsEbsAmiAgeMaxDays}} days')::interval < NOW()
33+
THEN name || ' needs to be restarted'
34+
ELSE name || ' launch time was not long ago'
2735
END AS reason,
2836
region,
2937
account_id
3038
FROM
31-
aws_ebs_snapshot es
39+
aws_ec2_ami
3240
Severity: high
3341
Tags:
3442
platform_score_cloud_service_name:
35-
- AWS Elastic Block Store (EBS)
43+
- AWS EC2
3644
platform_score_use_case:
37-
- Optimization
45+
- Lacking High Availability
3846
score_service_name:
39-
- AWS Elastic Block Store (EBS)
47+
- AWS EC2
4048
score_tags:
41-
- Optimization
42-
Title: EBS Volumes Too Old Snapshots
49+
- Lacking High Availability
50+

0 commit comments

Comments
 (0)