Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
destinationBucket: bucket,
destinationKeyPrefix: "_next/static"
});
new s3Upload.BucketDeployment(stack, `${id}-s3-public-files`, {
sources: [s3Upload.Source.asset("./public")],
destinationBucket: bucket,
destinationKeyPrefix: "public"
});
new s3Upload.BucketDeployment(stack, `${id}-s3-static-files`, {
sources: [s3Upload.Source.asset("./static")],
destinationBucket: bucket,
destinationKeyPrefix: "static"
});
const ssrLambda = new lambda.Function(stack, `${id}-ssr-lambda`, {
code: new lambda.AssetCode(`./${LAMBDA_BUILD_DIR}`),
handler: "index.handler",
runtime: lambda.Runtime.NODEJS_8_10,
environment: {}
});
// const cloudFrontOrigins = [
// {
// url: bucket.bucketWebsiteUrl,
// private: true,
// pathPatterns: {
// "_next/*": {
// ttl: 86400
// },
// "static/*": {
// ttl: 86400
// }
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: {
variables: {
TABLE_NAME: table.tableName,
PRIMARY_KEY: primaryKeyName
}
},
policies: `
- DynamoDBCrudPolicy:
TableName: ${tableName}`,
events: {
save: {
type: 'Api',
properties: {
path: '/viewers',
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',
runtime: 'nodejs8.10',
environment: {
variables: {
TABLE_NAME: table.tableName,
PRIMARY_KEY: primaryKeyName
}
},
policies: `
- DynamoDBCrudPolicy:
TableName: ${tableName}`,
events: {
save: {
type: 'Api',
properties: {
path: '/viewers',