- CDK stack for Sea Haven Industries internal Slack assistant - Bedrock Agent (Claude 3.5 Sonnet) with QBO + Google Maps action groups - VectorKnowledgeBase via @cdklabs/generative-ai-cdk-constructs (AOSS + S3) - Slack webhook/processor Lambdas with DM-only filtering - API Gateway HTTP API on bot.seahaven.com - DynamoDB conversation log with 90-day TTL - Secrets Manager references for Slack, QBO OAuth, and Google Maps
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import * as cdk from 'aws-cdk-lib';
|
|
import { Construct } from 'constructs';
|
|
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
|
|
|
|
export class ConversationLogConstruct extends Construct {
|
|
public readonly table: dynamodb.Table;
|
|
|
|
constructor(scope: Construct, id: string) {
|
|
super(scope, id);
|
|
|
|
this.table = new dynamodb.Table(this, 'Table', {
|
|
tableName: 'seahaven-conversations',
|
|
// PK: Slack user ID (e.g. U0123456789)
|
|
partitionKey: { name: 'userId', type: dynamodb.AttributeType.STRING },
|
|
// SK: ISO-8601 timestamp — enables range queries for session lookup
|
|
sortKey: { name: 'timestamp', type: dynamodb.AttributeType.STRING },
|
|
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
|
|
removalPolicy: cdk.RemovalPolicy.RETAIN,
|
|
pointInTimeRecoverySpecification: { pointInTimeRecoveryEnabled: true },
|
|
// TTL attribute — records are automatically expired after 90 days
|
|
timeToLiveAttribute: 'ttl',
|
|
});
|
|
|
|
// GSI for looking up all turns in a given Bedrock session (for context retrieval)
|
|
this.table.addGlobalSecondaryIndex({
|
|
indexName: 'sessionId-index',
|
|
partitionKey: { name: 'sessionId', type: dynamodb.AttributeType.STRING },
|
|
sortKey: { name: 'timestamp', type: dynamodb.AttributeType.STRING },
|
|
});
|
|
}
|
|
}
|