Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use NodejsFunction with AWS-SDK? #7685

Closed
thesoftwarephilosopher opened this issue Apr 29, 2020 · 7 comments
Closed

How to use NodejsFunction with AWS-SDK? #7685

thesoftwarephilosopher opened this issue Apr 29, 2020 · 7 comments
Labels
needs-triage This issue or PR still needs to be triaged.

Comments

@thesoftwarephilosopher
Copy link

❓ General Issue

The Question

I think the NodejsFunction function in the aws-lambda-nodejs may need another parameter. It uses Parcel to package the NodeJS-based function, but if that function does require('aws-sdk') from within that Lambda's code, Parcel will bundle that too, even though that module is natively available inside the Lambda function when called by AWS.

Environment

  • CDK CLI Version: 1.36.0 (build 47c9919)
  • Module Version: ^1.36.0
  • OS: macOS 10.15.4 (19E287)
  • Language: TypeScript

Other information

I think if there was a way to tell Parcel to leave the require line as-is without transforming it, then the aws-lambda-nodejs module could include that as an option for its constructor props.

(Pinging @jogold as I was told that's who wrote this module and to bring this up to him.)

@thesoftwarephilosopher thesoftwarephilosopher added the needs-triage This issue or PR still needs to be triaged. label Apr 29, 2020
@thesoftwarephilosopher
Copy link
Author

See also parcel-bundler/parcel#4547 because I'm not sure such a flag exists just yet (but it may, and I may have overlooked it in the Parcel docs).

@jogold
Copy link
Contributor

jogold commented Apr 29, 2020

Hi @sdegutis

For now I recommend using parcel-plugin-externals. Just add it as a dev dependency then in your package.json add either:

{
  "peerDependencies": {
    "aws-sdk": "*"
  }
}

or:

{
  "externals": [
    "aws-sdk"
  ]
}

With this setup, aws-sdk will not be bundled.

After #7169 gets merged, I have plans to add a prop to specify externals.

@thesoftwarephilosopher
Copy link
Author

Thanks @jogold!

@thesoftwarephilosopher
Copy link
Author

Also, this solution just now mentioned might already be viable for this module. Not sure if it's already been considered though.

@iDVB
Copy link

iDVB commented May 29, 2020

After #7169 gets merged, I have plans to add a prop to specify externals.

Hey @jogold now that #7169 is merged... did you get a chance to work on adding that prop?

@jogold
Copy link
Contributor

jogold commented May 29, 2020

After #7169 gets merged, I have plans to add a prop to specify externals.

Hey @jogold now that #7169 is merged... did you get a chance to work on adding that prop?

Not yet, we now need #7898...

@iDVB
Copy link

iDVB commented May 29, 2020

Thanks @jogold , I did see that issue, just wasn’t positive on the relevancy.
In the meantime is there some kind of Jacky workaround short of having all updates to anything trigger a new version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

3 participants