-
-
Notifications
You must be signed in to change notification settings - Fork 794
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
AWS profile cannot be loaded when the --useWorkerThreads
option is used
#1430
Comments
thank you for the repro @MiyamotoTa ! I'll try to have a look soon. does this apply to |
@dnalborczyk Yeah, it worked removing that option. |
looking into this again, I remember now that using worker threads is closer to the behavior of lambda functions ("containers") within node.js. when you run in order for you to use a local env variable with worker threads you would have to pass it explicitly to your function, in the same way you would have to do with just provider:
# either at the provider level
environment:
FOO: ${env:FOO}
functions:
foo:
# or the function level
environment:
FOO: ${env:FOO} edit, fixed example to make it more clear to lift the local env variable |
@dnalborczyk Great, I'll try it the way. |
added some additional tests @MiyamotoTa b5559cc#diff-6f01d26e6c42c1c26923cd15ccdfd64a3054931dfbd7b8f957f6dcf2b41dfed3R1 we could potentially copy over the |
Hi. I'm running into the same problem, but I can't solve it this way. We use aws-vault and AWS SSO, so we have NO creds on the machine, ever, except temporary session creds in environment variables. I noticed that worker threads were going to be default, and we were having trouble with child processes, so thought it was a good time to switch. (that one is in Now I get this error:
This is a false error, kinda. Its not found AWS creds in the environment (sound familiar?) so it's looking for the ECS/EC2 endpoint, and not finding it. I can sort of fake that by using The problem, I guess, is that you're not copying environment variables from the main process to the worker thread, as per:
So, if you're not doing that, then anyone using ONLY AWS environment variables will get this error, and not be able to use SLS with worker threads (and these days if you have creds in Hope that helps @dnalborczyk |
If you wanted to limit the items you are copying over, I think these should be enough, tho
|
I assume you are using this tool: https://github.com/99designs/aws-vault ? I have not used it myself yet.
unfortunately I'm not sure what you are referring to, could you open a new issue for this?
is this the
the intention of this is that the "lambda" is encapsulated like the real container lambda. currently, when you deploy with serverless, how are your AWS creds created and consumed on the AWS side-of-things? just noticed, that my example from above wasn't quite clear: // cc @MiyamotoTa this "lifts" any local env vars to provider:
# either at the provider level
environment:
FOO: ${env:FOO}
functions:
foo:
# or the function level
environment:
FOO: ${env:FOO}
it always helps to hear other opinions 😉 |
if we still think this is needed, we should just copy (clone) over everything, with a specific order of precedence. (clone -> provider -> function). |
Copying over the |
labeling as feature. I can see the need for this. Tho I think we should copy over everything instead of just restricting it to |
added with: #1513 |
what I ended up implementing is the automatic copying of any please let me know if that fixes your issue (ideally without the flag). |
Bug Report
Current Behavior
When the
--useWorkerThreads
option is enabled, the value of AWS_PROFILE cannot be referenced and valid credentials cannot be retrieved. Therefore, the following error occurs.Sample Code
Please prepare a profile that can run AWS Comprehend as a preliminary step.
(I've not checked other AWS clients, but I expect this to occur for other than Comprehend.)
https://github.com/MiyamotoTa/repro-sls-offline-aws_profile
Check out the above repository and execute the following command and send the request.
Also, the client's region is hard-coded, so please change it if necessary.
Expected behavior/code
As with the case without the
--useWorkerThreads
option, a valid credential should be obtained and no errors should occur.Environment
serverless
version: 3.0.0serverless-offline
version: 8.8.0node.js
version: 14.18.0OS
: macOS 12.3.1Possible Solution
N/A
Additional context/Screenshots
N/A
The text was updated successfully, but these errors were encountered: