Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cpu: 256,
environment: {
CHANGELOGS_TABLE_NAME: props.changelogsTable.tableName,
DISCOVERED_TOPIC_NAME: props.toCrawlTopic.topicArn
},
logging: new ecs.AwsLogDriver({
streamPrefix: 'npm-follower'
})
});
// Grant this application access to the DynamoDB table and SNS topic
props.changelogsTable.grantReadWriteData(followerDefinition.taskRole);
props.toCrawlTopic.grantPublish(followerDefinition.taskRole);
// Launch the image as a service in Fargate
this.npmFollower = new ecs.FargateService(this, 'NpmFollower', {
assignPublicIp: true,
cluster: props.cluster, // Required
cpu: '256',
memoryMiB: '512',
desiredCount: 1,
taskDefinition: followerDefinition,
createLogs: false
});
}
}
// Create a Task Definition for the container to start
this.taskDefinition = new FargateTaskDefinition(this, 'QueueProcessingTaskDef', {
memoryLimitMiB: props.memoryLimitMiB || 512,
cpu: props.cpu || 256,
});
this.taskDefinition.addContainer('QueueProcessingContainer', {
image: props.image,
command: props.command,
environment: this.environment,
secrets: this.secrets,
logging: this.logDriver
});
// Create a Fargate service with the previously defined Task Definition and configure
// autoscaling based on cpu utilization and number of messages visible in the SQS queue.
this.service = new FargateService(this, 'QueueProcessingFargateService', {
cluster: this.cluster,
desiredCount: this.desiredCount,
taskDefinition: this.taskDefinition,
propagateTags: props.propagateTags,
enableECSManagedTags: props.enableECSManagedTags,
});
this.configureAutoscalingForService(this.service);
}
}
const containerName = taskImageOptions.containerName !== undefined ? taskImageOptions.containerName : 'web';
const container = this.taskDefinition.addContainer(containerName, {
image: taskImageOptions.image,
logging: logDriver,
environment: taskImageOptions.environment,
secrets: taskImageOptions.secrets,
});
container.addPortMappings({
containerPort: taskImageOptions.containerPort || 80,
});
} else {
throw new Error('You must specify one of: taskDefinition or image');
}
this.service = new FargateService(this, "Service", {
cluster: this.cluster,
desiredCount: this.desiredCount,
taskDefinition: this.taskDefinition,
assignPublicIp: this.assignPublicIp,
serviceName: props.serviceName,
healthCheckGracePeriod: props.healthCheckGracePeriod,
minHealthyPercent: props.minHealthyPercent,
maxHealthyPercent: props.maxHealthyPercent,
propagateTags: props.propagateTags,
enableECSManagedTags: props.enableECSManagedTags,
cloudMapOptions: props.cloudMapOptions,
});
this.addServiceAsTarget(this.service);
}
}
image: ecs.ContainerImage.fromAsset(this, 'worker-image', {
directory: './worker'
}),
cpu: 2048,
memoryLimitMiB: 4096,
environment: {
QUEUE_URL: props.screenshotQueue.queueUrl,
TABLE: props.screenshotTable.tableName,
BUCKET: props.screenshotBucket.bucketName
},
logging: new ecs.AwsLogDriver(this, 'worker-logs', {
streamPrefix: 'worker'
})
});
this.worker = new ecs.FargateService(this, 'worker', {
cluster: props.cluster,
desiredCount: 2,
taskDefinition: this.workerDefinition
});
props.screenshotQueue.grantConsumeMessages(this.workerDefinition.taskRole);
props.screenshotTable.grantReadWriteData(this.workerDefinition.taskRole);
props.screenshotBucket.grantReadWrite(this.workerDefinition.taskRole);
}
}
const containerName = taskImageOptions.containerName !== undefined ? taskImageOptions.containerName : 'web';
const container = this.taskDefinition.addContainer(containerName, {
image: taskImageOptions.image,
logging: logDriver,
environment: taskImageOptions.environment,
secrets: taskImageOptions.secrets,
});
container.addPortMappings({
containerPort: taskImageOptions.containerPort || 80,
});
} else {
throw new Error('You must specify one of: taskDefinition or image');
}
this.service = new FargateService(this, "Service", {
cluster: this.cluster,
desiredCount: this.desiredCount,
taskDefinition: this.taskDefinition,
assignPublicIp: this.assignPublicIp,
serviceName: props.serviceName,
healthCheckGracePeriod: props.healthCheckGracePeriod,
minHealthyPercent: props.minHealthyPercent,
maxHealthyPercent: props.maxHealthyPercent,
propagateTags: props.propagateTags,
enableECSManagedTags: props.enableECSManagedTags,
cloudMapOptions: props.cloudMapOptions,
});
this.addServiceAsTarget(this.service);
}
}