Im trying to change S3 file's metadata from python, and test with chalice server locally (need the chalice for other things). When running (without chalice server):
# change file metadata in s3:
s3 = boto3.resource('s3')
s3_object = s3.Object(bucket, key)
s3_object.metadata.update({'metadata-key': 'something'})
s3_object.copy_from(CopySource={'Bucket': bucket, 'Key': key}, Metadata=s3_object.metadata,
MetadataDirective='REPLACE')
In python locally (with aws configured locaclly) everything is fine and the metadata is changing in S3.
The problem is when using chalice python local server, Im getting this error:
An error occurred (404) when calling the HeadObject operation: Not Found
(I need the chalice to simulate a lambda, and the s3 metadata part is in there)
Any ideas why this happenes?
Thanks :-)
If the object exists, this error usually means the role you are using to make the request doesn't have the required permissions.
Your local tests with Python work because they are using your default AWS profile. But that key is not passed to the Chalice APP.
You need to add read/write permissions to that bucket for that Lambda in Chalice.