Skip to content

How do I resolve the error "Configuration is ambiguously defined" when I tried to create an Amazon S3 event notification to trigger my Lambda function?

4 minute read
1

I tried to create an Amazon Simple Storage Service (Amazon S3) bucket event notification to trigger my AWS Lambda function and received an error.

Short description

The "Configuration is ambiguously defined error" occurs when a notification's event information and its prefix or suffix overlap with an S3 bucket's notification configuration.

To resolve this issue, take one of the following actions:

  • Remove the overlapping event, and create a new one.
  • Create an S3 event notification for multiple overlapping events with overlapping prefixes or suffixes.
  • Redesign your architecture.

Note: Amazon S3 event notification configurations allow overlapping events with non-overlapping prefixes or suffixes. The configurations also allow non-overlapping events with overlapping prefixes or suffixes.

For more information and examples, see Configuring event notifications using object key name filtering.

Resolution

Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.

Remove the overlapping event and create a new one

To delete overlapping event notifications, use the Amazon S3 console or AWS CLI.

Note: When you delete a Lambda function trigger, the associated S3 event notification isn't automatically deleted. You must also delete the notification in Amazon S3 before you create a new trigger without suffix constraints.

Amazon S3 console

Complete the following steps:

  1. Open the Amazon S3 console, and then select your bucket.
  2. Choose the Properties tab.
  3. In Event notifications, choose the event notification that overlaps with the new one that you tried to create.
  4. Choose Delete.
  5. Choose Create event notification.
  6. On the Lambda function dropdown list, select your function, and then choose Save changes.

AWS CLI

Use the AWS CLI to update the notification configuration JSON file on your S3 bucket. To get a list of all event notifications on your S3 bucket, run the get-bucket-notification-configuration AWS CLI command. To remove all S3 event notifications, run the put-bucket-notification-configuration AWS CLI command:

aws s3api put-bucket-notification-configuration --bucket=your-bucket-name --notification-configuration="{}"

Note: Replace your-bucket-name with your bucket name.

After you remove the overlapping event notification, you can run the put-bucket-notification-configuration AWS CLI command to add new notifications.

Create an S3 event notification for multiple overlapping events with overlapping prefixes or suffixes

Complete the following steps:

  1. Open the Amazon S3 console, and then select your bucket.
  2. Choose the Properties tab.
  3. In Event notifications, choose Create event notification.
  4. In Event name, enter a name for your event, for example your-event-name.
  5. For Prefix, enter a prefix, for example images/.
  6. For Suffix, enter a suffix, for example .jpg.
  7. For Event types, choose All objects create events.
  8. On the Lambda function dropdown list, choose your Lambda function.
  9. Choose Save changes.

Redesign your architecture

If you can't reconfigure your S3 event notification to avoid the overlap, then redesign your architecture to work around it.

For example, configure an event notification to trigger a Lambda function that triggers other Lambda functions based on the S3 event. Or, configure an event notification to publish events to an Amazon Simple Notification Service (Amazon SNS) topic or Amazon Simple Queue Service (Amazon SQS) queue.

Note: Make sure that the topic or queue pushes events to multiple subscribed Lambda functions. Design the subscribed functions with logic to decide whether to process the events that the functions receive. For more information, see Fanout S3 event notifications to multiple endpoints.

You can also turn on object-level logging of Amazon S3 actions to AWS CloudTrail. Then, use an Amazon EventBridge rule to trigger your Lambda function based on the Amazon S3 event pattern. For more information, see Tutorial: Log Amazon S3 object-level operations using EventBridge.

For more complex architecture and processes, use an AWS Step Functions state machine to design and manage your workflow. For more information, see AWS Step Functions use cases and Tutorials for learning Step Functions.

Related information

Why do I get the error "Unable to validate the following destination configurations" when I use Amazon S3 Event Notifications?

How do I troubleshoot issues when my Amazon S3 Event Notifications don't invoke my Lambda function?

Process Amazon S3 event notifications with Lambda

Tutorial: Using an Amazon S3 trigger to invoke a Lambda function

AWS OFFICIALUpdated 5 months ago
2 Comments

Thank you for this. This was really helpful.

replied 2 years ago

This can also be related to existing notification configuration destinations being invalid, rather than overlapping prefixes or suffixes. I found that existing event destinations had been removed, though the notification configuration pointing to them was still present, and this prevented any new configurations being added, even with a random prefix, suffix and previously unused event type.

The solution obviously was to validate any existing notification configuration destinations and remove the ones that were no longer valid.

replied 2 years ago