Skip to content

Conversation

pudkrong
Copy link
Contributor

Lambda SSM extension might not be ready yet when we request. So, we need to handle properly otherwise it will crash lambda and error loop

@pudkrong pudkrong requested a review from coderbyheart as a code owner June 28, 2023 19:03
@coderbyheart
Copy link
Member

This change deals with the lock, nothing with SSM related?

Lambda parameter store extension will be ready to read inside the handler.
Calling it outside handler might not get the value.
@pudkrong pudkrong force-pushed the fix-read-nrf-cloud-key-from-ssm branch from 38e5198 to 90b9544 Compare June 28, 2023 20:28
@pudkrong pudkrong temporarily deployed to ci June 28, 2023 20:28 — with GitHub Actions Inactive
@pudkrong
Copy link
Contributor Author

This change deals with the lock, nothing with SSM related?

Sorry, I will create a separated PR to fix lock.

For the SSM cannot read nRF Cloud API Key, the root cause is that reading parameter from outside handler might be failed due to lambda parameter store is not ready yet. Therefore, I reverted the previous changes and commit the new fix.

websocketDeviceConnectionsTableName,
)
const deviceShadowPromise = (async () => {
const deviceShadowPromise = once(async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This effectively does the same thing as before. It ensures that deviceShadowPromise only exists once. It will stay in a rejected stated if parameters cannot be fetched.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. Now I see. It does fix the problem, because the lambda is invoked only in the handler.

@coderbyheart coderbyheart merged commit 735f6c0 into saga Jun 29, 2023
@coderbyheart coderbyheart deleted the fix-read-nrf-cloud-key-from-ssm branch June 29, 2023 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants