Open austoonz opened 1 year ago
Is this a request to show how to deploy and use the runtime? This is what I'm after too so if there are any instructions I'd me most grateful.
Is this a request to show how to deploy and use the runtime? This is what I'm after too so if there are any instructions I'd me most grateful.
yes it is. It is to offer an example of how to deploy the custom runtime, using nothing but powershell cmdlets/modules.
I am patiently awaiting this.
Every time we try to go down this route for a pure Windows PowerShell build, the underlying Lambda layer is not formatted correctly. For example the /opt/bootstrap
file won't be marked with the executable bit in Linux. Or the CloudFormation template ends up UTF8 with BOM, even though we are forcing utf8
with the Set-Content
cmdlet.
The only reliable way we've currently found to build from Windows is to use WSL from Windows, and the SAM CLI from within WSL.
...reliable way we've currently found to build from Windows...
Greets. Firstly, still loving this Lambda PS runtime -- so good! Thx @austoonz and e'erbody that has made this
As for building/deploying a working runtime layer from Windows directly (as in, not from within WSL), I've been able to succeed in at least a couple of ways. In effort to see how I can help with this issue, I'll share those here to get feedback.
❓ My question to the group: what, beyond the descriptions below, will be most helpful in enabling people to succeed in this use case of, "new Lambda PS runtime layer built and deployed from directly within Windows"? Like, having a repo with steps/examples of end-to-end success? Or, me just submitting a PR to this current repo with a Docs update? Something else?
Success from Windows via each of:
-Encoding
param value to Ascii
from UTF8
(prevents the aforementioned BOM issue)Steps:
git clone https://github.com/awslabs/aws-lambda-powershell-runtime
powershell-runtime/build-PwshRuntimeLayer.ps1
sam deploy --template powershell-runtime/template.yml --<rest of "profile" and "s3bucket" params>
Thank you for the details.
I will note that in both a Windows Workspace and a Windows EC2 Instance of mine, the above does not work from either PowerShell or Windows PowerShell (after changing the -Encoding
parameter). Both end up failing with the following error, which is indicating the execute bit of the bootstrap file is not set correctly.
For me, using the PowerShell build script in PowerShell on Linux does not work either... same end result with a broken bootstrap.
{
"errorType": "Runtime.InvalidEntrypoint",
"errorMessage": "RequestId: 665609a7-17d4-496c-b052-1b0c463561b2 Error: fork/exec /opt/bootstrap: exec format error"
}
For awareness from further testing, I think this error might have something to do with the pwsh
binary, not the bootstrap file.
In my Linux testing, after building the layer with sam build
, I can run ./.aws-sam/build/PwshRuntimeLayer/powershell/pwsh -version
with success. However in the build using PowerShell, ./layers/runtimeLayer/powershell/pwsh -version
results in layers/runtimeLayer/powershell/pwsh: cannot execute binary file
.
That's where I'm now looking...
Found what I think the issue is, will test further across Windows, Linux, and PowerShell/Windows PowerShell to confirm. The examples/demo-runtime-layer-function
which I'm testing with is telling the PowerShell runtime build script to build using arm64
, instead of x64
.
...
New commits have been pushed to resolve the above issue.
I am leaving this issue open as I would still like to have complete PowerShell examples that do not depend on sam deploy
if possible.
...have complete PowerShell examples that do not depend on
sam deploy
...
Sounds good! @austoonz -- for the packaging portion of such an example, OK to use sam package
for the {zip up local resources, upload to S3, and transform SAM template with resultant ContentUri:
value}? Or are you picturing an example that uses a strictly CloudFormation template (no Transform:
property, no SAM whatsoever)?
...an example that uses a strictly CloudFormation template (no
Transform:
property, no SAM whatsoever..
In case this is the desire, I forked this repo and pushed a couple of commits that add such an example. See the comparison at https://github.com/awslabs/aws-lambda-powershell-runtime/compare/main..mtboren:aws-lambda-powershell-runtime_fork:feat_AddPShellDeployExample
How does that do for including a PowerShell-only deployment example, @austoonz?
I've taken a few stabs at running through the details you've outlined, and both times I end up with execution errors. I have yet to get to the root of the issue (and honestly I haven't spent any real time trying to troubleshoot it).
{
"errorType": "Runtime.InvalidEntrypoint",
"errorMessage": "RequestId: 3782d50a-942c-46e9-988a-06653dc5815b Error: Couldn't find valid bootstrap(s): [/var/task/bootstrap /opt/bootstrap]"
}
Provide an example for how to deploy the runtime using PowerShell (and only PowerShell).