Skip to content
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

feat(logs): Add KMS key support to LogGroup #11363

Merged
merged 6 commits into from
Nov 13, 2020

Conversation

nicklaw5
Copy link
Contributor

@nicklaw5 nicklaw5 commented Nov 9, 2020

This PR updates the LogGroup construct to support the ability to encrypt log groups on creation.

Closes #11211


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Nov 9, 2020

Comment on lines 60207 to 60212
"KmsKeyId": {
"Documentation": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html#cfn-logs-loggroup-kmskeyid",
"PrimitiveType": "String",
"Required": false,
"UpdateType": "Mutable"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spec changes are automated and not manually made -

the spec import is being done in #11319 ... let's wait for that to get merged and keep this change isolated to making the capability available

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Thanks 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicklaw5 it's been merged so updating your PR should allow us to simply consume the spec 🙂

Copy link
Contributor

@shivlaks shivlaks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicklaw5 - looked at the changes and they look great. I had some minor suggestions if you could take a look.

Let me know if you have any questions!!

*
* @default No KMS key
*/
readonly kmsKey?: IKey;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we commonly call this encryptionKey unless there's a need for multiple keys in which case we tend to prefix it with the qualifier that the key applies to.

Suggested change
readonly kmsKey?: IKey;
readonly encryptionKey?: IKey;

/**
* The KMS Key to encrypt the log group with.
*
* @default No KMS key
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this use the default master key if unspecified?
the default text should describe the behaviour - feel free to adjust if i'm reading it incorrectly.

Suggested change
* @default No KMS key
* @default - log group is encrypted with the default master key

Comment on lines 60 to 64
const kmsKey = new kms.Key(this, 'Key');

new LogGroup(this, 'LogGroup', {
kmsKey,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const kmsKey = new kms.Key(this, 'Key');
new LogGroup(this, 'LogGroup', {
kmsKey,
});
import * as kms from '@aws-cdk/aws-kms';
new LogGroup(this, 'LogGroup', {
kmsKey: new kms.Key(this, 'Key'),
});

@mergify mergify bot dismissed shivlaks’s stale review November 13, 2020 05:12

Pull request has been modified.

@nicklaw5
Copy link
Contributor Author

@shivlaks I've updated as per your review.

@@ -363,6 +371,7 @@ export class LogGroup extends LogGroupBase {
}

const resource = new CfnLogGroup(this, 'Resource', {
kmsKeyId: props.encryptionKey?.keyId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be using the ARN?
The docs indicate that it can. It would be more robust to use an ARN because the key might be in another account (some services allow it, I'm not sure about whether that's valid usage in this case)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Let me make that adjustment also.

Copy link
Contributor

@shivlaks shivlaks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicklaw5 looks great! i had one small comment re: using the ARN from the key for the keyId property

@mergify mergify bot dismissed shivlaks’s stale review November 13, 2020 05:40

Pull request has been modified.

Copy link
Contributor

@shivlaks shivlaks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome!! thanks for the contribution @nicklaw5 !!

@mergify
Copy link
Contributor

mergify bot commented Nov 13, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: e2af622
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Nov 13, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 21ccfce into aws:master Nov 13, 2020
@nicklaw5 nicklaw5 deleted the feature-logs-add-kmskey branch November 13, 2020 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[@aws-cdk/aws-logs] Add KmsKeyId to LogGroup
3 participants