Add Auto-remediation for check EKS-001 #67
Add Auto-remediation for check EKS-001 #67gmagella-ca wants to merge 3 commits intocloudconformity:mainfrom
Conversation
binli0114
left a comment
There was a problem hiding this comment.
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.
| 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.
| 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.
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.
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.
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.
| let FunctionName = | |
| const FunctionName = |
| Properties: | ||
| MessageRetentionPeriod: 7200 #2 Hours | ||
| QueueName: CloudConformityAutoRemediate | ||
|
|
There was a problem hiding this comment.
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.
| 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.
| let event = { | |
| const event = { |
|
|
||
| let AutoRemediate = require('../functions/AutoRemediateEKS-001') | ||
|
|
||
| AutoRemediate.handler(event, {}, function (err, data) { |
There was a problem hiding this comment.
Please add valid unit tests here.
Add auto-remediation for check EKS-001.
LambdaVersionhad to be disabled in serverless.yaml to support the number of resources needed.