-
Notifications
You must be signed in to change notification settings - Fork 30
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 framework- Await on an asynchronous action in a hook #700
Comments
@s1mrankaur Dashboard outputs are read from Service configuration, and this configuration cannot change after plugin initialization. It means that you cannot modify dashboard outputs after deployment. Conceptually Dashboard outputs are prerequisites for deployment and not its outcome. |
@medikoo Thanks for your response. After reading your comment, I modified the plugin to use
and the dashboard still doesn't get the updated value. Since it returns a promise, I suppose it will await on the package:initialize hook for the ssm update to complete. Why does it still not sync the updated value to the dashboard? Here's what the deployment logs look like:
Going by " this configuration cannot change after plugin initialization" and looking at the sequence of events at the top, I expected it to read the updated value from SSM but it still is reading the old value. Thoughts? |
@s1mrankaur in my understanding this feature doesn't have public facing API. Best if you contact Dashboard support about that |
@medikoo Thanks. I did but they wouldn't respond :( I tried to go through the dashboard-plugin code though and it seems to create artifacts in before:package:createDeploymentArtifacts dashboard-plugin/lib/plugin.js Line 238 in dc19abd
If the artifacts are being created after the hook that I am updating SSM in, what might be the reason for it to leave out the updated values? |
@s1mrankaur the issue at hand here is that SSM is read at the start when variables are initialized and not updated from source later. If you pass a value to SSM why not just pass the same value you sent to SSM to the outputs as well to save the new value. In fact, why send to SSM at all as you can both save and read from outputs like SSM but its cheaper and easier. |
@garethmcc Thanks for your response. Ah, I didn't know I can read the value from outputs, I am happy to increment it just there and skip the SSM bit altogether. This may actually work :) I'll keep you posted |
@garethmcc I tried to go with the suggested approach but it doesn't seem to work yet. Added the following function:
In the serverless.yml file, I added
My console log statements give
Am I not reading the output correctly? I tried passing "${output:${self:service}.app-version}" both to an environment variable and tried using
The requirement is basically:
I'd appreciate some clarity here, Thanks |
@s1mrankaur I'm a bit confused here. Can you in one sentence, clarify what you're trying to achieve? The relation of SSM and Dashboard Outputs is not clear to me here |
@medikoo Thanks for your response. Here it goes: My end goal is to show the version number of each serverless microservice on the "Serverless Dashboard". I am using "Serverless Dashboard Outputs" for the same. We have been incrementing and maintaining our version numbers on each deployment in SSM thus the first attempt was to fetch the updated deployment number from SSM and send it to Serverless Dashboard Outputs. I gave that a go and realized it is not feasible no matter how early on I update the version in SSM during the deployment process, the dashboard always picked the last version number and not the most recent one. In response to @garethmcc's suggestion, I then tried to read the version directly from Serverless Outputs Dashboard and skip SSM altogether. The issue with the approach is that instead of getting the version number in my app-version.js file, I get the expression i.e "${output:${self:service}.app-version}" thus I still am not able to get the version in my js file to read it, increment it and send it back to the SLS dashboard outputs on every new deployment. Please let me know if I can clarify this further. |
@s1mrankaur so to summarize, I believe you're doing following:
Is that correct? |
@medikoo That's absolutely correct. Continuing the suggestion from @garethmcc, Based on what I've read, something like the following should be possible i.e resolving the variables in app-version.js based on the unevaluated expressions that I see at the stage when app-version.js is triggered.
Is resolveVariable supposed to be the fix here? I haven't tried it yet though. |
@s1mrankaur, thanks for the clarification. Outputs are sent to the Dashboard with If you want to adjust Outputs after deployment but before they're sent to the Serverless Dashboard, I think it's fine if in your plugin you attach to the very same hook and over there do the job of (1) storing new version in SSM (2) updating Having that done it's the updated values that should be sent to the Serverless Dashboard |
Hi @medikoo Thanks for your response. I thought so and did the ssm update in after:aws:deploy but it hasn't been using the updated value so far. Can you elaborate on how I could possibly update |
Simply alter |
We are using the serverless framework in the application for our backend microservices and I am looking to update the microservice version number in SSM from a serverless lifecycle hook mentioned below
after:deploy:deploy
After it gets updated, I'd like to see those versions in Serverless dashboard outputs
https://www.serverless.com/framework/docs/guides/output-variables#:~:text=The%20Serverless%20Framework%20Dashboard%20helps,key%2Fvalues%20in%20other%20serverless.
Based on the info I have, the outputs dashboard gets updated in serverless at "after:was:info:disolayServiceInfo" hook".
So I'd like to ensure that SSM update action is waited upon in the hook before the framework proceeds to the next step as recommended here serverless/serverless#4557 (comment)
Here's what the plugin looks like:
The version updated in the Outputs dashboard picks the last version, not the updated version after deployment.
What am I missing?
The text was updated successfully, but these errors were encountered: