From 890087a572277d706d2f060c77aba737ffd2ad78 Mon Sep 17 00:00:00 2001 From: falsycat Date: Thu, 19 Jun 2025 22:29:18 +0900 Subject: [PATCH] improve database schema --- infra/backend.ts | 14 ++++++++++++++ infra/database.ts | 17 ----------------- infra/index.ts | 2 -- 3 files changed, 14 insertions(+), 19 deletions(-) delete mode 100644 infra/database.ts diff --git a/infra/backend.ts b/infra/backend.ts index 2b06855..4d61045 100644 --- a/infra/backend.ts +++ b/infra/backend.ts @@ -45,6 +45,20 @@ new aws.cloudwatch.LogGroup(`${prefix}-lambda-log-group`, { }); +// ---- database ---- +new aws.dynamodb.Table(`${prefix}-db`, { + tags, + name: "objects", + attributes: [ + { name: "userId", type: "S", }, + { name: "sortKey", type: "S", }, + ], + hashKey: "userId", + rangeKey: "sortKey", + billingMode: "PAY_PER_REQUEST", +}); + + // ---- API Gateway ---- const api = new aws.apigatewayv2.Api(`${prefix}-api`, { tags, diff --git a/infra/database.ts b/infra/database.ts deleted file mode 100644 index 9bc8fa9..0000000 --- a/infra/database.ts +++ /dev/null @@ -1,17 +0,0 @@ -import * as aws from "@pulumi/aws"; -import * as pulumi from "@pulumi/pulumi"; - -import * as common from "./common"; - -const tags = common.tags; -const prefix = `${common.prefix}-database`; - -new aws.dynamodb.Table(`${prefix}-users`, { - tags, - name: "Users", // これがDynamoDBのTableNameになる - attributes: [ - { name: "id", type: "S", }, - ], - hashKey: "id", - billingMode: "PAY_PER_REQUEST", -}); diff --git a/infra/index.ts b/infra/index.ts index 05bb2ad..d57c324 100644 --- a/infra/index.ts +++ b/infra/index.ts @@ -4,7 +4,5 @@ import * as aws from "@pulumi/aws"; import * as backend from "./backend"; import * as frontend from "./frontend"; -import "./database"; - export const frontendDomain = frontend.cloudfront.domainName; export const backendEndpoint = backend.endpoint;