![](/img/trans.png)
[英]"AttributeError: module 'boto3' has no attribute 'client'" error while trying to create lambda function using boto3 python 3.7 in VSCode
[英]How to pass RunProperties while calling the glue workflow using boto3 and python in lambda function?
我在 lambda 函數中的 python 代碼:
import json
import boto3
from botocore.exceptions import ClientError
glueClient = boto3.client('glue')
default_run_properties = {'s3_path': 's3://bucketname/abc.zip'}
response = glue_client.start_workflow_run(Name="Testing",RunProperties=default_run_properties)
print(response)
我收到這樣的錯誤:
"errorMessage": "Parameter validation failed:\nUnknown parameter in input: \"RunProperties\", must be one of: Name",
"errorType": "ParamValidationError",
我也試過這樣:
session = boto3.session.Session()
glue_client = session.client('glue')
但是得到了同樣的錯誤。
任何人都可以告訴如何在調用膠水工作流運行時傳遞 RunProperties。RunProperties 是動態的,需要從 lambda 事件傳遞。
我有同樣的問題,這有點棘手。 我不喜歡我的解決方案,所以也許其他人有更好的主意? 見這里: https ://github.com/boto/boto3/issues/2580 還有這里: https ://docs.aws.amazon.com/glue/latest/webapi/API_StartWorkflowRun.html
因此,您在啟動工作流時無法傳遞參數,這在我看來是一種恥辱,因為即使是 CLI 也建議: https ://docs.aws.amazon.com/cli/latest/reference/glue/start-workflow -run.html
但是,您可以在啟動工作流之前更新參數。 然后為每個人設置這些值。 如果您期望任何“並發”問題,那么這不是一個好方法。 您需要決定是在之后重置這些值還是將其留到工作流程的下一次開始。
我開始我的工作流程是這樣的:
glue_client.update_workflow(
Name=SHOPS_WORKFLOW_NAME,
DefaultRunProperties={
's3_key': file_key,
'market_id': segments[0],
},
)
workflow_run_id = glue_client.start_workflow_run(
Name=SHOPS_WORKFLOW_NAME
)
我遇到了同樣的問題,並在AWS re:Post中詢問。 問題是 Lambda 中使用的舊boto3
版本。 他們推薦了兩種解決此問題的方法:
start_workflow_run
之后立即更新 Job 的運行屬性:default_run_properties = {'s3_path': 's3://bucketname/abc.zip'}
response = glue_client.start_workflow_run(Name="Testing")
updateRun = glue_client.put_workflow_run_properties(
Name = "Testing",
RunId = response['RunId'],
RunProperties = default_run_properties
)
boto3
版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.