我正在尝试在 Lambda 函数中编写 Python 代码,该代码将在警报触发时启动停止的工作区。响应类型是 dict。
但我得到了错误。下面是我的代码和错误。
import json
import boto3
client = boto3.client('workspaces')
def lambda_handler(event, context):
response = client.describe_workspaces(
DirectoryId='d-966714f114'
)
#print(response)
print("hello")
for i in response['Workspaces']:
if(i['State']== 'STOPPED'):
print(i['WorkspaceId'])
client.start_workspaces(i['WorkspaceId'])
{
"errorMessage": "start_workspaces() only accepts keyword arguments.",
"errorType": "TypeError",
"stackTrace": [
" File \"/var/task/lambda_function.py\", line 21, in lambda_handler\n client.start_workspaces(i)\n",
" File \"/var/runtime/botocore/client.py\", line 354, in _api_call\n raise TypeError(\n"
]
}