Recommand · June 6, 2021 0

Parameter validation failed: Unknown parameter in input: "Expires"

I have this lambda function which creates a signed URL for the Object in bucket and return a URL to API gateway .

here is my lambda function code

import uuid
import boto3

def lambda_handler(event, context):
    s3 = boto3.client('s3')

    upload_key = uuid.uuid4().hex

    bucket = 'test-bucket-athena'

    # Generate the presigned URL for upload
    presigned_upload_url = s3.generate_presigned_url(
            'Bucket': bucket,
            'Key': upload_key,
            'Expires': 3600

    # return the result
    return {
        "upload_url": presigned_upload_url
        #"download_url": presigned_download_url

When i run this code i get below error

[ERROR] ParamValidationError: Parameter validation failed: Unknown parameter in input: "Expires", must be one of: Bucket, IfMatch,
IfModifiedSince, IfNoneMatch, IfUnmodifiedSince, Key, Range,
ResponseCacheControl, ResponseContentDisposition,
ResponseContentEncoding, ResponseContentLanguage, ResponseContentType,
ResponseExpires, VersionId, SSECustomerAlgorithm, SSECustomerKey,
SSECustomerKeyMD5, RequestPayer, PartNumber, ExpectedBucketOwner
Traceback (most recent call last):   File
"/var/task/", line 14, in lambda_handler
    presigned_download_url = s3.generate_presigned_url(   File "/var/runtime/botocore/", line 586, in
    request_dict = serializer.serialize_to_request(   File "/var/runtime/botocore/", line 293, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())

I thought the S3 url that i have provide is not in correct format but i tested all combination and nothing seems to be working

I have tried below formats

bucket = 'test-bucket-athena'
bucket = 'test-bucket-athena/'
bucket = 's3://test-bucket-athena/'
bucket = 's3://test-bucket-athena'
bucket = 's3:///test-bucket-athena'

Please suggest what silly mistake i am doing here