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

AV-2187: First draft of clamav scanner CDK port #2272

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
AV-2187: Use SNS topic for all zulip messages
  • Loading branch information
bzar committed Jun 20, 2024
commit 507d0ca1829901ba6d693bc460b87ba7b21aa73b
4 changes: 2 additions & 2 deletions cdk/bin/opendata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ const webStackBeta = new WebStack(app, 'WebStack-beta', {
});

const monitoringStackBeta = new MonitoringStack(app, 'MonitoringStack-beta', {
sendToZulipLambda: lambdaStackBeta.sendToZulipLambda,
sendToZulipTopic: lambdaStackBeta.sendToZulipTopic,
env: {
account: betaProps.account,
region: betaProps.region,
Expand Down Expand Up @@ -717,7 +717,7 @@ const webStackProd = new WebStack(app, 'WebStack-prod', {
});

const monitoringStackProd = new MonitoringStack(app, 'MonitoringStack-prod', {
sendToZulipLambda: lambdaStackProd.sendToZulipLambda,
sendToZulipTopic: lambdaStackProd.sendToZulipTopic,
env: {
account: prodProps.account,
region: prodProps.region,
Expand Down
4 changes: 2 additions & 2 deletions cdk/lib/clamav-scanner-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Fn, Stack,
aws_ssm as ssm,
aws_s3 as s3,
aws_s3_notifications as s3n,
aws_lambda_nodejs as lambda_nodejs
aws_lambda_nodejs as lambdaNodejs
} from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { ClamavScannerStackProps } from './clamav-scanner-stack-props';
Expand All @@ -14,7 +14,7 @@ import { ClamavScan } from './clamav-scan';

export class ClamavScannerStack extends Stack {

readonly lambda: lambda_nodejs.NodejsFunction;
readonly lambda: lambdaNodejs.NodejsFunction;

constructor(scope: Construct, id: string, props: ClamavScannerStackProps) {
super(scope, id, props);
Expand Down
5 changes: 1 addition & 4 deletions cdk/lib/lambda-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import {Stack} from "aws-cdk-lib";
import {Construct} from "constructs";
import {LambdaStackProps} from "./lambda-stack-props";
import { SendToZulip } from "./send-to-zulip";
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
import {Credentials} from "aws-cdk-lib/aws-rds";
import { Topic } from "aws-cdk-lib/aws-sns";
import { LambdaSubscription } from 'aws-cdk-lib/aws-sns-subscriptions';

export class LambdaStack extends Stack {
readonly sendToZulipLambda: NodejsFunction;
readonly sendToZulipTopic: Topic;
readonly datastoreJobsCredentials: Credentials;
readonly datastoreReadCredentials: Credentials;
Expand Down Expand Up @@ -37,9 +35,8 @@ export class LambdaStack extends Stack {
env: props.env,
environment: props.environment,
});
this.sendToZulipLambda = sendToZulip.lambda;

this.sendToZulipTopic = new Topic(this, 'monitoringTopic');
this.sendToZulipTopic.addSubscription(new LambdaSubscription(this.sendToZulipLambda));
this.sendToZulipTopic.addSubscription(new LambdaSubscription(sendToZulip.lambda));
}
}
4 changes: 2 additions & 2 deletions cdk/lib/monitoring-stack-props.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
import { aws_sns as sns } from 'aws-cdk-lib';
import {EnvStackProps} from "./env-stack-props";

export interface MonitoringStackProps extends EnvStackProps {
sendToZulipLambda: NodejsFunction
sendToZulipTopic: sns.Topic
}

14 changes: 6 additions & 8 deletions cdk/lib/monitoring-stack.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Stack } from 'aws-cdk-lib';
import { ITopic, Topic } from "aws-cdk-lib/aws-sns";
import { Stack,
aws_events as events,
aws_events_targets as eventsTargets,
aws_logs as logs
} from 'aws-cdk-lib';
import { MonitoringStackProps } from './monitoring-stack-props';

import * as events from 'aws-cdk-lib/aws-events';
import * as eventsTargets from 'aws-cdk-lib/aws-events-targets';
import * as logs from 'aws-cdk-lib/aws-logs';

import { Construct } from 'constructs';

export class MonitoringStack extends Stack {
Expand All @@ -18,7 +16,7 @@ export class MonitoringStack extends Stack {
});

// Eventbridge rule to send
const sendToDeveloperZulipTarget = new eventsTargets.LambdaFunction(props.sendToZulipLambda, {});
const sendToDeveloperZulipTarget = new eventsTargets.SnsTopic(props.sendToZulipTopic, {});
const taskHealthCheckFailLogGroupTarget = new eventsTargets.CloudWatchLogGroup(taskHealthCheckFailLogGroup);

new events.Rule(this, 'taskHealthCheckFailedRule', {
Expand Down
Loading