-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Auto-remediation for check EKS-001 #67
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry about the delay PR review.
Left some comments and please let me know if any problem.
return handleError('Invalid event') | ||
} | ||
|
||
const clustername=event.resource.split('/')[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const clustername=event.resource.split('/')[1]; | |
const resourceItems = event.resource.split('/'); | |
if (resourceItems.length<1){ | |
return handleError('Invalid resource'); | |
} | |
const clustername=resourceItems[1]; |
} | ||
}; | ||
|
||
let eks = new AWS.EKS({region: event.region}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let eks = new AWS.EKS({region: event.region}) | |
const eks = new AWS.EKS({region: event.region}) |
if (err) console.log(err, err.stack); // an error occurred | ||
else console.log(data); // successful response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These if
condition can be removed because line 29 handles it
if (err) console.log(err, err.stack); // an error occurred | |
else console.log(data); // successful response | |
|
||
let eks = new AWS.EKS({region: event.region}) | ||
|
||
eks.updateClusterConfig(params, function(err, data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest to use asynchronous flow instead of using callbacks.
ref: https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/using-promises.html
|
||
module.exports.handler = (event, context, callback) => { | ||
console.log('Received event: ', JSON.stringify(event, null, 2)) | ||
console.log('Config settings: ', JSON.stringify(CONFIG, null, 2)) | ||
//console.log('Config settings: ', JSON.stringify(CONFIG, null, 2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unused code
//console.log('Config settings: ', JSON.stringify(CONFIG, null, 2)) | |
else{ | ||
|
||
//Compose the function name based on its own name... | ||
let FunctionName = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let FunctionName = | |
const FunctionName = |
Properties: | ||
MessageRetentionPeriod: 7200 #2 Hours | ||
QueueName: CloudConformityAutoRemediate | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SQS queue must be encrypted at rest. Please configure KMS KeyId in the queue property
'region': 'us-east-1' | ||
} | ||
|
||
let AutoRemediate = require('../functions/AutoRemediateEKS-001') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let AutoRemediate = require('../functions/AutoRemediateEKS-001') | |
const AutoRemediate = require('../functions/AutoRemediateEKS-001') |
@@ -0,0 +1,11 @@ | |||
let event = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let event = { | |
const event = { |
|
||
let AutoRemediate = require('../functions/AutoRemediateEKS-001') | ||
|
||
AutoRemediate.handler(event, {}, function (err, data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add valid unit tests here.
Add auto-remediation for check EKS-001.
LambdaVersion
had to be disabled in serverless.yaml to support the number of resources needed.