Skip to content

Commit

Permalink
move resources to own folder
Browse files Browse the repository at this point in the history
  • Loading branch information
ebisbe committed Jul 9, 2024
1 parent 9d2cf3f commit e220991
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 30 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
"@middy/http-error-handler": "^5.4.3",
"@middy/http-json-body-parser": "^5.4.3",
"dynamodb-onetable": "^2.7.4",
"lodash": "^4.17.21",
"zod": "^3.23.8"
},
"devDependencies": {
"@awboost/cfntypes": "^0.100.9",
"@eslint/js": "^9.6.0",
"@types/aws-lambda": "^8.10.140",
"@types/jest": "^29.5.12",
"@types/lodash": "^4.17.6",
"@types/node": "^20.14.10",
"@types/serverless": "^3.12.22",
"dotenv": "^16.4.5",
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 2 additions & 30 deletions serverless.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import resources from "./src/resources";
import { ServerlessExtended } from "./src/types/extendedSlsTypes";

const environment = {
Expand Down Expand Up @@ -120,36 +121,7 @@ const serverlessConfig: ServerlessExtended = {
},
},

resources: {
Resources: {
DdbTable: {
Type: "AWS::DynamoDB::Table",
Properties: {
AttributeDefinitions: [
{
AttributeName: "pk",
AttributeType: "S",
},
{
AttributeName: "sk",
AttributeType: "S",
},
],
KeySchema: [
{
AttributeName: "pk",
KeyType: "HASH",
},
{
AttributeName: "sk",
KeyType: "RANGE",
},
],
BillingMode: "PAY_PER_REQUEST",
},
},
},
},
resources,
};

export default serverlessConfig;
32 changes: 32 additions & 0 deletions src/resources/ddb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ServerlessExtended } from "../types/extendedSlsTypes";

export const ddbResources: ServerlessExtended["resources"] = {
Resources: {
DdbTable: {
Type: "AWS::DynamoDB::Table",
Properties: {
AttributeDefinitions: [
{
AttributeName: "pk",
AttributeType: "S",
},
{
AttributeName: "sk",
AttributeType: "S",
},
],
KeySchema: [
{
AttributeName: "pk",
KeyType: "HASH",
},
{
AttributeName: "sk",
KeyType: "RANGE",
},
],
BillingMode: "PAY_PER_REQUEST",
},
},
},
};
7 changes: 7 additions & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { merge } from "lodash";

import { ddbResources } from "./ddb";

const resources = merge(ddbResources);

export default resources;

0 comments on commit e220991

Please sign in to comment.