aws-samples / aws-lambda-environmental-variables-from-aws-secrets-manager

MIT No Attribution
37 stars 8 forks source link

.Net fails to start #10

Open hae-anwar-bardai opened 1 year ago

hae-anwar-bardai commented 1 year ago

Hi All, I implemented this solution with a node test script that displays the environment variables with no issues. We have a .NET runtime for which we are implementing these to fix exposed secrets issues. But once the wrapper executes the .Net runtime startup errors out with no reason specified. These are the Lambda logs: INIT_START Runtime Version: dotnet:core3.1.v14 Runtime Version ARN: arn:aws:lambda:us-east-1::runtime:7cbb73ab7c13b31a3c81dc02f85a149ca730c142e4f3b99100ec0594932d6ba0 No new layer was specified, unsetting AWS_LAMBDA_EXEC_WRAPPER [WARN] (invoke@invoke.c:331 errno: None) run_dotnet(dotnet_path, &args) failed RequestId: 3319b38f-cc58-4063-8af3-430c969679df Error: Runtime exited without providing a reason Runtime.ExitError

The Lambda function without this getSecret layer works successfully.

Any guidance will be greatly appreciated.

hae-anwar-bardai commented 1 year ago

from AWS official docs https://docs.aws.amazon.com/lambda/latest/dg/runtimes-modify.html#runtime-wrapper, it seems the args in the last line of the src/get-secrets-layer should be quoted: exec "${args[@]}" This fixed the issue with dotnet core 3.1. Wasn't sure if this can be applied universally, hence not initiating a pull request.

sergio-vf commented 1 year ago

@a-bardai can you share an example how you make it work using .net?

hae-anwar-bardai commented 1 year ago

@sergio-vf I made the following 2 changes to src/get-secrets-layer script:

78c78 < echo "export ${key}='${value}'" >> ${tempFile}

echo "export ${key}=\"${value}\"" >> ${tempFile}

102c102 < exec "${args[@]}"

exec ${args[@]}

and followed the rest of the documentation