Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
type Query {
all(limit: Int, nextToken: String): Paginated${tableName}!
getOne(${tableName}Id: ID!): ${tableName}
}
type Mutation {
save(name: String!): ${tableName}
delete(${tableName}Id: ID!): ${tableName}
}
type Schema {
query: Query
mutation: Mutation
}`
});
const itemsTable = new Table(this, 'ItemsTable', {
tableName: tableName,
partitionKey: {
name: `${tableName}Id`,
type: AttributeType.STRING
},
billingMode: BillingMode.PAY_PER_REQUEST,
stream: StreamViewType.NEW_IMAGE,
// The default removal policy is RETAIN, which means that cdk destroy will not attempt to delete
// the new table, and it will remain in your account until manually deleted. By setting the policy to
// DESTROY, cdk destroy will delete the table (even if it has data in it)
removalPolicy: cdk.RemovalPolicy.DESTROY, // NOT recommended for production code
});
const itemsTableRole = new Role(this, 'ItemsDynamoDBRole', {
assumedBy: new ServicePrincipal('appsync.amazonaws.com')
constructor(scope: cdk.Construct, id: string, props: property) {
super(scope, id, props);
const lambdaRole = props.lambdaRoleARN
? iam.Role.fromRoleArn(this, "LambdaRole", props.lambdaRoleARN, {
mutable: false,
})
: undefined;
const sfnRole = props.sfnRoleARN
? iam.Role.fromRoleArn(this, "SfnRole", props.sfnRoleARN, {
mutable: false,
})
: undefined;
this.cacheTable = new dynamodb.Table(this, "cacheTable", {
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", {
const changelogsTable = new dynamodb.Table(this, 'Changelogs', {
partitionKey: { name: 'changelog', type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.Provisioned
});
const readScaling = changelogsTable.autoScaleReadCapacity({
minCapacity: 211,
maxCapacity: 300
});
readScaling.scaleOnUtilization({
targetUtilizationPercent: 75
});
// A table to store the list of feeds
const feedsTable = new dynamodb.Table(this, 'Feeds', {
partitionKey: { name: 'feed', type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.PayPerRequest
});
// A table which stores the auto complete search index
const searchIndexTable = new dynamodb.Table(this, 'search-index', {
partitionKey: { name: 'fragment', type: dynamodb.AttributeType.STRING },
sortKey: { name: 'score', type: dynamodb.AttributeType.STRING },
timeToLiveAttribute: 'validUntil',
billingMode: dynamodb.BillingMode.PayPerRequest
});
// An S3 bucket which holds the web content
const webBucket = new s3.Bucket(this, 'web-bucket', {
publicReadAccess: true,
websiteIndexDocument: 'index.html'
// 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(parent, id, props) {
super(parent, id, props);
// Network to run everything in
const vpc = new ec2.Vpc(this, 'NpmFollowerVpc', {
maxAZs: 2,
natGateways: 1
});
// A table to store the list of changelogs and their metadata in
const changelogsTable = new dynamodb.Table(this, 'Changelogs', {
partitionKey: { name: 'changelog', type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.Provisioned
});
const readScaling = changelogsTable.autoScaleReadCapacity({
minCapacity: 211,
maxCapacity: 300
});
readScaling.scaleOnUtilization({
targetUtilizationPercent: 75
});
// A table to store the list of feeds
const feedsTable = new dynamodb.Table(this, 'Feeds', {
partitionKey: { name: 'feed', type: dynamodb.AttributeType.STRING },
minCapacity: 211,
maxCapacity: 300
});
readScaling.scaleOnUtilization({
targetUtilizationPercent: 75
});
// A table to store the list of feeds
const feedsTable = new dynamodb.Table(this, 'Feeds', {
partitionKey: { name: 'feed', type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.PayPerRequest
});
// A table which stores the auto complete search index
const searchIndexTable = new dynamodb.Table(this, 'search-index', {
partitionKey: { name: 'fragment', type: dynamodb.AttributeType.STRING },
sortKey: { name: 'score', type: dynamodb.AttributeType.STRING },
timeToLiveAttribute: 'validUntil',
billingMode: dynamodb.BillingMode.PayPerRequest
});
// An S3 bucket which holds the web content
const webBucket = new s3.Bucket(this, 'web-bucket', {
publicReadAccess: true,
websiteIndexDocument: 'index.html'
});
// An S3 bucket which holds the API content
const apiBucket = new s3.Bucket(this, 'api-bucket', {
publicReadAccess: true,
websiteIndexDocument: 'index.json'
constructor(scope: cdk.Construct, id: string, props: properties) {
super(scope, id, props);
const table = new dynamodb.Table(this, "resultTable", {
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
partitionKey: { name: "pk", type: dynamodb.AttributeType.STRING },
sortKey: { name: "sk", type: dynamodb.AttributeType.STRING },
});
const buildPath = lambda.Code.fromAsset("./build");
const testInspector = new lambda.Function(this, "testInspector", {
runtime: lambda.Runtime.GO_1_X,
handler: "inspector",
timeout: cdk.Duration.seconds(30),
code: buildPath,
events: [new SnsEventSource(props.deepalert.taskTopic)],
environment: {
RESULT_TABLE: table.tableName,
FINDING_QUEUE: props.deepalert.findingQueue.queueUrl,
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const tableName = 'twitchViewers';
const primaryKeyName = 'viewerId';
const table = new Table(this, 'viewers-table', {
tableName: tableName,
partitionKey: {
name: primaryKeyName,
type: AttributeType.String
},
billingMode: BillingMode.PayPerRequest
});
const api = new CfnApi(this, 'viewersApi', {
stageName: 'prod',
cors: '"*"'
});
new CfnFunction(this, 'SaveToDynamoDB', {
codeUri: new AssetCode('src').path,
handler: 'index.handler',
})
}).addPortMappings({
containerPort: 8080
});
const fargatesvc = new ecsPatterns.ApplicationLoadBalancedFargateService(this, 'AlbSvc', {
cluster,
taskDefinition,
})
const fargateTaskRole = fargatesvc.service.taskDefinition.taskRole;
fargateTaskRole.addToPolicy(new iam.PolicyStatement({
resources: ['*'],
actions: ['events:*']
}));
const orderTable = new dynamodb.Table(this, 'Order', {
partitionKey: { name: 'seqNo', type: dynamodb.AttributeType.NUMBER },
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
tableName: 'Order',
});
orderTable.grantFullAccess(fargateTaskRole);
const coffeeTable = new dynamodb.Table(this, 'Coffee', {
partitionKey: { name: 'seqNo', type: dynamodb.AttributeType.NUMBER },
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
tableName: 'Coffee',
});
coffeeTable.grantFullAccess(fargateTaskRole);
const rule = new Rule(this, 'OrderCreatedRule',{
constructor(scope, id, props) {
super(scope, id, props);
const tableName = 'twitchViewers';
const primaryKeyName = 'viewerId';
const table = new aws_dynamodb_1.Table(this, 'viewers-table', {
tableName: tableName,
partitionKey: {
name: primaryKeyName,
type: aws_dynamodb_1.AttributeType.String
},
billingMode: aws_dynamodb_1.BillingMode.PayPerRequest
});
const api = new aws_sam_1.CfnApi(this, 'viewersApi', {
stageName: 'prod',
cors: '"*"'
});
new aws_sam_1.CfnFunction(this, 'SaveToDynamoDB', {
codeUri: new aws_lambda_1.AssetCode('src').path,
handler: 'index.handler',
runtime: 'nodejs8.10',
environment: {