-
Notifications
You must be signed in to change notification settings - Fork 4k
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
CDK native Hook to upload zipped code (assets) #7513
Comments
Hello @Cloudrage - Would something like this #7898 satisfy your needs? |
Hi @nija-at ! You mean something like that ?
So :
That's it ? In that case, I think it can be more easy to set for our needs with .fromAsset; maybe just by setting an option if you're trying to build your Lambda from a ZIP file or not. For example, a boolean of a bundle prop (or whatever) set to true/false :
|
We could do that by creating a new At the moment, we don't have plans to do this but #7898 should give you the first steps to supporting this, once it is merged and released. Let me know if there is something here that doesn't satisfy your original use case. |
Yes that's it ! Also, I've reported that issue too, to our TAM and we need now to make a call with the CDK Service Team to see what we could do about some of them in the Roadmap. |
@Cloudrage - I believe the new |
Closing for now, let us know if lambda-python works for you. |
Aha, I've seen that new module and planned to use it this week ^^ |
The construct will handle installing all required modules in a Lambda compatible Docker container (?) According to the Microsoft WSL page on github.com, iptables isn't supported : It seems to be possible with WSL 2 : https://docs.docker.com/docker-for-windows/wsl/ |
WSL2 together with the WSL 2 Docker engine is the way to go under Windows. (it is possible with WSL via daemon but Docker is really slow then) |
Ok, so it's working with WSL2 & Docker Desktop. Create & Build Lambda with modules from requirements.txt. The solution below make it the same way, too long (build with a Container without checking a hash if the Build is needed or not) :
Like when we create a Lambda with code as ZIP file, if we update the ZIP, CDK don't know if it has been updated. At the begining of the Request, I've said that actually, using Sceptre, we have made a hook to check the requirements.txt file under the Lambda directory to download every modules needed with pip, but in local (also in .gitignore). Maybe something can be done with CDK to improve these Lambda mechanism ? |
Use Case
When you're creating a Lambda with CDK, you have multiple way to provide the Code, fromAsset, fromBucket, fromInline...
But for example, if you have a Lambda Function in Python with Boto3 needed (but every imports needed are concerned); I don't want to store in my CodeCommit xXxMo of datas useless in every ZIP on each Lambda I have.
And after all, don't store any ZIP files on a Git...
Proposed Solution
So, actually using Sceptre (Troposphere), we have made a hook to check a requirements.txt file under the Lambda directory to download every modules needed with pip, but in local (also in .gitignore).
After that, we create the ZIP file & compare the hash with the one on S3, if existing.
If any changes appears, we upload the code/assets on S3 for the Lambda.
That way, we have a clean Repository with only the code of the Lambda; and costs optimized too.
This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: