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

Why install AWS SDK into AwsCustomResource Node.js Lambda - isn't it already there? #7781

Closed
mcalello opened this issue May 4, 2020 · 8 comments
Assignees
Labels
@aws-cdk/aws-lambda-nodejs @aws-cdk/custom-resources Related to AWS CDK Custom Resources feature-request A feature should be added or improved.

Comments

@mcalello
Copy link

mcalello commented May 4, 2020

The Question

Just noticed that the code behind one of my AwsCustomResources has the following in its log:
INFO Installing latest AWS SDK v2
which takes about 45 seconds to install.

Isn't AWS SDK preloaded in Node.js lambdas?

( Perhaps this is just an older artifact that can be removed, similar to #7047 )

@mcalello mcalello added the needs-triage This issue or PR still needs to be triaged. label May 4, 2020
@jogold
Copy link
Contributor

jogold commented May 5, 2020

This to install the latest v2 of AWS SDK JS so that the newest API calls are available.

@mcalello
Copy link
Author

mcalello commented May 5, 2020

Thanks @jogold - can that be turned into an option? Rarely, do we need the very edge of functionality, and would be willing to tradeoff in favor of improving the performance.

@jogold
Copy link
Contributor

jogold commented May 5, 2020

We have decided not to when implementing this feature (#5442 (comment)). @eladb what do you think? Not sure that loosing time in a custom resource is critical compared to the "slowness" of CloudFormation...

@eladb
Copy link
Contributor

eladb commented May 5, 2020

@mcalello What do you say? Doesn’t seem like something many people are looking for. If this is a major use case for you, we’d love to learn about it.

@SomayaB SomayaB added @aws-cdk/custom-resources Related to AWS CDK Custom Resources @aws-cdk/aws-lambda-nodejs labels May 5, 2020
@SomayaB SomayaB added feature-request A feature should be added or improved. and removed needs-triage This issue or PR still needs to be triaged. labels May 5, 2020
@eladb
Copy link
Contributor

eladb commented May 7, 2020

Closing for now

@eladb eladb closed this as completed May 7, 2020
@mcalello
Copy link
Author

mcalello commented May 7, 2020

Thanks @eladb and @jogold. Sorry for the delay in writing back, but I wanted to test this and verify what we are seeing.

So if this was a one-time hit to download the latest (edge) version of the Node.js AWS-SDK-JS, I'd say it's only a 45 second delay, typically. But, what we are seeing is that it's downloading the SDK for each and every AwsCustomResource in our stacks. I just completed a test to have 2 different AwsCustomResource-backed custom constructs in the same stack, and they both download the SDK independently. So - for our large stacks this means we have to add 45 sec for each time we solve a problem with AwsCustomResource.

My suggestion:
Give users the choice to enable/disable this bootstrapping for when the preloaded version is good enough. I think this provides 2 benefits:

  • No surprises with an edgier version of the SDK we may have not tested.
  • Reduce the deployment time of our stacks

@jogold
Copy link
Contributor

jogold commented May 8, 2020

OK, this is because the custom resources are being executed in parallel so there's no Lambda "container reuse" and you pay the "installation penalty" each time... in the meantime you could "chain" your custom resources:

customResource2.node.addDependency(customResource1);

@skyrpex
Copy link
Contributor

skyrpex commented Aug 6, 2020

I would like to share my scenario: we need AWS Custom Resources to invoke another lambda asynchronously (in order to get some QueueUrls registered in a DynamoDB somewhere else).

The thing is that, in our scenario, we will deploy these custom resources very often, and the ~45s penalty for each of these deployments is going to cost deployment time and unwanted $$$... Would love to avoid that installation execution, if possible.

I still don't understand how different these custom resources lambdas are compared to the rest of the lambdas 🤔 Are the AWS SDK from common lambdas outdated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-nodejs @aws-cdk/custom-resources Related to AWS CDK Custom Resources feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

5 participants