Python AWS SAM lambda授权人互联网访问
仅添加到aws sam cli hello world示例并尝试添加lambda authorizer:Python AWS SAM lambda授权人互联网访问,python,amazon-cloudformation,aws-sam,Python,Amazon Cloudformation,Aws Sam,仅添加到aws sam cli hello world示例并尝试添加lambda authorizer: MyAuthFunction: Type: AWS::Serverless::Function Properties: CodeUri: ./python Handler: auth/authorizer.lambda_handler Runtime: python3.8 我的lambda需要从我的租户那里获取公钥,因此我需要一个外部get调用来获取它: d
MyAuthFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./python
Handler: auth/authorizer.lambda_handler
Runtime: python3.8
我的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'])
...
每次我击中lambda,它都会超时:
Function 'MyAuthFunction' timed out after 3 seconds
我是不是遗漏了什么?我觉得我的lambda无法访问互联网您应该将默认的3秒增加到您的功能成功运行所需的时间(最多15分钟)
例如:
MyAuthFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./python
Handler: auth/authorizer.lambda_handler
Runtime: python3.8
Timeout: 60 # one minute
@Wildhammer在3秒后仍然超时?我尝试增加超时时间,但如我所说,我怀疑我的lambda无法访问internet。@Wildhammer是否将其放置在VPC中?否,除非sam cli在本地测试时将所有内容放置在类似VPC的位置。