-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Serverless null error when using SSM variables that not exist in region #5110
Comments
Same issue here, randomly appeared after working most of the day. Using serverless-offline. Editing the same function as above but returning early so it wont trigger trigger the rejection and I can finally start my application. I was also able to start it by using a region I've never used before. I've also downgraded to 1.27.x and still have the issue. To me it seems like a random AWS problem since it was ok after the update then randomly broke no matter the version. Subbed for a proper resolution. <3 serverless! |
@gcphost yep, I thought the same after checking the latest releases, seems that AWS changed something since the project was working the before. |
Got the same problem with a null error. However, I actually found it was non-deterministic. Most of the time it would show the null error, but about 1/3 of the time it would instead show me a warning:
|
Encountering this issue both with serverless-offline and deploying. It seems to occur any time Serverless encounters an SSM parameter that does not exist, even if there is a default to fallback to. Temporarily worked around this issue by commenting out const expectedErrorMessage = `Parameter ${param} not found.`;
if (err.message !== expectedErrorMessage) {
return BbPromise.reject(new this.serverless.classes.Error(err.message));
} in Additional note: Affects all versions from 1.26 through 1.28 |
I decided to check this AM and simply put, err.message is
if (err.message && err.message !== `Parameter ${param} not found.`) {
return BbPromise.reject(new this.serverless.classes.Error(err.message));
}
return BbPromise.resolve(undefined); I'm uncertain if the error message will ever equal |
Can also confirm that Upon further inspection of the error that's being raised in the JS, it seems like there's a lot of other information contained in that error object that could be used to determine if the error is in fact a ParameterNotFound error. It's not clear why the choice was made to do a string comparison on the message itself over, say, checking the HTTP status code, but that would probably to allow "missing param" errors to pass through as a warning. |
You can do this:
|
Hey y'all, I'm new to using SSM and I'm having the same issue--quick question: Is the issue at stake that there is no error message printed? Or is the issue that having an unset ssm variable triggers an error? To me, it should be the latter, so that I can pull from SSM, but if not set, use a default value. (i.e. for env-specific configs). Is this right? |
@jacobevans yes, the latter, it should pull the default value without triggering the error. |
@crash7 thanks yeah, thats what I thought/hoped. You doing anything as a workaround in the meantime? |
@jacobevans yes, editing the code I mentioned in the issue, in the file serverless/lib/classes/Variables.js. |
PR is now passing. The tests were sending a 123 error code instead of a 400. |
I know there's a PR up for this but I thought it'd be worth mentioning. I got this because I use an AWS credential switcher for numerous accounts I work with and forgot to switch back to right account so sls offline will bug out because as you rightly say the credentials don't exist. I'm not suggesting that you make any changes but hopefully, future readers will have the facepalm moment I did when they read this. :-) |
#5110 null error on undefined AWS SSM variables
On a related note, when the Serverless Error ---------------------------------------
Inaccessible host: `ssm.us-west-1.amazonaws.com'. This service may not be available in the `us-west-1' region. If a default is provided (by means of configuring vars like so |
I am using serverless 1.33.1 and I deployed my SSM with:
And when I try to invoke the lambda locally, I am getting this error:
Does anyone know what I should do to fix this? Is it a permission issue? |
@dagumak Make sure you have a valid url for your ssm parameter, starting with a slash eg. |
I get this when I use either the wrong AWS profile from ~/.aws/credentials(Mac) or if I have the wrong region selected as above @okarlsson make sure you've got the right format.
the above includes the stage name since I have multiple stages in one account. Remember by default serverless will use the [default] profile from your AWS creds unless you have env vars specified(I think?) In short I don't think this is a bug - it's a local config issue. |
Closing, as it's solved with new variable resolver, which crashes on not existing parameter only if fallback wasn't provided |
This is a Bug Report
Description
Serverless throws an error when using SSM variables that not exist in the AWS region.
For bug reports:
When the variable doesn't exists in the configured region, I get a null error in serverless
What did you expect should have happened?
sls script runs normally
What was the config you used?
I got this after adding a console log in getValueFromSsm, seems that the promise is rejected because something changed in the error message expected in this case
Additional Data
The text was updated successfully, but these errors were encountered: