Skip to content

Commit 8bc2ddc

Browse files
committed
Made few changes
1 parent 6b44c1c commit 8bc2ddc

2 files changed

Lines changed: 18 additions & 16 deletions

File tree

‎plugins/aws/computeoptimizer/asgOptimized.js‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ module.exports = {
55
title: 'Auto Scaling Group Optimized',
66
category: 'Compute Optimizer',
77
domain: 'Management and Governance',
8-
description: 'Ensure that Compute Optimizer ASGs findings are in order to take the actions to optimize Amazon Auto Scaling groups that are under-performing.',
8+
description: 'Ensure that Compute Optimizer does not have active recommendation summaries for unoptimized Auto Scaling groups.',
99
more_info: 'An Auto Scaling group is considered optimized when Compute Optimizer determines that the group is correctly provisioned to run your workload, based on the chosen instance type. For optimized Auto Scaling groups, Compute Optimizer might sometimes recommend a new generation instance type.',
1010
link: 'https://docs.aws.amazon.com/compute-optimizer/latest/ug/view-asg-recommendations.html',
11-
recommended_action: 'Enable Compute Optimizer Opt In options for Auto Scaling Groups recommendations',
11+
recommended_action: 'Resolve Compute Optimizer recommendations for Auto Scaling groups.',
1212
apis: ['ComputeOptimizer:getRecommendationSummaries'],
1313

1414
run: function(cache, settings, callback) {
@@ -22,8 +22,9 @@ module.exports = {
2222

2323
if (!getRecommendationSummaries) return rcb();
2424

25-
if (getRecommendationSummaries && getRecommendationSummaries.err &&
26-
getRecommendationSummaries.err.code === 'OptInRequiredException'){
25+
if (getRecommendationSummaries && getRecommendationSummaries.err &&
26+
getRecommendationSummaries.err.code &&
27+
getRecommendationSummaries.err.code.toUpperCase() === 'OPTINREQUIREDEXCEPTION'){
2728
helpers.addResult(results, 0,
2829
'Compute Optimizer is not enabled', region);
2930
return rcb();
@@ -37,29 +38,30 @@ module.exports = {
3738

3839
if (!getRecommendationSummaries.data.length) {
3940
helpers.addResult(results, 0,
40-
'Optimization for summaries is not configured', region);
41+
'No Compute Optimizer recommendation summaries found', region);
4142
return rcb();
4243
}
4344

44-
let findings = getRecommendationSummaries.data.find(resourceType => resourceType.recommendationResourceType === 'AutoScalingGroup');
45+
let findings = getRecommendationSummaries.data.find(resourceType => resourceType.recommendationResourceType &&
46+
resourceType.recommendationResourceType.toUpperCase() === 'AUTOSCALINGGROUP');
4547
if (findings) {
4648

4749
let notOptimized = findings.summaries.find(notOpt => notOpt.name && notOpt.name.toUpperCase() === 'NOT_OPTIMIZED');
4850
let Optimized = findings.summaries.find(opt => opt.name && opt.name.toUpperCase() === 'OPTIMIZED');
4951

5052
if (!notOptimized.value && !Optimized.value){
5153
helpers.addResult(results, 0,
52-
'Auto Scaling Groups have no recommendations enabled', region);
54+
'No recommendations found for Auto Scaling groups', region);
5355
} else if (notOptimized.value){
5456
helpers.addResult(results, 2,
55-
`Auto Scaling Groups are not optimized, NOT_OPTIMIZED: ${notOptimized.value}`, region);
57+
`Found ${notOptimized.value} unoptimized Auto Scaling groups`, region);
5658
} else {
5759
helpers.addResult(results, 0,
58-
'All Auto Scaling Groups are optimized', region);
60+
'All Auto Scaling groups are optimized', region);
5961
}
6062
} else {
6163
helpers.addResult(results, 2,
62-
'No Auto Scaling Group configured', region);
64+
'Recommendation summaries are not configured for Auto Scaling groups', region);
6365
}
6466

6567
rcb();

‎plugins/aws/computeoptimizer/asgOptimized.spec.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('asgOptimized', function () {
8686
expect(results.length).to.equal(1);
8787
expect(results[0].status).to.equal(0);
8888
expect(results[0].region).to.equal('us-east-1');
89-
expect(results[0].message).to.include('All Auto Scaling Groups are optimized');
89+
expect(results[0].message).to.include('All Auto Scaling groups are optimized');
9090
done();
9191
});
9292
});
@@ -97,29 +97,29 @@ describe('asgOptimized', function () {
9797
expect(results.length).to.equal(1);
9898
expect(results[0].status).to.equal(2);
9999
expect(results[0].region).to.equal('us-east-1');
100-
expect(results[0].message).to.include('Auto Scaling Groups are not optimized');
100+
expect(results[0].message).to.include('unoptimized Auto Scaling groups');
101101
done();
102102
});
103103
});
104104

105-
it('should PASS if Auto Scaling Groups have no recommendations enabled', function (done) {
105+
it('should PASS if no recommendations found for Auto Scaling groups', function (done) {
106106
const cache = createCache([getRecommendationSummaries[2]]);
107107
asgOptimized.run(cache, {}, (err, results) => {
108108
expect(results.length).to.equal(1);
109109
expect(results[0].status).to.equal(0);
110110
expect(results[0].region).to.equal('us-east-1');
111-
expect(results[0].message).to.include('Auto Scaling Groups have no recommendations enabled');
111+
expect(results[0].message).to.include('No recommendations found for Auto Scaling groups');
112112
done();
113113
});
114114
});
115115

116-
it('should PASS if Optimization for summaries is not configured', function (done) {
116+
it('should PASS if no Compute Optimizer recommendation summaries found', function (done) {
117117
const cache = createCache([]);
118118
asgOptimized.run(cache, {}, (err, results) => {
119119
expect(results.length).to.equal(1);
120120
expect(results[0].status).to.equal(0);
121121
expect(results[0].region).to.equal('us-east-1');
122-
expect(results[0].message).to.include('Optimization for summaries is not configured');
122+
expect(results[0].message).to.include('No Compute Optimizer recommendation summaries found');
123123
done();
124124
});
125125
});

0 commit comments

Comments
 (0)