我用lambda编写python代码来创建快照,直到它完成执行剩下的代码,但是我有错误。
"errorMessage": "Parameter validation failed:\nUnknown parameter in input: \"SnapshotsId\", must be one of: Filters, MaxResults, NextToken, OwnerIds, RestorableByUserIds, SnapshotIds, DryRun",
"errorType": "ParamValidationError",代码
from __future__ import print_function
import botocore
import boto3
import urllib.request
def lambda_handler(event, context):
ec2_client = boto3.client('ec2', region_name='eu-west-1')
snapshot1 = ec2_client.create_snapshot(VolumeId='vol-054c95927bb8ed4a9', Description='Created by Lambda backup function ebs-snapshots')
try:
snapshot_id = snapshot1['SnapshotId']
snapshot_complete_waiter = ec2_client.get_waiter('snapshot_completed')
snapshot_complete_waiter.wait(SnapshotsId=['snapshot_id'])
except botocore.exceptions.WaiterError as e:
if "max attempts exceeded" in e.message:
print("snapshot not completed")
else:
print(e.message)发布于 2019-12-02 13:30:15
您必须使用SnapshotIds而不是SnapshotsId
from __future__ import print_function
import botocore
import boto3
import urllib.request
def lambda_handler(event, context):
ec2_client = boto3.client('ec2', region_name='eu-west-1')
snapshot1 = ec2_client.create_snapshot(VolumeId='vol-054c95927bb8ed4a9', Description='Created by Lambda backup function ebs-snapshots')
try:
snapshot_id = snapshot1['SnapshotId']
snapshot_complete_waiter = ec2_client.get_waiter('snapshot_completed')
snapshot_complete_waiter.wait(SnapshotIds=[snapshot_id])
except botocore.exceptions.WaiterError as e:
print(e)发布于 2021-03-16 11:14:49
使用此功能:
snapshot.wait_until_completed()https://stackoverflow.com/questions/59139882
复制相似问题