How to update ts.config files in AWS CDK project

Viewed 538

I am receiving this error when trying to deploy to my aws stack,

Error: spawnSync docker ENOENT
    at Object.spawnSync (node:internal/child_process:1111:20)
    at Object.spawnSync (node:child_process:814:24)
    at dockerExec (/Users/jialinzhen/Desktop/typescript-cdk/node_modules/aws-cdk-lib/core/lib/bundling.ts:498:16)
    at Function.fromBuild (/Users/jialinzhen/Desktop/typescript-cdk/node_modules/aws-cdk-lib/core/lib/bundling.ts:279:5)
    at new Bundling (/Users/jialinzhen/Desktop/typescript-cdk/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.ts:122:74)
    at Function.bundle (/Users/jialinzhen/Desktop/typescript-cdk/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.ts:59:17)
    at new NodejsFunction (/Users/jialinzhen/Desktop/typescript-cdk/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/function.ts:103:22)
    at new DocumentManagementAPI (/Users/jialinzhen/Desktop/typescript-cdk/lib/api.ts:9:38)
    at new TypescriptCdkStack (/Users/jialinzhen/Desktop/typescript-cdk/lib/typescript-cdk-stack.ts:23:17)
    at Object.<anonymous> (/Users/jialinzhen/Desktop/typescript-cdk/bin/typescript-cdk.ts:9:15)

I am trying to deploy a lambda to aws and the lambda looks like:

import { aws_lambda_nodejs as lambda, aws_lambda as awslambda } from "aws-cdk-lib";
import { Construct } from 'constructs';
interface DocumentManagementAPIProps {
}

export class DocumentManagementAPI extends Construct {
    constructor(scope: Construct, id: string, props?: DocumentManagementAPIProps) {
        super(scope, id);
        const getDocumentsFunction = new lambda.NodejsFunction(this, 'getDocumentsFunction', {
            runtime: awslambda.Runtime.NODEJS_14_X,
            entry: 'api/getDocuments/index.ts',
            handler: 'getDocuments',
            bundling: {
                externalModules: ['aws-sdk']
            }
        })
    }
}

I am using the newest version of cdk which is 2.24.0, and node version 16.14.2. Here is the ts.config file that convert TS to JS,

{
  "compilerOptions": {
    "target": "ES2020",
    "module": "commonjs",
    "lib": [
      "es2020"
    ],
    "declaration": true,
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noImplicitThis": true,
    "alwaysStrict": true,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": false,
    "inlineSourceMap": true,
    "inlineSources": true,
    "experimentalDecorators": true,
    "strictPropertyInitialization": false,
    "esModuleInterop": true,
    "typeRoots": [
      "./node_modules/@types"
    ]
  },
  "exclude": [
    "node_modules",
    "cdk.out"
  ]
}

Can anyone help me to see what happens? I can provide link to my repo if the above does not help? https://github.com/jaydenyen123/typescript-cdk

0 Answers
Related