I'm just getting started with Powershell on Lambda. I've been following the getting started guide here: https://aws.amazon.com/blogs/developer/announcing-lambda-support-for-powershell-core/
I've setup my environment and installed all the necessary modules. I'm trying to publish an extremely basic Powershell script just to learn a bit more about how this works before I start writing real functions
My steps:
The publish then fails with the error:
Error creating Lambda function: Unzipped size must be smaller than 262144000 bytes
If I run New-AWSPowershellLambdaPackage and examine the output I have a 37MB zip file that unzips into 275MB of files, so clearly the commandlet is generating a deployment package that is too large.
I have not added any additional modules to my test, only the default AWSPowerShell.NetCore module is being required. I notice that this module alone on my workstation is 246MB uncompressed, so it seems like it is too large for this to ever work.
Am I doing something wrong here? Is there a way to reduce the size of the lambda package?
I'm currently using the latest version 4.0.2.0 of AWSPowerShell.NetCore.
One additional note, I tried switching the version of AWSPowerShell.NetCore that my function required to an older version I have installed (3.3.590.0) and I was able to successfully publish the Lambda. Using the older version of the module dropped the zip size down to 29MB and the unzipped size down to 144MB.
I guess 4.x versions might be too large for lambda usage?
After some additional reading I think I might have the solution to my issue. AWSPowerShell.NetCore is a monolithic module that includes everything for all AWS services and supports Powershell 3 all the way to Powershell 6.
Instead of loading one giant module I can use the AWS.Tools modules (https://github.com/aws/aws-tools-for-powershell/issues/67) which are modular and allow me to only load the commandlets I need for my function. Doing it this way and only requiring aws.tools.s3 gives me a deployment zip size of 11MB and an uncompressed size of 33MB. Much better.
Might be worth updating the basic template to not reference the latest version of AWSPowerShell.NetCore though, since it's too large to deploy with a Lambda
You'll need to un-comment the section in the lambda below. This will force the machine to work with the appropriate module otherwise you get a bunch of DLLs bundled into your zip which makes it huge
Requires -Modules @{ModuleName='AWSPowerShell.NetCore';ModuleVersion='4.0.4.0'}
You'll need to un-comment the section in the lambda below. This will force the machine to work with the appropriate module otherwise you get a bunch of DLLs bundled into your zip which makes it huge
Requires -Modules @{ModuleName='AWSPowerShell.NetCore';ModuleVersion='4.0.4.0'}
Just tried uncommenting this and it didn't load the Module into the Lambda, don't believe that's the answer: #Requires -Modules @{ModuleName='AWSPowerShell.NetCore';ModuleVersion='4.0.5.0'}
That also gives the following error from the Lambda itself:
START RequestId: 762bd5bd-e3b4-48a5-97af-5da66f68a46c Version: $LATEST
[Error] - The term 'Requires' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I get the same issue as brendan-sherrin when using the AWSPowershell.NetCore module version 4.0.6.0 and uncommenting the the line starting #Requires
The lambda getting published - but executing the lambda returns the error:
START RequestId: 46320f85-5466-4896-bed8-b094e055b47a Version: $LATEST
[Error] - The term 'Requires' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
EDIT: in the end I opted to include just the components that I needed for my lambda:
`#Requires -Modules @{ModuleName='AWS.Tools.Common';ModuleVersion='4.0.5.0'}
@{ModuleName='AWS.Tools.SimpleSystemsManagement';ModuleVersion='4.0.5.0'}`
Hi @jeffj254,
Good afternoon.
I was going through the backlog and encountered this issue. Looks like you had found solution to your problem. Please confirm if this issue could be closed.
Thanks,
Ashish
I suppose, though I think the issue still exists if you create a new lambda using the basic template and you have AWSPowerShell.NetCore installed since that will be the required module.
Some sort of documentation update might be useful to note that the NetCore module is too large to be deployed with a Lambda would probably be helpful.
You’re supposed to use the modular module for lambda development in the powershell language.
Regards,
Chris
From: Jeff Josephson notifications@github.com
Sent: Wednesday, September 2, 2020 5:50:10 PM
To: aws/aws-lambda-dotnet aws-lambda-dotnet@noreply.github.com
Cc: Christopher Glover topher90@outlook.com; Comment comment@noreply.github.com
Subject: Re: [aws/aws-lambda-dotnet] Publish-AWSPowershellLambda generating deployment larger than 250MB (#566)
I suppose, though I think the issue still exists if you create a new lambda using the basic template and you have AWSPowerShell.NetCore installed since that will be the required module.
Some sort of documentation update might be useful to note that the NetCore module is too large to be deployed with a Lambda would probably be helpful.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Faws%2Faws-lambda-dotnet%2Fissues%2F566%23issuecomment-686164607&data=02%7C01%7C%7C79179a5a9451450f4ffc08d84fa350d7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637346910133232909&sdata=evBIepX363fToeH2MFRjyHDNbJICAzKN7FzzYZzWJEk%3D&reserved=0, or unsubscribehttps://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKYJ77E7HL3GJM2OSJFIPRLSD3R4FANCNFSM4KHL5CCA&data=02%7C01%7C%7C79179a5a9451450f4ffc08d84fa350d7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637346910133232909&sdata=vQb4EErG8XCyMzxEeekzhJ6%2BrsT2Yn1pBlAdSKOeSCU%3D&reserved=0.
Hi @jeffj254,
I just checked, the documentation link Installing AWS Tools for PowerShell on Linux or macOS and Installing the AWS Tools for PowerShell on Windows mentions about the large AWSPowerShell.NetCore
module. Hope this helps, let me know if this issue could be closed.
Thanks,
Ashish
@ashishdhingra I'd be thinking add a note to the documentation that the single large AWSPowerShell.NetCore module will exceed the maximum upload size on Lambda as stands
@jeffj254 @brendan-sherrin Thanks for the feedback. I will discuss with the team if this could be added at appropriate place in documentation.
@ashishdhingra the tools for NT community is rather confusing due to there being so many options. AWS has already recommended which tool to use which is the modular install. Can you guys just remove the other tools from the docs or is there something like dependency issues or something we don’t see that’s preventing AWS from being more organized with tools provided to NT community? IMHO the modular tool should be THE tool to use.
Regards,
Chris
From: Ashish Dhingra notifications@github.com
Sent: Wednesday, September 16, 2020 4:27:22 PM
To: aws/aws-lambda-dotnet aws-lambda-dotnet@noreply.github.com
Cc: Christopher Glover topher90@outlook.com; Comment comment@noreply.github.com
Subject: Re: [aws/aws-lambda-dotnet] Publish-AWSPowershellLambda generating deployment larger than 250MB (#566)
@jeffj254https://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjeffj254&data=02%7C01%7C%7C778a4b036a1343fe5c3108d85a981088%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637358956438051192&sdata=jkt5FllQ0W1y6E5DoDwhYtPWf3s%2Foai%2FzGcYNs8Ao2s%3D&reserved=0 @brendan-sherrinhttps://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fbrendan-sherrin&data=02%7C01%7C%7C778a4b036a1343fe5c3108d85a981088%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637358956438051192&sdata=VTj1aInZuOBorzUMxF9gWm7hzr9FYGZ%2BogJTKHFxZXE%3D&reserved=0 Thanks for the feedback. I will discuss with the team if this could be added at appropriate place in documentation.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Faws%2Faws-lambda-dotnet%2Fissues%2F566%23issuecomment-693719029&data=02%7C01%7C%7C778a4b036a1343fe5c3108d85a981088%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637358956438061186&sdata=7WSH7uGzD866wZyo9zB9gO1SMoSgvSj3dyGz0vN%2FcXc%3D&reserved=0, or unsubscribehttps://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKYJ77G2XJ62LB3MGSQ54STSGFCVVANCNFSM4KHL5CCA&data=02%7C01%7C%7C778a4b036a1343fe5c3108d85a981088%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637358956438061186&sdata=h6R9QbV3nVPRe5cUDH2W%2FOlQ2040G9HNH%2FBx9eT6BXc%3D&reserved=0.
Migrating from AWS Tools for PowerShell Version 3.3 to Version 4 specifies details of New Fully Modularized AWS.Tools Version
Most helpful comment
After some additional reading I think I might have the solution to my issue. AWSPowerShell.NetCore is a monolithic module that includes everything for all AWS services and supports Powershell 3 all the way to Powershell 6.
Instead of loading one giant module I can use the AWS.Tools modules (https://github.com/aws/aws-tools-for-powershell/issues/67) which are modular and allow me to only load the commandlets I need for my function. Doing it this way and only requiring aws.tools.s3 gives me a deployment zip size of 11MB and an uncompressed size of 33MB. Much better.
Might be worth updating the basic template to not reference the latest version of AWSPowerShell.NetCore though, since it's too large to deploy with a Lambda