From 25f851385237d42a2c1abe5b2bf0bc8208d63159 Mon Sep 17 00:00:00 2001 From: antfconeto Date: Mon, 17 Feb 2025 16:10:10 -0300 Subject: [PATCH] feat: :sparkles: init config user table --- lib/dynamodb-setup.ts | 29 +++++++++++++++++++++++++++++ lib/svc-user-stack.ts | 11 ++++------- 2 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 lib/dynamodb-setup.ts diff --git a/lib/dynamodb-setup.ts b/lib/dynamodb-setup.ts new file mode 100644 index 0000000..541fa99 --- /dev/null +++ b/lib/dynamodb-setup.ts @@ -0,0 +1,29 @@ +import {aws_dynamodb as dynamodb, Stack} from 'aws-cdk-lib' + +export class DynamoDBSetup{ + private userTable:dynamodb.Table; + private stack:Stack + + constructor(stackParameter: Stack){ + this.stack = stackParameter + } + + + setupUserTable():void{ + this.userTable = new dynamodb.Table(this.stack,'UserTableIdentifier',{ + partitionKey:{ + name:"PK", + type:dynamodb.AttributeType.STRING + }, + sortKey:{ + name:"SK", + type:dynamodb.AttributeType.STRING + }, + billingMode:dynamodb.BillingMode.PAY_PER_REQUEST + }) + } + + getUserTable():dynamodb.Table{ + return this.userTable; + } +} \ No newline at end of file diff --git a/lib/svc-user-stack.ts b/lib/svc-user-stack.ts index 4e46609..c1fb635 100644 --- a/lib/svc-user-stack.ts +++ b/lib/svc-user-stack.ts @@ -1,16 +1,13 @@ import * as cdk from 'aws-cdk-lib'; import { Construct } from 'constructs'; +import { DynamoDBSetup } from './dynamodb-setup'; // import * as sqs from 'aws-cdk-lib/aws-sqs'; export class SvcUserStack extends cdk.Stack { constructor(scope: Construct, id: string, props?: cdk.StackProps) { super(scope, id, props); - - // The code that defines your stack goes here - - // example resource - // const queue = new sqs.Queue(this, 'SvcUserQueue', { - // visibilityTimeout: cdk.Duration.seconds(300) - // }); + //---------Setup DynamoDB----------// + const dynamodbSetup = new DynamoDBSetup(this) + dynamodbSetup.setupUserTable() } }