Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: add support for s3.put_object IfNoneMatch option #8091

Closed
mbant opened this issue Sep 6, 2024 · 2 comments · Fixed by #8109
Closed

enhancement: add support for s3.put_object IfNoneMatch option #8091

mbant opened this issue Sep 6, 2024 · 2 comments · Fixed by #8109

Comments

@mbant
Copy link

mbant commented Sep 6, 2024

S3 recently added support for conditional writes: https://aws.amazon.com/about-aws/whats-new/2024/08/amazon-s3-conditional-writes/

https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html#API_PutObject_RequestParameters

Would be cool to be able to test this using moto!

The issue can be tested with the following snippet

import boto3
from moto import mock_aws

with mock_aws():
    s3 = boto3.client("s3", region_name="us-east-1")
    s3.create_bucket(Bucket="test_bucket")

    first = s3.put_object(
        Key="test_object",
        Body="test",
        Bucket="test_bucket",
        IfNoneMatch="*",
    )

    second = s3.put_object(
        Key="test_object",
        Body="another_test",
        Bucket="test_bucket",
        IfNoneMatch="*",
    )

assert second['ResponseMetadata']['HTTPStatusCode'] == 412

You can see for yourself that this fails (as in the write to S3 succeeded) using mock_aws() while it behaves correctly if I use a real S3 client on a real bucket.

@bblommers
Copy link
Collaborator

Hi @mbant, welcome to Moto! I've opened a PR with support for this feature.

@mbant
Copy link
Author

mbant commented Sep 10, 2024

Hi @bblommers ! Thanks for the quick turnaround for this one :)

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants