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

Event notification filters, multiple suffixes #1465

Closed
fyockm opened this issue Aug 25, 2015 · 3 comments
Closed

Event notification filters, multiple suffixes #1465

fyockm opened this issue Aug 25, 2015 · 3 comments
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information.

Comments

@fyockm
Copy link

fyockm commented Aug 25, 2015

1.7.46 added support for event notification filters for aws s3, which is great. However, I would like to see the ability to add multiple suffixes per event.

$ aws s3api put-bucket-notification-configuration --bucket my_bucket --cli-input-json '{
    "Bucket": "my_bucket",
    "NotificationConfiguration": {
        "LambdaFunctionConfigurations": [{
            "Id": "abc123",
            "LambdaFunctionArn": "arn:aws:lambda:us-east-1:123456:function:image_processor",
            "Events": [
                "s3:ObjectCreated:*"
            ],
            "Filter": {
                "Key": {
                    "FilterRules": [{
                        "Name": "suffix",
                        "Value": "jpg"
                    }, {
                        "Name": "suffix",
                        "Value": "png"
                    }, {
                        "Name": "suffix",
                        "Value": "gif"
                    }, {
                        "Name": "suffix",
                        "Value": "tiff"
                    }]
                }
            }
        }]
    }
}'

Current response:

A client error (InvalidArgument) occurred when calling the PutBucketNotificationConfiguration operation:
Cannot specify more than one suffix rule in a filter.

Why can't there be more than one suffix rule? The FilterRules array seems perfectly set up to handle multiple suffixes. I can workaround by creating a separate LambdaFunctionConfiguration for each suffix, but it should be much easier.

@kyleknap
Copy link
Contributor

This error is being thrown by S3. It looks like S3 does not support including multiple suffixes in the FilterRules element. To do what you want, I believe you will have to create a new element in the LambdaFunctionConfigurations for each suffix based on the S3 docs: http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-filtering. So something like this:

"LambdaFunctionConfigurations": [{
            "Id": "jpg",
            "LambdaFunctionArn": "arn:aws:lambda:us-east-1:123456:function:image_processor",
            "Events": [
                "s3:ObjectCreated:*"
            ],
            "Filter": {
                "Key": {
                    "FilterRules": [{
                        "Name": "suffix",
                        "Value": "jpg"
           }]}}},
           {"Id": "gif",
            "LambdaFunctionArn": "arn:aws:lambda:us-east-1:123456:function:image_processor",
            "Events": [
                "s3:ObjectCreated:*"
            ],
            "Filter": {
                "Key": {
                    "FilterRules": [{
                        "Name": "suffix",
                        "Value": "gif"
           }]}}}
]

Let me know if this helps.

@kyleknap kyleknap added question closing-soon This issue will automatically close in 4 days unless further comments are made. labels Aug 25, 2015
@fyockm
Copy link
Author

fyockm commented Aug 25, 2015

@kyleknap thanks for the response. your suggestion is exactly what I did. this issue was more of a feature request than a bug report.

@kyleknap
Copy link
Contributor

Good to hear that you got it working.

Unfortunately, there is not really anything the CLI can do from its side, as we just send requests and parse responses based on S3's API. If would recommend requesting the feature to S3 through their forums: https://forums.aws.amazon.com/forum.jspa?forumID=24. If they add support for this, the CLI will automatically pick this up. Closing issue.

@diehlaws diehlaws added guidance Question that needs advice or information. and removed question labels Jan 4, 2019
thoward-godaddy pushed a commit to thoward-godaddy/aws-cli that referenced this issue Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

3 participants