How to use the @aws-cdk/aws-dynamodb.BillingMode.PayPerRequest function in @aws-cdk/aws-dynamodb

To help you get started, we’ve selected a few @aws-cdk/aws-dynamodb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github simalexan / api-lambda-save-dynamodb / lib / api-lambda-save-dynamodb-stack.ts View on Github external
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',
      runtime: 'nodejs8.10',
      environment: {
        variables: {
          TABLE_NAME: table.tableName,
          PRIMARY_KEY: primaryKeyName
        }