Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions localstack-core/localstack/services/lambda_/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -1889,6 +1889,13 @@ def validate_event_source_mapping(self, context, request):
# TODO: test whether stream ARNs are valid sources for Pipes or ESM or whether only DynamoDB table ARNs work
is_create_esm_request = context.operation.name == self.create_event_source_mapping.operation

if destination_config := request.get("DestinationConfig"):
if "OnSuccess" in destination_config:
raise InvalidParameterValueException(
"Unsupported DestinationConfig parameter for given event source mapping type.",
Type="User",
)

service = None
if "SelfManagedEventSource" in request:
service = "kafka"
Expand Down
13 changes: 13 additions & 0 deletions tests/aws/services/lambda_/test_lambda_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5337,6 +5337,19 @@ def test_event_source_mapping_exceptions(self, snapshot, aws_client):
EventSourceArn="arn:aws:sqs:us-east-1:111111111111:somequeue",
)
snapshot.match("create_unknown_params", e.value.response)

with pytest.raises(aws_client.lambda_.exceptions.InvalidParameterValueException) as e:
aws_client.lambda_.create_event_source_mapping(
FunctionName="doesnotexist",
EventSourceArn="arn:aws:sqs:us-east-1:111111111111:somequeue",
DestinationConfig={
"OnSuccess": {
"Destination": "arn:aws:sqs:us-east-1:111111111111:someotherqueue"
}
},
)
snapshot.match("destination_config_failure", e.value.response)

# TODO: add test for event source arn == failure destination
# TODO: add test for adding success destination
# TODO: add test_multiple_esm_conflict: create an event source mapping for a combination of function + target ARN that already exists
Expand Down
14 changes: 13 additions & 1 deletion tests/aws/services/lambda_/test_lambda_api.snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -5791,7 +5791,7 @@
}
},
"tests/aws/services/lambda_/test_lambda_api.py::TestLambdaEventSourceMappings::test_event_source_mapping_exceptions": {
"recorded-date": "10-04-2024, 09:19:37",
"recorded-date": "05-12-2024, 10:52:30",
"recorded-content": {
"get_unknown_uuid": {
"Error": {
Expand Down Expand Up @@ -5852,6 +5852,18 @@
"HTTPHeaders": {},
"HTTPStatusCode": 400
}
},
"destination_config_failure": {
"Error": {
"Code": "InvalidParameterValueException",
"Message": "Unsupported DestinationConfig parameter for given event source mapping type."
},
"Type": "User",
"message": "Unsupported DestinationConfig parameter for given event source mapping type.",
"ResponseMetadata": {
"HTTPHeaders": {},
"HTTPStatusCode": 400
}
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion tests/aws/services/lambda_/test_lambda_api.validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"last_validated_date": "2024-04-10T09:21:59+00:00"
},
"tests/aws/services/lambda_/test_lambda_api.py::TestLambdaEventSourceMappings::test_event_source_mapping_exceptions": {
"last_validated_date": "2024-04-10T09:19:37+00:00"
"last_validated_date": "2024-12-05T10:52:30+00:00"
},
"tests/aws/services/lambda_/test_lambda_api.py::TestLambdaEventSourceMappings::test_event_source_mapping_lifecycle": {
"last_validated_date": "2024-10-14T12:36:54+00:00"
Expand Down
Loading