How to use the @aws-cdk/aws-dynamodb.BillingMode 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 nathanpeck / screenshot-service / app.3.js View on Github external
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
    });
  }
}
github aws-samples / aws-cdk-changelogs-demo / changelogs-md.js View on Github external
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 },
      billingMode: dynamodb.BillingMode.PayPerRequest
    });
github humank / EventStormingWorkShop / deployment / coffeeshop-cdk / lib / coffee-shop-code-pipeline.ts View on Github external
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',{
            eventPattern:{
                source:["solid.humank.coffeeshop.order"],
                detailType:['customevent']
            },
            // eventBus: coffeeshop_eventbus,
            ruleName: 'OrderCreatedRule',
        });

        //add ssm parameter store for cloudwatchevent put usage
        const eventSourceParam = new ssm.StringParameter(this, 'eventSourceParam', {
github aws-samples / aws-cdk-changelogs-demo / changelogs-md.js View on Github external
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'
    });
github deepalert / deepalert / lib / deepalert-stack.ts View on Github external
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", {
      visibilityTimeout: alertQueueTimeout,
github deepalert / deepalert / test / workflow / bin / stack.ts View on Github external
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,
        ATTRIBUTE_QUEUE: props.deepalert.attributeQueue.queueUrl,
github humank / EventStormingWorkShop / deployment / coffeeshop-cdk / lib / coffee-shop-code-pipeline.ts View on Github external
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',{
            eventPattern:{
                source:["solid.humank.coffeeshop.order"],
github simalexan / api-lambda-save-dynamodb / lib / api-lambda-save-dynamodb-stack.js View on Github external
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: {
                variables: {
                    TABLE_NAME: table.tableName,
                    PRIMARY_KEY: primaryKeyName
                }
            },
            policies: `