0

I am trying to write a lambda function to upload file to S3 using PutObject with checksum. However I am getting the error Unknown parameter in input ChecksumAlgorithm

"errorMessage": "Parameter validation failed:\nUnknown parameter in input: \"ChecksumAlgorithm\", must be one of: ACL, Body, Bucket, CacheControl, ContentDisposition, ContentEncoding, ContentLanguage, ContentLength, ContentMD5, ContentType, Expires, GrantFullControl, GrantRead, GrantReadACP, GrantWriteACP, Key, Metadata, ServerSideEncryption, StorageClass, WebsiteRedirectLocation, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, SSEKMSKeyId, SSEKMSEncryptionContext, BucketKeyEnabled, RequestPayer, Tagging, ObjectLockMode, ObjectLockRetainUntilDate, ObjectLockLegalHoldStatus, ExpectedBucketOwner",

Code is below:

import boto3

s3_conn=boto3.client('s3')
bucket_name="test123"

def lambda_handler(event, context):
  filename="./sample.txt"
  with open(filename, 'rb') as file:
        response = s3_conn.put_object(
            Bucket=bucket_name,
            Key='Test.txt',
            Body=filename,
            ChecksumAlgorithm='SHA1'
        )
  print(response)

As per boto3 documentation ChecksumAlgorithm is part of the S3 PutObject

VN-
  • 27
  • 6
  • Not sure if this is boto3 doing the parameter validation or the S3 service, but be sure that your boto3 library is up to date. – jarmod Nov 18 '22 at 15:42
  • 2
    If you're using Lambda, then you're using boto3 version [1.20.32](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html), but the checksum support was added in [1.21.7](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html). You'll need to follow [the directions to bring in a later version of boto3](https://aws.amazon.com/premiumsupport/knowledge-center/lambda-python-runtime-errors/) – Anon Coward Nov 18 '22 at 19:16
  • Thanks. I updated the boto3 version using the solution mentioned here[link](https://stackoverflow.com/questions/53736963/aws-lambda-console-upgrade-boto3-version) and that updated the version of boto3 in lambda. – VN- Nov 21 '22 at 08:03

0 Answers0