AWS GreenGrass V2 Lambda - Token Exchange Service not loading credentials before the lambda is invoked

0

I am running a lambda on a greengrass core device and the lambda is invoked from an IOT Core message. The topic has a retained flag so the device gets the message if it is offline when published. When I restart the device and the lambda subscribes to the topic and the lambda is invoked immediately I get a CredentialsProviderError: Could not load credentials from any providers. If I then run publish the same message again after 5-10 seconds the lambda executed with no errors. Its as if the lambda is not loading the credentials before it is invoked. Is there a work around for this? I have the TokenExchangeService as a hard dependency for the lambda component:

 "aws.greengrass.TokenExchangeService": {
      "VersionRequirement": ">=2.0.0 <3.0.0",
      "DependencyType": "HARD"
  • Does the error message appear in the greengrass.log or in your lambda function component logs? Do you use an AWS SDK in your lambda to access a cloud-side AWS API? If you use an SDK in your code, could you dump the environment variable AWS_CONTAINER_CREDENTIALS_FULL_URI in your lambda code during both executions.

已提問 2 年前檢視次數 282 次
1 個回答
1

Hello Phil,

This is the expected behavior; credentials are not fetched until they are requested from the token exchange service (TES) by some application. All lambdas, for example, depend on TES by default, but not all lambdas may actually want or need credentials, so they are only fetched from AWS when something actually requests them.

Your lambda should retry the failed API call which will cause the credentials to be requested again. It should succeed on retries as long as the device is connected to the internet and is allowed to get credentials. Verify in /greengrass/v2/logs/greengrass.log that there are no errors when requesting credentials. You will see "Received IAM credentials that will be cached until" in the log file when credentials are successfully retrieved by Greengrass and cached.

Cheers,

Michael

AWS
專家
已回答 2 年前
AWS
專家
已審閱 9 個月前
profile pictureAWS
專家
Chris_G
已審閱 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南