-
Notifications
You must be signed in to change notification settings - Fork 162
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
Improving AWS Config security pattern #172
Improving AWS Config security pattern #172
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.
Gret work, a few comments.
console.log(err, err.stack); | ||
} else { | ||
if (data.ConfigurationRecorders?.length === 0) { | ||
console.log("AWS Config is not enabled in this 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.
Can you specify the region as opposed to "this"?
const awsConfig = new AWS.ConfigService(); | ||
awsConfig.describeConfigurationRecorders({}, (err, data) => { | ||
if (err) { | ||
console.log(err, err.stack); |
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 use logger from blueprints for error messages and info messages, otherwise there is no control to suppress and elevate these.
const logger = blueprints.utils.logger;
applies elsewhere
}); | ||
// Check if AWS Config is already enabled in the region | ||
const awsConfig = new AWS.ConfigService(); | ||
awsConfig.describeConfigurationRecorders({}, (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.
it is getting a bit hard to maintain if you use this callback style (callback hell). Let's use async/await and this style of SDK invocation:
import { DescribeConfigurationRecordersCommand } from "@aws-sdk/client-config-service";
const command = new DescribeConfigurationRecordersCommand(input);
const response = await client.send(command);
You can use try/catch with this. You will need to move this code away from the constructor as constructor can have async.
It is a minor change, example here but it will improve readability and maintenance.
@shapirov103 addressed |
|
||
const logger = blueprints.utils.logger; | ||
|
||
(async () => { |
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.
@aliaksei-ivanou let's move it to a method like async buildConfigStack
and remove => and such.
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.
Addressed
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.
LGTM, great work!
Issue #, if available:
Description of changes:
a. Check if AWS Config recorder is already enabled in the target account and region.
b. Check if a delivery channel is already configured in the target account and region.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.