我想调用一个AWS API Gateway endpoints ,该 endpoints 的执行AWS Lambda具有授权设置为AWS_IAM,执行角色有权执行该API网关 .
Is there anyway for me to sign the HTTPS request to API Gateway using the current execution role of my Lambda?
编辑:
查看http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html,我可以使用SDK调用AssumeRole来承担有权执行Api Gateway的角色,然后提取可用于签署请求的密钥 .
1 回答
可以从环境变量中检索lambda执行角色的凭证 - AWS_SESSION_TOKEN,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY .
您可以使用上述凭据对请求进行签名 . 签署文件在这里http://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html . 您还可以查看执行此操作的第三方库 .
请注意,由于您有会话令牌,因此您需要按照此处所述处理它http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html#RequestWithSTS