gpt4 book ai didi

python - 使用python在Lambda函数中运行命令wirth SSM

转载 作者:太空宇宙 更新时间:2023-11-03 20:04:28 25 4
gpt4 key购买 nike

我在 lambda 中编写了 python 代码,用于从 SSM 运行命令,但出现错误错误

回复:{ "errorMessage": "2019-11-26T10:51:09.649Z d6a9aff6-9da9-477c-82b4-100d96a316fe 任务在 3.00 秒后超时"}

请求 ID:“d6a9aff6-9da9-477c-82b4-100d96a316fe”

功能日志:开始请求 ID:d6a9aff6-9da9-477c-82b4-100d96a316fe 版本:$LATEST结束请求 ID:d6a9aff6-9da9-477c-82b4-100d96a316fe报告请求 ID:d6a9aff6-9da9-477c-82b4-100d96a316fe 持续时间:3003.16 毫秒 计费持续时间:3000 毫秒 内存大小:128 MB 最大使用内存:34 MB
2019-11-26T10:51:09.649Z d6a9aff6-9da9-477c-82b4-100d96a316fe 任务在 3.00 秒后超时

代码

   from __future__ import print_function

import json

import boto3
import urllib.request

ec2_client = boto3.client('ec2', region_name='us-west-1')
ssm_client = boto3.client('ssm', region_name='us-west-1')

client = boto3.client('ssm')
params={"commands":["mkdir reham1"],"workingDirectory":["/home"],"executionTimeout":["3600"]}
response = ssm_client.send_command(DocumentName="AWS-RunShellScript", InstanceIds="i-0fb28a7b3786adee1",Comment='logging the', TimeoutSeconds=600, Parameters=params)

最佳答案

您的 Lambda 函数上的超时设置似乎设置为 3 秒,但它需要比 SSM 命令更长的时间才能完成(如您在 SSM 命令上设置的 600 秒超时所示)。您需要增加 Lambda 函数的超时。

关于python - 使用python在Lambda函数中运行命令wirth SSM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59049601/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com