Skip to content

Commit

Permalink
POL-1071 Merge 'AWS RDS Instances' policy into 'AWS Rightsize RDS Ins…
Browse files Browse the repository at this point in the history
…tances' (#1875)

* update

* update

* update

* fix
  • Loading branch information
XOmniverse authored Feb 29, 2024
1 parent e79c3f2 commit 051d7ee
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 7 deletions.
4 changes: 4 additions & 0 deletions cost/aws/rds_instance_license_info/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v4.2

- Deprecated: This policy is no longer being updated. Please see policy README for more information.

## v4.1

- Updated description of `Account Number` parameter
Expand Down
4 changes: 4 additions & 0 deletions cost/aws/rds_instance_license_info/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# AWS RDS Instance License Information

## Deprecated

This policy is no longer being updated. The [AWS Rightsize RDS Instances](https://github.com/flexera-public/policy_templates/tree/master/cost/aws/rightsize_rds_instances/) policy can be used with the `Underutilized Instance CPU Threshold (%)` parameter set to `100` and the `Report Unused or Underutilized` parameter set to `Underutilized` to retrieve the same information.

## What it does

This Policy Template gathers AWS RDS Instance data related to licensing.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name "AWS RDS Instances"
rs_pt_ver 20180301
type "policy"
short_description "Collects all RDS instances in an account. See the [README](https://github.com/flexera-public/policy_templates/tree/master/cost/aws/rds_instance_license_info/) and [docs.flexera.com/flexera/EN/Automation](https://docs.flexera.com/flexera/EN/Automation/AutomationGS.htm) to learn more."
short_description "**Deprecated: This policy is no longer being updated. Please see [README](https://github.com/flexera-public/policy_templates/tree/master/cost/aws/rds_instance_license_info/) for more details.** Collects all RDS instances in an account. See the [README](https://github.com/flexera-public/policy_templates/tree/master/cost/aws/rds_instance_license_info/) and [docs.flexera.com/flexera/EN/Automation](https://docs.flexera.com/flexera/EN/Automation/AutomationGS.htm) to learn more."
long_description ""
severity "low"
category "Cost"
default_frequency "daily"
info(
version: "4.1",
version: "4.2",
provider: "AWS",
service: "RDS",
policy_set: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tenancy "single"
default_frequency "15 minutes"
info(
provider: "AWS",
version: "4.1", # This version of the Meta Parent Policy Template should match the version of the Child Policy Template as it appears in the Catalog for best reliability
version: "4.2", # This version of the Meta Parent Policy Template should match the version of the Child Policy Template as it appears in the Catalog for best reliability
publish: "false"
)

Expand Down
4 changes: 4 additions & 0 deletions cost/aws/rightsize_rds_instances/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v5.1

- Added Availability Zone, License Model, and vCPUs to incident output

## v5.0

- Added support for regex when filtering resources by tag
Expand Down
67 changes: 64 additions & 3 deletions cost/aws/rightsize_rds_instances/aws_rightsize_rds_instances.pt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ severity "low"
category "Cost"
default_frequency "weekly"
info(
version: "5.0",
version: "5.1",
provider: "AWS",
service: "RDS",
policy_set: "Rightsize Database Instances",
Expand Down Expand Up @@ -515,6 +515,14 @@ datasource "ds_rds_instances_set" do
field "privateDnsName", xpath(col_item, "Endpoint/Address")
field "databaseEngine", xpath(col_item, "Engine")
field "engineVersion", xpath(col_item, "EngineVersion")
field "availabilityZone", xpath(col_item, "AvailabilityZone")
field "licenseModel", xpath(col_item, "LicenseModel")
field "processorFeatures" do
collect xpath(col_item, "ProcessorFeatures/ProcessorFeature") do
field "name", xpath(col_item, "Name")
field "value", xpath(col_item, "Value")
end
end
field "region", val(iter_item, "region")
end
end
Expand Down Expand Up @@ -593,11 +601,11 @@ EOS
end

datasource "ds_rds_instances" do
run_script $js_rds_instances, $ds_rds_instances_set, $ds_resource_tags, $param_exclusion_tags, $param_exclusion_tags_boolean
run_script $js_rds_instances, $ds_rds_instances_set, $ds_resource_tags, $ds_aws_instance_size_map, $param_exclusion_tags, $param_exclusion_tags_boolean
end

script "js_rds_instances", type: "javascript" do
parameters "ds_rds_instances_set", "ds_resource_tags", "param_exclusion_tags", "param_exclusion_tags_boolean"
parameters "ds_rds_instances_set", "ds_resource_tags", "ds_aws_instance_size_map", "param_exclusion_tags", "param_exclusion_tags_boolean"
result "result"
code <<-EOS
comparators = _.map(param_exclusion_tags, function(item) {
Expand Down Expand Up @@ -687,6 +695,21 @@ script "js_rds_instances", type: "javascript" do
tag_string = tag_string.join(', ')
vcpus = null
if (instance["processorFeatures"] != null && instance["processorFeatures"] != undefined) {
cores = _.findWhere(instance["processorFeatures"], { "name": "coreCount" })
threads = _.findWhere(instance["processorFeatures"], { "name": "threadsPerCore" })
if (cores != undefined && threads != undefined) {
vcpus = cores["value"] * threads["value"]
}
}
if (vcpus == null && ds_aws_instance_size_map[instance["resourceType"]] != undefined) {
vcpus = ds_aws_instance_size_map[instance["resourceType"]]["vcpu"]
}
result.push({
instanceId: instance['instanceId'],
instanceArn: instance['instanceArn'],
Expand All @@ -697,6 +720,10 @@ script "js_rds_instances", type: "javascript" do
engineVersion: instance['engineVersion'],
privateDnsName: instance['privateDnsName'],
region: instance['region'],
availabilityZone: instance['availabilityZone'],
licenseModel: instance['licenseModel'],
processorFeatures: instance['processorFeatures'],
vcpus: vcpus,
tags: tag_string
})
}
Expand Down Expand Up @@ -882,6 +909,10 @@ script "js_rds_idle_instances", type: "javascript" do
privateDnsName: instance['privateDnsName'],
region: instance['region'],
tags: instance['tags'],
availabilityZone: instance['availabilityZone'],
licenseModel: instance['licenseModel'],
processorFeatures: instance['processorFeatures'],
vcpus: instance['vcpus'],
savings: savings,
instance_activity: instance_activity
})
Expand Down Expand Up @@ -1120,6 +1151,10 @@ script "js_rds_nonidle_instances_with_metrics", type: "javascript" do
privateDnsName: instance['privateDnsName'],
region: instance['region'],
tags: instance['tags'],
availabilityZone: instance['availabilityZone'],
licenseModel: instance['licenseModel'],
processorFeatures: instance['processorFeatures'],
vcpus: instance['vcpus'],
savings: savings,
newResourceType: newResourceType
}
Expand Down Expand Up @@ -1329,6 +1364,10 @@ script "js_rds_idle_incident", type: "javascript" do
databaseEngine: instance['databaseEngine'],
platform: instance['databaseEngine'],
engineVersion: instance['engineVersion'],
availabilityZone: instance['availabilityZone'],
licenseModel: instance['licenseModel'],
processorFeatures: instance['processorFeatures'],
vcpus: instance['vcpus'],
savings: parseFloat(savings.toFixed(3)),
savingsCurrency: ds_currency['symbol'],
lookbackPeriod: param_stats_lookback,
Expand Down Expand Up @@ -1456,6 +1495,10 @@ script "js_rds_underutil_incident", type: "javascript" do
cpuP99: instance['cpu_p99'],
cpuP95: instance['cpu_p95'],
cpuP90: instance['cpu_p90'],
availabilityZone: instance['availabilityZone'],
licenseModel: instance['licenseModel'],
processorFeatures: instance['processorFeatures'],
vcpus: instance['vcpus'],
savings: parseFloat(savings.toFixed(3)),
savingsCurrency: ds_currency['symbol'],
lookbackPeriod: param_stats_lookback,
Expand Down Expand Up @@ -1563,6 +1606,9 @@ policy "pol_rightsize_rds" do
field "region" do
label "Region"
end
field "availabilityZone" do
label "Availability Zone"
end
field "state" do
label "State"
end
Expand Down Expand Up @@ -1605,6 +1651,12 @@ policy "pol_rightsize_rds" do
field "engineVersion" do
label "Engine Version"
end
field "vcpus" do
label "vCPUs"
end
field "licenseModel" do
label "License Model"
end
field "arn" do
label "ARN"
end
Expand Down Expand Up @@ -1658,6 +1710,9 @@ policy "pol_rightsize_rds" do
field "region" do
label "Region"
end
field "availabilityZone" do
label "Availability Zone"
end
field "state" do
label "State"
end
Expand All @@ -1679,6 +1734,12 @@ policy "pol_rightsize_rds" do
field "engineVersion" do
label "Engine Version"
end
field "vcpus" do
label "vCPUs"
end
field "licenseModel" do
label "License Model"
end
field "arn" do
label "ARN"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tenancy "single"
default_frequency "15 minutes"
info(
provider: "AWS",
version: "5.0", # This version of the Meta Parent Policy Template should match the version of the Child Policy Template as it appears in the Catalog for best reliability
version: "5.1", # This version of the Meta Parent Policy Template should match the version of the Child Policy Template as it appears in the Catalog for best reliability
publish: "false"
)

Expand Down Expand Up @@ -931,6 +931,9 @@ policy "policy_scheduled_report" do
field "region" do
label "Region"
end
field "availabilityZone" do
label "Availability Zone"
end
field "state" do
label "State"
end
Expand Down Expand Up @@ -973,6 +976,12 @@ policy "policy_scheduled_report" do
field "engineVersion" do
label "Engine Version"
end
field "vcpus" do
label "vCPUs"
end
field "licenseModel" do
label "License Model"
end
field "arn" do
label "ARN"
end
Expand Down Expand Up @@ -1023,6 +1032,9 @@ policy "policy_scheduled_report" do
field "region" do
label "Region"
end
field "availabilityZone" do
label "Availability Zone"
end
field "state" do
label "State"
end
Expand All @@ -1044,6 +1056,12 @@ policy "policy_scheduled_report" do
field "engineVersion" do
label "Engine Version"
end
field "vcpus" do
label "vCPUs"
end
field "licenseModel" do
label "License Model"
end
field "arn" do
label "ARN"
end
Expand Down

0 comments on commit 051d7ee

Please sign in to comment.