From 95d80993fddd27850e0815228e3294fc35e3c1a4 Mon Sep 17 00:00:00 2001 From: Jason Park Date: Sun, 9 Jul 2023 12:56:10 +0900 Subject: [PATCH 1/3] fix: refactoring forum table keys --- lib/constructs/persistence/database.ts | 56 +++++++++++++------------- lib/stacks/persistence.ts | 1 + 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/lib/constructs/persistence/database.ts b/lib/constructs/persistence/database.ts index b5a13cac3..6b07b4fa0 100644 --- a/lib/constructs/persistence/database.ts +++ b/lib/constructs/persistence/database.ts @@ -82,36 +82,36 @@ export class DynamoDatabase extends Construct { }, ); - this.tables[Collection.THREAD] = new dynamodb.Table( - this, - 'dynamodb-thread-table', - { - partitionKey: { - name: 'board_id', - type: dynamodb.AttributeType.STRING, - }, - billingMode: dynamodb.BillingMode.PROVISIONED, - encryption: dynamodb.TableEncryption.DEFAULT, - removalPolicy: RemovalPolicy.DESTROY, - sortKey: { name: 'created_at', type: dynamodb.AttributeType.STRING }, - tableName: 'forum-threads', - readCapacity: 15, - writeCapacity: 15, - pointInTimeRecovery: true, - }, - ); + // this.tables[Collection.THREAD] = new dynamodb.Table( + // this, + // 'dynamodb-thread-table', + // { + // partitionKey: { + // name: 'board_id', + // type: dynamodb.AttributeType.STRING, + // }, + // billingMode: dynamodb.BillingMode.PROVISIONED, + // encryption: dynamodb.TableEncryption.DEFAULT, + // removalPolicy: RemovalPolicy.DESTROY, + // sortKey: { name: 'created_at', type: dynamodb.AttributeType.STRING }, + // tableName: 'forum-threads', + // readCapacity: 15, + // writeCapacity: 15, + // pointInTimeRecovery: true, + // }, + // ); - this.tables[Collection.THREAD].addLocalSecondaryIndex({ - indexName: 'GroupIndex', - sortKey: { name: 'group_id', type: dynamodb.AttributeType.STRING }, - projectionType: dynamodb.ProjectionType.ALL, - }); + // this.tables[Collection.THREAD].addLocalSecondaryIndex({ + // indexName: 'GroupIndex', + // sortKey: { name: 'group_id', type: dynamodb.AttributeType.STRING }, + // projectionType: dynamodb.ProjectionType.ALL, + // }); - this.tables[Collection.THREAD].addLocalSecondaryIndex({ - indexName: 'TagIndex', - sortKey: { name: 'tag_id', type: dynamodb.AttributeType.STRING }, - projectionType: dynamodb.ProjectionType.ALL, - }); + // this.tables[Collection.THREAD].addLocalSecondaryIndex({ + // indexName: 'TagIndex', + // sortKey: { name: 'tag_id', type: dynamodb.AttributeType.STRING }, + // projectionType: dynamodb.ProjectionType.ALL, + // }); // this.tables[Collection.THREAD].addGlobalSecondaryIndex({ // indexName: "UidbyCreated_at", diff --git a/lib/stacks/persistence.ts b/lib/stacks/persistence.ts index f2018086e..ae5859ae0 100644 --- a/lib/stacks/persistence.ts +++ b/lib/stacks/persistence.ts @@ -74,6 +74,7 @@ export class WasedaTimePersistenceLayer extends PersistenceLayer { // DataEndpoint.COURSE, // syllabusSyncPipeline.dataWarehouse.tableName, // ); + this.exportValue(dynamoDatabase.tables[Collection.THREAD].tableName); this.operationInterface.setEndpoint(OperationEndpoint.SYLLABUS, { [syllabusDataPipeline.processor.stateMachineArn]: 'scraper', From 97d444c1eb584f8306e959ad4ab043cdd1aad447 Mon Sep 17 00:00:00 2001 From: Jason Park Date: Sun, 9 Jul 2023 13:04:54 +0900 Subject: [PATCH 2/3] fix: first deleting the table --- lib/constructs/persistence/database.ts | 56 +++++++++++++------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/constructs/persistence/database.ts b/lib/constructs/persistence/database.ts index 6b07b4fa0..b5a13cac3 100644 --- a/lib/constructs/persistence/database.ts +++ b/lib/constructs/persistence/database.ts @@ -82,36 +82,36 @@ export class DynamoDatabase extends Construct { }, ); - // this.tables[Collection.THREAD] = new dynamodb.Table( - // this, - // 'dynamodb-thread-table', - // { - // partitionKey: { - // name: 'board_id', - // type: dynamodb.AttributeType.STRING, - // }, - // billingMode: dynamodb.BillingMode.PROVISIONED, - // encryption: dynamodb.TableEncryption.DEFAULT, - // removalPolicy: RemovalPolicy.DESTROY, - // sortKey: { name: 'created_at', type: dynamodb.AttributeType.STRING }, - // tableName: 'forum-threads', - // readCapacity: 15, - // writeCapacity: 15, - // pointInTimeRecovery: true, - // }, - // ); + this.tables[Collection.THREAD] = new dynamodb.Table( + this, + 'dynamodb-thread-table', + { + partitionKey: { + name: 'board_id', + type: dynamodb.AttributeType.STRING, + }, + billingMode: dynamodb.BillingMode.PROVISIONED, + encryption: dynamodb.TableEncryption.DEFAULT, + removalPolicy: RemovalPolicy.DESTROY, + sortKey: { name: 'created_at', type: dynamodb.AttributeType.STRING }, + tableName: 'forum-threads', + readCapacity: 15, + writeCapacity: 15, + pointInTimeRecovery: true, + }, + ); - // this.tables[Collection.THREAD].addLocalSecondaryIndex({ - // indexName: 'GroupIndex', - // sortKey: { name: 'group_id', type: dynamodb.AttributeType.STRING }, - // projectionType: dynamodb.ProjectionType.ALL, - // }); + this.tables[Collection.THREAD].addLocalSecondaryIndex({ + indexName: 'GroupIndex', + sortKey: { name: 'group_id', type: dynamodb.AttributeType.STRING }, + projectionType: dynamodb.ProjectionType.ALL, + }); - // this.tables[Collection.THREAD].addLocalSecondaryIndex({ - // indexName: 'TagIndex', - // sortKey: { name: 'tag_id', type: dynamodb.AttributeType.STRING }, - // projectionType: dynamodb.ProjectionType.ALL, - // }); + this.tables[Collection.THREAD].addLocalSecondaryIndex({ + indexName: 'TagIndex', + sortKey: { name: 'tag_id', type: dynamodb.AttributeType.STRING }, + projectionType: dynamodb.ProjectionType.ALL, + }); // this.tables[Collection.THREAD].addGlobalSecondaryIndex({ // indexName: "UidbyCreated_at", From aff3d5fb75862ecc74e17c6c0f4b74e2ecb96b7d Mon Sep 17 00:00:00 2001 From: Jason Park Date: Sun, 9 Jul 2023 13:14:27 +0900 Subject: [PATCH 3/3] feat: exporting table arn --- lib/stacks/persistence.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/stacks/persistence.ts b/lib/stacks/persistence.ts index ae5859ae0..9214582a7 100644 --- a/lib/stacks/persistence.ts +++ b/lib/stacks/persistence.ts @@ -74,7 +74,7 @@ export class WasedaTimePersistenceLayer extends PersistenceLayer { // DataEndpoint.COURSE, // syllabusSyncPipeline.dataWarehouse.tableName, // ); - this.exportValue(dynamoDatabase.tables[Collection.THREAD].tableName); + this.exportValue(dynamoDatabase.tables[Collection.THREAD].tableArn); this.operationInterface.setEndpoint(OperationEndpoint.SYLLABUS, { [syllabusDataPipeline.processor.stateMachineArn]: 'scraper',