I am attempting to test this AWS S3 PreSignedURL Lambda Function
import boto3
from botocore.exceptions import ClientError
def lambda_handler(bucket='bg-us-east-1-bucket', key='filename.jpg', expiry=3600):
"""
Method to get post url from s3
:param bucket: name of s3 bucket
:param key: key of the file
:return:
"""
try:
presigned_post = boto3.client('s3').generate_presigned_post(
bucket,
key,
ExpiresIn=expiry
)
return SimpleNamespace(success=True, data={
'upload_url': presigned_post['url'],
'fields': presigned_post['fields']
})
except ClientError:
return SimpleNamespace(
success=False,
error='Unable to upload image'
)
I test with this Test Event:
{
"bucket": "bg-us-east-1-bucket",
"key": "value3"
}
and I get this Execution error response:
"errorMessage": "Parameter validation failed:
Invalid type for parameter Bucket, value: {'bucket': 'bg-us-east-1-bucket', 'key': 'value3'}, type: <class 'dict'>, valid types: <class 'str'>",
"errorType": "ParamValidationError",
Any suggestions what is causing this AWS Lambda error response?
question from:
https://stackoverflow.com/questions/65893377/aws-s3-presignedurl-lambda-function-test-error 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…