1
現在、パラメータとして渡された値でDynamoDBテーブルを更新するラムダ関数があります。 I "TEST"
に設定されたテストパラメータでラムダコンソール内で次を実行することができています:私は、次のJSON文書から構築されたSSMオートメーションからこれを呼び出そうとしていますパラメータ付きAWS SSMオートメーションからラムダを実行
import boto3
import json
def lambda_handler(event, context):
# TODO implement
update_ami(event)
def update_ami(ami_id):
#DO STUFF
:
{
"description":"Test Execute Lambda Function.",
"schemaVersion":"0.3",
"assumeRole":"MYARN",
"parameters":{},
"mainSteps":[
{
"name": "invokeMyLambdaFunction",
"action": "aws:invokeLambdaFunction",
"maxAttempts": 3,
"timeoutSeconds": 120,
"onFailure": "Abort",
"inputs": {
"FunctionName": "MyLambdaFunction",
"Payload": "TESTER"
}
}
]
}
次のエラーで、この自動化の結果を実行すると:私はまた、JSONオブジェクトinsteaとしてPayload
入力を渡して試してみました
Automation Step Execution fails when it is invoking the lambda function. Get Exception from Invoke API of lambda Service. Exception Message from Invoke API: [Could not parse request body into json: Unrecognized token 'TESTER': was expecting ('true', 'false' or 'null')
それに応じて文字列のD、および調整私のラムダ方法:
JSONオートメーション:
...
"inputs": {
"FunctionName": "MyLambdaFunction",
"Payload": {
"ami_id": "AMI-TESTER"
}
}
...
ラムダはPython:これは内部オートメーション文書エディタから次のようなエラーになり
def lambda_handler(event, context):
# TODO implement
update_ami(event['ami-id'])
SSMコンソール:
Input {ami_id=TESTER} is of type class java.util.LinkedHashMap, but expected type is String.
だから一言で言えば、どのようにすればいいですか?オートメーション文書からラムダ関数へ