Giter Club home page Giter Club logo

aws-cdk-webpack-lambda-function's People

Contributors

dependabot[bot] avatar kdxcbdp7 avatar masahirompp avatar micro-jumbo avatar muhamadto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

aws-cdk-webpack-lambda-function's Issues

Support for CDK 2

Thanks for this library, it's pretty handy. Any chance you can dedicate sometime to support CDK v2

Update cdk dependencies

At package.json there are some old versions of aws-cdk

    "@aws-cdk/aws-lambda": "^1.33.1",
    "@aws-cdk/core": "^1.33.1",

Can you upgrade to the latest 1.47.0 ?
I can make a pull request too, but how can I know if version change breaks something? (any test?)

WebpackFunction construct throw an exception on windows

The library doesn't seem to work on windows environnement. When I cdk synth with the WebpackFunction construct:

const func = new WebpackFunction(this,id,{
            entry: '../functions/portfolio/src/lambda.ts',
            config: '../functions/portfolio/webpack.config.js'
        })

I get this weird error:

Error: spawnSync C:\serverless-rest-api-typescript\cdk\node_modules\webpack-cli\bin\cli.js UNKNOWN
    at Object.spawnSync (internal/child_process.js:1041:20)
    at Object.spawnSync (child_process.js:616:24)
    at Builder.build (C:\serverless-rest-api-typescript\cdk\node_modules\aws-cdk-webpack-lambda-function\lib\builder.js:29:41)
    at preProcess (C:\serverless-rest-api-typescript\cdk\node_modules\aws-cdk-webpack-lambda-function\lib\function.js:60:13)
    at new WebpackFunction (C:\serverless-rest-api-typescript\cdk\node_modules\aws-cdk-webpack-lambda-function\lib\function.js:14:66)
    at new PortfolioCRUDRestAPI (C:\serverless-rest-api-typescript\cdk\lib\portfolio-crud-api.ts:21:22)
    at new AppStack (C:\serverless-rest-api-typescript\cdk\lib\app-stack.ts:8:5)
    at Object.<anonymous> (C:\serverless-rest-api-typescript\cdk\bin\cdk.ts:7:1)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Module.m._compile (C:\serverless-rest-api-typescript\cdk\node_modules\ts-node\src\index.ts:858:23)

Usage with webpack-node-externals

Can someone help me with a minimal webpack.config.js to get this construct setup with webpack-node-externals?

I'm new to the CDK world and have yet to figure out how to get node_modules to the correct place. Lots of the CDK docs seem to allude to the fact that your repo should be structured in a magic way and your dependencies in package.json are magically bundled / npm installed, but I've not been able to get that to work with TypeScript - I need experimentalDecorators support to be able to use typegraphql.

I can get my code working and deployed with the example webpack.config.js, but my machine is taking around 30 seconds to build code vs. < 3 with webpack-node-externals configured which is making local development a challenge, especially when combined with the slowness of docker and the SAM CLI.

Any ideas on how to improve my iteration time?

The relevant portions of my directory are structured like this:

.
├── cdk.json
├── infrastructure
│   ├── infra-stack.ts
│   └── infra.ts
├── lambda
│   ├── apollo
│   │   ├── graphql.ts
│   │   ├── resolvers
│   │   │   ├── ...
│   │   │   └── ....
├── package.json
├── tsconfig.module.json
├── webpack.config.js
└── yarn.lock
// cdk.json
{
  "app": "npx ts-node --project tsconfig.module.json --prefer-ts-exts infrastructure/infra.ts",
  "context": {
    "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
    "@aws-cdk/core:enableStackNameDuplicates": "true",
    "aws-cdk:enableDiffNoFail": "true",
    "@aws-cdk/core:stackRelativeExports": "true",
    "@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true,
    "@aws-cdk/aws-secretsmanager:parseOwnedSecretName": true,
    "@aws-cdk/aws-kms:defaultKeyPolicies": true,
    "@aws-cdk/aws-s3:grantWriteWithoutAcl": true,
    "@aws-cdk/aws-ecs-patterns:removeDefaultDesiredCount": true,
    "@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
    "@aws-cdk/aws-efs:defaultEncryptionAtRest": true,
    "@aws-cdk/aws-lambda:recognizeVersionProps": true
  }
}

And the actual function definition

 const apolloGraphqlLambdaId = `${process.env.TARGET_ENV}ApolloGraphql`;
    const apolloGraphqlLambda = new WebpackFunction(
      this,
      apolloGraphqlLambdaId,
      {
        functionName: apolloGraphqlLambdaId,
        entry: path.join(__dirname, '../lambda/apollo/graphql.ts'),
        buildDir: path.join(__dirname, '../.build/lambda'),
        handler: 'apolloGraphQLHandler',
        runtime: lambda.Runtime.NODEJS_14_X,
        config: path.join(__dirname, '../webpack.config.js'),
        ensureUniqueBuildPath: process.env.TARGET_ENV !== 'localhost',
        timeout: cdk.Duration.seconds(60),
        memorySize: 1024,
      }
    );

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.