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

fix(logs): DataProtectionPolicy not displaying properly in console #26736

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions packages/aws-cdk-lib/aws-logs/lib/data-protection-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ export class DataProtectionPolicy {
* @internal
*/
public _bind(_scope: Construct): DataProtectionPolicyConfig {
const name = this.dataProtectionPolicyProps.name || 'data-protection-policy-cdk';
const description = this.dataProtectionPolicyProps.description || 'cdk generated data protection policy';
const version = '2021-06-01';
const Name = this.dataProtectionPolicyProps.name || 'data-protection-policy-cdk';
const Description = this.dataProtectionPolicyProps.description || 'cdk generated data protection policy';
const Version = '2021-06-01';

const findingsDestination: FindingsDestination = {};
if (this.dataProtectionPolicyProps.logGroupAuditDestination) {
findingsDestination.cloudWatchLogs = {
logGroup: this.dataProtectionPolicyProps.logGroupAuditDestination.logGroupName,
findingsDestination.CloudWatchLogs = {
LogGroup: this.dataProtectionPolicyProps.logGroupAuditDestination.logGroupName,
};
}

if (this.dataProtectionPolicyProps.s3BucketAuditDestination) {
findingsDestination.s3 = {
bucket: this.dataProtectionPolicyProps.s3BucketAuditDestination.bucketName,
findingsDestination.S3 = {
Bucket: this.dataProtectionPolicyProps.s3BucketAuditDestination.bucketName,
};
}

if (this.dataProtectionPolicyProps.deliveryStreamNameAuditDestination) {
findingsDestination.firehose = {
deliveryStream: this.dataProtectionPolicyProps.deliveryStreamNameAuditDestination,
findingsDestination.Firehose = {
DeliveryStream: this.dataProtectionPolicyProps.deliveryStreamNameAuditDestination,
};
}

Expand All @@ -54,46 +54,46 @@ export class DataProtectionPolicy {
}));
};

const statement = [
const Statement = [
{
sid: 'audit-statement-cdk',
dataIdentifier: identifierArns,
operation: {
audit: {
findingsDestination: findingsDestination,
Sid: 'audit-statement-cdk',
DataIdentifier: identifierArns,
Operation: {
Audit: {
FindingsDestination: findingsDestination,
},
},
},
{
sid: 'redact-statement-cdk',
dataIdentifier: identifierArns,
operation: {
deidentify: {
maskConfig: {},
Sid: 'redact-statement-cdk',
DataIdentifier: identifierArns,
Operation: {
Deidentify: {
MaskConfig: {},
},
},
},
];
return { name, description, version, statement };
return { Name, Description, Version, Statement };
}
}

interface FindingsDestination {
cloudWatchLogs?: CloudWatchLogsDestination;
firehose?: FirehoseDestination;
s3?: S3Destination;
CloudWatchLogs?: CloudWatchLogsDestination;
Firehose?: FirehoseDestination;
S3?: S3Destination;
}

interface CloudWatchLogsDestination {
logGroup: string;
LogGroup: string;
}

interface FirehoseDestination {
deliveryStream: string;
DeliveryStream: string;
}

interface S3Destination {
bucket: string;
Bucket: string;
}

/**
Expand All @@ -105,24 +105,24 @@ export interface DataProtectionPolicyConfig {
*
* @default - 'data-protection-policy-cdk'
*/
readonly name: string;
readonly Name: string;

/**
* Description of the data protection policy
*
* @default - 'cdk generated data protection policy'
*/
readonly description: string;
readonly Description: string;

/**
* Version of the data protection policy
*/
readonly version: string;
readonly Version: string;

/**
* Statements within the data protection policy. Must contain one Audit and one Redact statement
*/
readonly statement: any;
readonly Statement: any;
}

/**
Expand Down
96 changes: 48 additions & 48 deletions packages/aws-cdk-lib/aws-logs/test/loggroup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,13 +478,13 @@ describe('log group', () => {
Template.fromStack(stack).hasResourceProperties('AWS::Logs::LogGroup', {
LogGroupName: logGroupName,
DataProtectionPolicy: {
name: 'test-policy-name',
description: 'test description',
version: '2021-06-01',
statement: [
Name: 'test-policy-name',
Description: 'test description',
Version: '2021-06-01',
Statement: [
{
sid: 'audit-statement-cdk',
dataIdentifier: [
Sid: 'audit-statement-cdk',
DataIdentifier: [
{
'Fn::Join': [
'',
Expand All @@ -496,15 +496,15 @@ describe('log group', () => {
],
},
],
operation: {
audit: {
findingsDestination: {},
Operation: {
Audit: {
FindingsDestination: {},
},
},
},
{
sid: 'redact-statement-cdk',
dataIdentifier: [
Sid: 'redact-statement-cdk',
DataIdentifier: [
{
'Fn::Join': [
'',
Expand All @@ -516,9 +516,9 @@ describe('log group', () => {
],
},
],
operation: {
deidentify: {
maskConfig: {},
Operation: {
Deidentify: {
MaskConfig: {},
},
},
},
Expand Down Expand Up @@ -548,13 +548,13 @@ describe('log group', () => {
Template.fromStack(stack).hasResourceProperties('AWS::Logs::LogGroup', {
LogGroupName: logGroupName,
DataProtectionPolicy: {
name: 'test-policy-name',
description: 'test description',
version: '2021-06-01',
statement: [
Name: 'test-policy-name',
Description: 'test description',
Version: '2021-06-01',
Statement: [
{
sid: 'audit-statement-cdk',
dataIdentifier: [
Sid: 'audit-statement-cdk',
DataIdentifier: [
{
'Fn::Join': [
'',
Expand All @@ -566,15 +566,15 @@ describe('log group', () => {
],
},
],
operation: {
audit: {
findingsDestination: {},
Operation: {
Audit: {
FindingsDestination: {},
},
},
},
{
sid: 'redact-statement-cdk',
dataIdentifier: [
Sid: 'redact-statement-cdk',
DataIdentifier: [
{
'Fn::Join': [
'',
Expand All @@ -586,9 +586,9 @@ describe('log group', () => {
],
},
],
operation: {
deidentify: {
maskConfig: {},
Operation: {
Deidentify: {
MaskConfig: {},
},
},
},
Expand Down Expand Up @@ -623,13 +623,13 @@ describe('log group', () => {
Template.fromStack(stack).hasResourceProperties('AWS::Logs::LogGroup', {
LogGroupName: logGroupName,
DataProtectionPolicy: {
name: 'data-protection-policy-cdk',
description: 'cdk generated data protection policy',
version: '2021-06-01',
statement: [
Name: 'data-protection-policy-cdk',
Description: 'cdk generated data protection policy',
Version: '2021-06-01',
Statement: [
{
sid: 'audit-statement-cdk',
dataIdentifier: [
Sid: 'audit-statement-cdk',
DataIdentifier: [
{
'Fn::Join': [
'',
Expand All @@ -641,19 +641,19 @@ describe('log group', () => {
],
},
],
operation: {
audit: {
findingsDestination: {
cloudWatchLogs: {
logGroup: {
Operation: {
Audit: {
FindingsDestination: {
CloudWatchLogs: {
LogGroup: {
Ref: 'LogGroupAudit2C8B7F73',
},
},
firehose: {
deliveryStream: auditDeliveryStreamName,
Firehose: {
DeliveryStream: auditDeliveryStreamName,
},
s3: {
bucket: {
S3: {
Bucket: {
Ref: 'BucketAudit1DED3529',
},
},
Expand All @@ -662,8 +662,8 @@ describe('log group', () => {
},
},
{
sid: 'redact-statement-cdk',
dataIdentifier: [
Sid: 'redact-statement-cdk',
DataIdentifier: [
{
'Fn::Join': [
'',
Expand All @@ -675,9 +675,9 @@ describe('log group', () => {
],
},
],
operation: {
deidentify: {
maskConfig: {},
Operation: {
Deidentify: {
MaskConfig: {},
},
},
},
Expand Down
Loading