[英]AWS SAM lambda authorizer internet access
Just adding to aws sam cli hello world example and trying to add lambda authorizer:只需添加到 aws sam cli hello world 示例并尝试添加 lambda 授权器:
MyAuthFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./python
Handler: auth/authorizer.lambda_handler
Runtime: python3.8
My lambda needs to get a public key from my tenant so I need an external get call to get it:我的 lambda 需要从我的租户那里获取公钥,所以我需要一个外部 get 调用来获取它:
def lambda_handler(event, context):
...
print("getting pub key from", 'https://%s/pem' % os.environ['AUTH_DOMAIN'])
pub_key = requests.get('https://%s/pem' % os.environ['AUTH_DOMAIN'])
...
Every time I hit the lambda it gets timed out:每次我点击 lambda 时,它都会超时:
Function 'MyAuthFunction' timed out after 3 seconds
Am I missing something here?我在这里错过了什么吗? I feel like my lambda doesn't have access to the internet我觉得我的 lambda 无法访问互联网
You should increase Timeout , from default 3 seconds to whatever is required for your function to work successful (max 15 min).您应该增加Timeout ,从默认的 3 秒增加到您的函数成功运行所需的任何时间(最多 15 分钟)。
For example:例如:
MyAuthFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./python
Handler: auth/authorizer.lambda_handler
Runtime: python3.8
Timeout: 60 # one minute
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.