Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
partitionKey: { name: "pk", type: dynamodb.AttributeType.STRING },
sortKey: { name: "sk", type: dynamodb.AttributeType.STRING },
timeToLiveAttribute: "expires_at",
});
// ----------------------------------------------------------------
// Messaging Channels
this.alertTopic = new sns.Topic(this, "alertTopic");
this.taskTopic = new sns.Topic(this, "taskTopic");
this.contentTopic = new sns.Topic(this, "contentTopic");
this.attributeTopic = new sns.Topic(this, "attributeTopic");
this.reportTopic = new sns.Topic(this, "reportTopic");
const alertQueueTimeout = cdk.Duration.seconds(30);
this.alertQueue = new sqs.Queue(this, "alertQueue", {
visibilityTimeout: alertQueueTimeout,
});
this.alertTopic.addSubscription(new SqsSubscription(this.alertQueue));
const contentQueueTimeout = cdk.Duration.seconds(30);
this.contentQueue = new sqs.Queue(this, "contentQueue", {
visibilityTimeout: contentQueueTimeout,
});
const attributeQueueTimeout = cdk.Duration.seconds(30);
this.attributeQueue = new sqs.Queue(this, "attributeQueue", {
visibilityTimeout: attributeQueueTimeout,
});
// ----------------------------------------------------------------
// Lambda Functions
maxAZs: 2,
natGateways: 1
});
// Create an ECS cluster
this.cluster = new ecs.Cluster(this, 'cluster', {
vpc: this.vpc
});
// Create S3 bucket
this.screenshotBucket = new s3.Bucket(this, 'screenshot-bucket', {
publicReadAccess: true
});
// Create queue
this.screenshotQueue = new sqs.Queue(this, 'screenshot-queue');
// Create DynamoDB table
this.screenshotTable = new dynamodb.Table(this, 'screenshots', {
partitionKey: { name: 'id', type: dynamodb.AttributeType.String },
billingMode: dynamodb.BillingMode.PayPerRequest
});
}
}
constructor(scope: Construct, id: string, props: QueueProcessingServiceBaseProps) {
super(scope, id);
if (props.cluster && props.vpc) {
throw new Error(`You can only specify either vpc or cluster. Alternatively, you can leave both blank`);
}
this.cluster = props.cluster || this.getDefaultCluster(this, props.vpc);
// Create the SQS queue if one is not provided
this.sqsQueue = props.queue !== undefined ? props.queue : new Queue(this, 'EcsProcessingQueue', {});
// Setup autoscaling scaling intervals
const defaultScalingSteps = [{ upper: 0, change: -1 }, { lower: 100, change: +1 }, { lower: 500, change: +5 }];
this.scalingSteps = props.scalingSteps !== undefined ? props.scalingSteps : defaultScalingSteps;
// Create log driver if logging is enabled
const enableLogging = props.enableLogging !== undefined ? props.enableLogging : true;
this.logDriver = props.logDriver !== undefined
? props.logDriver
: enableLogging
? this.createAWSLogDriver(this.node.id)
: undefined;
// Add the queue name to environment variables
this.environment = { ...(props.environment || {}), QUEUE_NAME: this.sqsQueue.queueName };
this.secrets = props.secrets;
this.attributeTopic = new sns.Topic(this, "attributeTopic");
this.reportTopic = new sns.Topic(this, "reportTopic");
const alertQueueTimeout = cdk.Duration.seconds(30);
this.alertQueue = new sqs.Queue(this, "alertQueue", {
visibilityTimeout: alertQueueTimeout,
});
this.alertTopic.addSubscription(new SqsSubscription(this.alertQueue));
const contentQueueTimeout = cdk.Duration.seconds(30);
this.contentQueue = new sqs.Queue(this, "contentQueue", {
visibilityTimeout: contentQueueTimeout,
});
const attributeQueueTimeout = cdk.Duration.seconds(30);
this.attributeQueue = new sqs.Queue(this, "attributeQueue", {
visibilityTimeout: attributeQueueTimeout,
});
// ----------------------------------------------------------------
// Lambda Functions
const baseEnvVars = {
TASK_TOPIC: this.taskTopic.topicArn,
REPORT_TOPIC: this.reportTopic.topicArn,
CACHE_TABLE: this.cacheTable.tableName,
};
const nodeModulesLayer = new lambda.LayerVersion(this, "NodeModulesLayer", {
code: lambda.AssetCode.fromAsset("????"),
compatibleRuntimes: [lambda.Runtime.NODEJS_10_X],
});
this.recvAlert = new NodejsFunction(this, "recvAlert", {
entry: path.join(__dirname, "lambda/recvAlert.js"),
// ----------------------------------------------------------------
// Messaging Channels
this.alertTopic = new sns.Topic(this, "alertTopic");
this.taskTopic = new sns.Topic(this, "taskTopic");
this.contentTopic = new sns.Topic(this, "contentTopic");
this.attributeTopic = new sns.Topic(this, "attributeTopic");
this.reportTopic = new sns.Topic(this, "reportTopic");
const alertQueueTimeout = cdk.Duration.seconds(30);
this.alertQueue = new sqs.Queue(this, "alertQueue", {
visibilityTimeout: alertQueueTimeout,
});
this.alertTopic.addSubscription(new SqsSubscription(this.alertQueue));
const contentQueueTimeout = cdk.Duration.seconds(30);
this.contentQueue = new sqs.Queue(this, "contentQueue", {
visibilityTimeout: contentQueueTimeout,
});
const attributeQueueTimeout = cdk.Duration.seconds(30);
this.attributeQueue = new sqs.Queue(this, "attributeQueue", {
visibilityTimeout: attributeQueueTimeout,
});
// ----------------------------------------------------------------
// Lambda Functions
const baseEnvVars = {
TASK_TOPIC: this.taskTopic.topicArn,
REPORT_TOPIC: this.reportTopic.topicArn,
CACHE_TABLE: this.cacheTable.tableName,
};
const nodeModulesLayer = new lambda.LayerVersion(this, "NodeModulesLayer", {