constructor()

in source/lib/ddb-data-catalog.ts [31:97]


    constructor(scope: cdk.Construct, id: string) {
        super(scope, id);

        // [ STATUS TABLE ]
        const statusTable = new dynamo.Table(this, "StatusTable", {
            tableName: `${cdk.Aws.STACK_NAME}-grf-job-status`,
            partitionKey: {name: "aid", type: dynamo.AttributeType.STRING},
            removalPolicy: cdk.RemovalPolicy.DESTROY,
            pointInTimeRecovery: true,
            billingMode: dynamo.BillingMode.PROVISIONED,
            readCapacity: 25,
            writeCapacity: 30,
            stream: dynamo.StreamViewType.NEW_AND_OLD_IMAGES
        });
        this.addCfnNagSuppressions(statusTable);
        // CDK excludes the default option - PROVISIONED - from the generated CFN.
        // Adding it explicitly to suppress automated review warning
        (<cdk.CfnResource>statusTable.node.defaultChild).addOverride('Properties.BillingMode', 'PROVISIONED');
        this.statusTable = statusTable;

        statusTable.autoScaleWriteCapacity({minCapacity: 30, maxCapacity: 500})
            .scaleOnUtilization({
                targetUtilizationPercent: TARGET_UTILIZATION,
                scaleOutCooldown: cdk.Duration.seconds(SCALING_OUT_COOLDOWN_SEC),
                scaleInCooldown: cdk.Duration.seconds(SCALING_IN_COOLDOWN_SEC)
            });

        statusTable
            .autoScaleReadCapacity({minCapacity: 25, maxCapacity: 500})
            .scaleOnUtilization({
                targetUtilizationPercent: TARGET_UTILIZATION,
                scaleOutCooldown: cdk.Duration.seconds(SCALING_OUT_COOLDOWN_SEC),
                scaleInCooldown: cdk.Duration.seconds(SCALING_IN_COOLDOWN_SEC)
            });

        // status table: max-file-index GSI
        statusTable.addGlobalSecondaryIndex({
            indexName: "max-file-index",
            partitionKey: {name: "pid", type: dynamo.AttributeType.NUMBER},
            sortKey: {name: "ifn", type: dynamo.AttributeType.NUMBER},
            projectionType: dynamo.ProjectionType.KEYS_ONLY,
            readCapacity: 5,
            writeCapacity: 30
        });
        DynamoDataCatalog.configureGsiAutoScaling(statusTable, 'max-file-index', 5, 30);

        // status table: file-name GSI
        statusTable.addGlobalSecondaryIndex({
            indexName: "name-index",
            partitionKey: {name: "fname", type: dynamo.AttributeType.STRING},
            projectionType: dynamo.ProjectionType.KEYS_ONLY,
            readCapacity: 15,
            writeCapacity: 30
        });
        DynamoDataCatalog.configureGsiAutoScaling(statusTable, 'name-index', 15, 30);

        // [ METRICS TABLE ]
        const metricsTable = new dynamo.Table(this, 'MetricsTable', {
            tableName: `${cdk.Aws.STACK_NAME}-grf-job-metrics`,
            partitionKey: {name: "pk", type: dynamo.AttributeType.STRING},
            removalPolicy: cdk.RemovalPolicy.DESTROY,
            pointInTimeRecovery: true,
            billingMode: dynamo.BillingMode.PAY_PER_REQUEST
        });
        this.addCfnNagSuppressions(metricsTable);
        this.metricTable = metricsTable;
    }