Skip to content

Commit f101aed

Browse files
committed
fix: CSR Comments (encryption at rest, in transit, auth scheme)
1 parent be95f99 commit f101aed

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

lib/cell-stack.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { SqsSubscription } from 'aws-cdk-lib/aws-sns-subscriptions';
55
import { EventConsumer } from './eventConsumer';
66
import { EventProducer } from './eventProducer';
77
import { EventRouter } from './eventRouter';
8-
import { Queue } from 'aws-cdk-lib/aws-sqs';
8+
import { Queue, QueueEncryption } from 'aws-cdk-lib/aws-sqs';
99
import { EventMonitoring } from './eventMonitoring';
1010
import { consumers } from 'stream';
1111

@@ -37,7 +37,10 @@ export class CellStack extends cdk.Stack {
3737
this.consumers.forEach(consumer => {
3838
const target = this.router.targets.find(target => target.type == consumer.type)!;
3939

40-
const deadLetterQueue = new Queue(this, consumer.node.id + consumer.type + 'DeadLetterQueue');
40+
const deadLetterQueue = new Queue(this, consumer.node.id + consumer.type + 'DeadLetterQueue', {
41+
encryption: QueueEncryption.SQS_MANAGED,
42+
enforceSSL: true
43+
});
4144
target.topic.addSubscription(new SqsSubscription(consumer.queue, {
4245
deadLetterQueue: deadLetterQueue
4346
}));

lib/eventConsumer.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { aws_iam, aws_lambda, Duration, PhysicalName } from "aws-cdk-lib";
22
import { Metric } from "aws-cdk-lib/aws-cloudwatch";
3-
import { Queue } from "aws-cdk-lib/aws-sqs";
3+
import { Queue, QueueEncryption } from "aws-cdk-lib/aws-sqs";
44
import { Construct } from "constructs";
55

66
export const EventQueueConsumerEvents = ['ingestion', 'reconciliation', 'authorization', 'posting'] as const;
@@ -22,11 +22,15 @@ export class EventConsumer extends Construct {
2222
this.type = props.type;
2323

2424
const deadLetterQueue = new Queue(this, id + 'DeadLetterQueue', {
25-
queueName: PhysicalName.GENERATE_IF_NEEDED
25+
queueName: PhysicalName.GENERATE_IF_NEEDED,
26+
encryption: QueueEncryption.SQS_MANAGED,
27+
enforceSSL: true
2628
});
2729

2830
// create a queue with a dead letter queue attached
2931
this.queue = new Queue(this, id + 'EventsQueue', {
32+
encryption: QueueEncryption.SQS_MANAGED,
33+
enforceSSL: true,
3034
visibilityTimeout: Duration.seconds(30),
3135
deadLetterQueue: {
3236
maxReceiveCount: 3,

lib/eventMonitoring.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Queue } from 'aws-cdk-lib/aws-sqs';
88
import { EmailSubscription } from 'aws-cdk-lib/aws-sns-subscriptions';
99
import { Topic } from 'aws-cdk-lib/aws-sns';
1010
import { ServicePrincipal } from 'aws-cdk-lib/aws-iam';
11+
import { Key } from 'aws-cdk-lib/aws-kms';
1112

1213
export interface EventMonitoringProps {
1314
router: EventRouter;
@@ -332,7 +333,9 @@ export class EventMonitoring extends Construct {
332333

333334
// Create SNS topic for alarms
334335
const alarmTopic = new Topic(this, 'AlarmTopic', {
335-
displayName: 'Event Monitoring Alarms'
336+
displayName: 'Event Monitoring Alarms',
337+
enforceSSL: true,
338+
masterKey: new Key(scope, id + "Key"),
336339
});
337340
// Add email subscription
338341
alarmTopic.addSubscription(new EmailSubscription('[email protected]'));

lib/eventProducer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ export class EventProducer extends Construct {
120120

121121
// add request to all routes
122122
const businessEventPost: MethodOptions = {
123-
// Change to your preferred type
123+
// WARNING: For production APIs, we recommend an
124+
// authorization strategy as a security best practice.
125+
// We use IAM here as this is a sample API.
124126
authorizationType: AuthorizationType.IAM,
125127
requestParameters: {
126128
"method.request.header.Authorization": true,

lib/eventRouter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { EventQueueConsumerEvents, EventQueueConsumerEventType } from "./eventCo
77
import { Duration, PhysicalName, RemovalPolicy } from "aws-cdk-lib";
88
import { LogGroup, RetentionDays } from "aws-cdk-lib/aws-logs";
99
import { Queue } from "aws-cdk-lib/aws-sqs";
10+
import { Key } from "aws-cdk-lib/aws-kms";
1011

1112
export type EventRouterProps = {
1213

@@ -101,6 +102,8 @@ export class EventRouter extends Construct {
101102
// Create the SNS topic
102103
const topic = new Topic(stack, name + 'Topic', {
103104
...props,
105+
enforceSSL: true,
106+
masterKey: new Key(stack, name + "Key"),
104107
loggingConfigs: [{
105108
protocol: LoggingProtocol.SQS,
106109
successFeedbackRole: successFeedbackRole,

0 commit comments

Comments
 (0)