Skip to content

Commit

Permalink
add localstack setup for the lambda stack
Browse files Browse the repository at this point in the history
  • Loading branch information
wssheldon committed Sep 30, 2024
1 parent 97151ab commit c948ec8
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
14 changes: 8 additions & 6 deletions distribution/lambda/bin/pond-lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import * as cdk from "aws-cdk-lib";
import { PondLambdaStack } from "../lib/pond-lambda-stack";

const app = new cdk.App();
const useLocalStack = app.node.tryGetContext("use_local_stack") === true;

new PondLambdaStack(app, "PondLambdaStack", {
/* If you don't specify 'env', this stack will be environment-agnostic.
* Account/Region-dependent features and context lookups will not work,
* but a single synthesized template can be deployed anywhere. */
/* Uncomment the next line to specialize this stack for the AWS Account
* and Region that are implied by the current CLI configuration. */
// env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION },
env: useLocalStack
? { account: "000000000000", region: "us-east-1" }
: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION,
},
});
3 changes: 3 additions & 0 deletions distribution/lambda/cdk.context.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"use_local_stack": true
}
26 changes: 25 additions & 1 deletion distribution/lambda/package-lock.json

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

9 changes: 7 additions & 2 deletions distribution/lambda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@
"test": "jest",
"cdk": "cdk",
"build:lambda": "cd $(git rev-parse --show-toplevel)/pond/pond-planner && cargo lambda build --release && cd $(git rev-parse --show-toplevel)/pond/pond-duckling && cargo lambda build --release",
"deploy": "npm run build:lambda && npm run build && cdk deploy"
"deploy": "npm run build:lambda && npm run build && cdk deploy",
"start:localstack": "docker run --rm -it -p 4566:4566 -p 4571:4571 localstack/localstack",
"cdk-local": "cdklocal",
"deploy:local": "npm run build:lambda && npm run build && cdklocal deploy",
"destroy:local": "cdklocal destroy"
},
"devDependencies": {
"@types/jest": "^29.5.5",
"@types/node": "^20.16.10",
"aws-cdk": "2.100.0",
"aws-cdk": "^2.100.0",
"aws-cdk-local": "^2.18.0",
"esbuild": "^0.24.0",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
Expand Down

0 comments on commit c948ec8

Please sign in to comment.