stackme
stackme

Reputation: 3

lambda issue connecting to s3 for put_object but get_object works

I have a lambda which is connecting to s3 and reading a file then it does some manuplation on the file and puts it back to a different bucket. my lambda has appropriate role to connect to s3 so its not a issue. I am able to read the file form s3 download into /tmp/ folder on lambda and do the changes. But when i try to put it back its using s3_client.put_object it gives following error

s3_client = boto3.client("s3")
# read the file
file_obj = s3.get_object(Bucket=bucket_name, Key=bucket_key)
file_content = file_obj["Body"].read()
# do some manuplation on it and try to upload it back to the s3
s3_client.put_object(Bucket=bucket_name, key=outbound_bucket_key, Body=output_path)
Parameter validation failed:
Missing required parameter in input: "Key"
Unknown parameter in input: "key", 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, RequestPayer, Tagging, ObjectLockMode, ObjectLockRetainUntilDate, ObjectLockLegalHoldStatus
END RequestId: 88fd1324-7b14-4b24-b414-a0a04bb97bbd
REPORT RequestId: 88fd1324-7b14-4b24-b414-a0a04bb97bbd Duration: 4511.74 ms Billed Duration: 4600 ms Memory Size: 128 MB Max Memory Used: 128 MB Init Duration: 1179.77 ms

Upvotes: 0

Views: 1764

Answers (1)

amittn
amittn

Reputation: 2355

  • I think it just a typo in here, you need to use Key and not key that what the error says.
s3_client.put_object(Bucket=bucket_name, Key=outbound_bucket_key, Body=output_path)

  • All this are first letter capital Bucket, Key, Body.

Upvotes: 1

Related Questions