calling IAM auth function urls from Lambda

1

I have a 2 lambda functions

  1. Caller - calling the service mentioned #2
  2. Service - with function url with IAM permission setup.

From service lambda #1 I want to invoke service #2 . I searched online, all mentioned calling the function url using IAM credentials, but we don’t use IAM credentials inside calling Lambda right ?

Do we need to use the lambda role while configuring the lambda resource based policy ? Are there any CDK examples for Lambda with functions urls IAM permissions set ? Can some one share on this ?

1개 답변
1
수락된 답변

For invoking a Lambda function using its function URL, which is protected with IAM, you need to sign the request using SigV4. To create the signature you need to have AWS credentials which are allowed to invoke the function. If you invoke function #2 from a Lambda function #1, you need to attache an execution role to function #1 that has the right permissions.

You will need to sign the request yourself. The role is not enough. Depending on your language, there are different SDKs that may sign it for you.

profile pictureAWS
전문가
Uri
답변함 2년 전
profile picture
전문가
검토됨 9일 전
  • I am going to use java/kotlin in lambda #1 to invoke lambda #2. I referred the below link which requires the secret key. Does this secret key represents the IAM user's secret key ? If yes, how does this IAM user and lambda role linked ?

    https://docs.aws.amazon.com/general/latest/gr/signature-v4-examples.html#signature-v4-examples-java

    Where do we store the secrets in Lambda ? What is the best practice ? We also want to rotate the key periodically right.

  • The function has an execution role. You should retrieve the secret key from the role in the Lambda function. The runtime does it for you and you can find the information in environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠