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

S3 Event Notification Filter Rule Names changing string value from case insensitive to case sensitive #5329

Open
1 task
ge0Aja opened this issue Oct 21, 2024 · 0 comments
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@ge0Aja
Copy link

ge0Aja commented Oct 21, 2024

Describe the bug

I'm using FilterRuleNames to have a prefix filter when creating an event notification for an S3 bucket.
I'm using the const enum values provided by the SDK to create the filter. However, when I query back the created event notification and match against the filter rule name I get empty values.
I've checked on the created event notification and the rule seem to be there, but with a different name i.e. Prefix instead of prefix.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

I expect to find the created rule using the filter rule name provided by the SDK.

Current Behavior

If we iterate over the created filter names we won't be able to match any of the names provided by the SDK

Reproduction Steps

Create an event notification on an S3 bucket with a filter rule to target a specific prefix for example

var itemId = "ID"
var lambdaArn = "arn"
var prefix = "prefix"

_, err = s3Client.PutBucketNotificationConfiguration(context.Background(), &s3.PutBucketNotificationConfigurationInput{
		Bucket: &bucketName,
		NotificationConfiguration: &types.NotificationConfiguration{
			LambdaFunctionConfigurations: []types.LambdaFunctionConfiguration{
				types.LambdaFunctionConfiguration{
					Id:                &itemId,
					LambdaFunctionArn: &lambdaArn,
					Events:             []types.Event{types.EventS3ObjectCreated, types.EventS3ObjectRemoved},
					Filter: &types.NotificationConfigurationFilter{
						Key: &types.S3KeyFilter{
							FilterRules: []types.FilterRule{
								{
									Name:  types.FilterRuleNamePrefix,
									Value: &prefix,
								},
							},
						},
					},
				},
			},
		},
	})

Try to query it back again and switch case match using the prefix enum value

var prefix string
var suffix string

out, err := s3Client.GetBucketNotificationConfiguration(context.Background(), &s3.GetBucketNotificationConfigurationInput{
		Bucket: &bucketName,
})

if err != nil {
    return err
}

lfcs := out.LambdaFunctionConfigurations

for _, lfc := range lfcs.LambdaFunctionConfigurations {
	for _, rule := range lfc.Filter.Key.FilterRules {
		if rule.Value == nil {
			continue
		}

		switch rule.Name {
		case types.FilterRuleNamePrefix:
			prefix = *rule.Value
		default:
		}
	}
}

prefix will always be ""

Possible Solution

No response

Additional Information/Context

No response

SDK version used

v1.32.2

Environment details (Version of Go (go version)? OS name and version, etc.)

go 1.23.1 / ubuntu 22.04

@ge0Aja ge0Aja added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant