Repository: getmoto/moto

Issue:
mock_events: unexpected `put_events()` behaviour when event `EventBusName` is an ARN
**How to reproduce the issue**:

```py
from moto import mock_events
import boto3


@mock_events
def test_fails_with_arn():
    base_event = {
        "Source": "source",
        "DetailType": "type",
        "Detail": '{"foo": "bar"}'
    }
    mock_client = boto3.client("events", region_name="us-east-1")
    bus_arn = mock_client.create_event_bus(Name="mock_bus")["EventBusArn"]
    mock_client.create_archive(ArchiveName="mock_archive", EventSourceArn=bus_arn)
    response = mock_client.put_events(Entries=[{**base_event, "EventBusName": "mock_bus"}])
    assert response["FailedEntryCount"] == 0
    assert mock_client.describe_archive(ArchiveName="mock_archive")["EventCount"] == 1
    response = mock_client.put_events(Entries=[{**base_event, "EventBusName": bus_arn}])
    assert response["FailedEntryCount"] == 0
    assert mock_client.describe_archive(ArchiveName="mock_archive")["EventCount"] == 2
```

**Expected behaviour**:
The final assertion should pass. `put_events()` `EventBusName` [can be either a name or an ARN](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/events.html#EventBridge.Client.put_events) therefore the second event should be routed to the archive

**Actual behaviour**:
```
============================= test session starts ==============================
platform darwin -- Python 3.8.2, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 -- /Users/tom.noble/PycharmProjects/mototest/venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/tom.noble/PycharmProjects/mototest
collecting ... collected 1 item

test.py::test_fails_with_arn FAILED                                      [100%]
test.py:4 (test_fails_with_arn)
1 != 2

Expected :2
Actual   :1
<Click to see difference>

@mock_events
    def test_fails_with_arn():
        base_event = {
            "Source": "source",
            "DetailType": "type",
            "Detail": '{"foo": "bar"}'
        }
        mock_client = boto3.client("events", region_name="us-east-1")
        bus_arn = mock_client.create_event_bus(Name="mock_bus")["EventBusArn"]
        mock_client.create_archive(ArchiveName="mock_archive", EventSourceArn=bus_arn)
        response = mock_client.put_events(Entries=[{**base_event, "EventBusName": "mock_bus"}])
        assert response["FailedEntryCount"] == 0
        assert mock_client.describe_archive(ArchiveName="mock_archive")["EventCount"] == 1
        response = mock_client.put_events(Entries=[{**base_event, "EventBusName": bus_arn}])
        assert response["FailedEntryCount"] == 0
>       assert mock_client.describe_archive(ArchiveName="mock_archive")["EventCount"] == 2
E       assert 1 == 2

test.py:20: AssertionError
```

**Moto version / Installation**:
2.0.2 installed via pip

**Potential solution**:

When an `Archive` is created, a corresponding `Rule` is created and attached to the `EventBus` using the simple name of the bus

```py
    class EventsBackend(BaseBackend):
       ...
       def create_archive(self, name, source_arn, description, event_pattern, retention):
          ...
          rule = self.put_rule(
             "Events-Archive-{}".format(name),
             **{
                "EventPattern": json.dumps(rule_event_pattern),
                "EventBusName": event_bus.name,
             }
          )
          ...
       ...
```

The `Rule` class checks the bus name in an event against its own bus name when deciding whether to send an event to its targets, however, this ignores cases where the an event's bus name is an ARN rather than a simple name.

```py
    class Rule(CloudFormationModel):
       ...
       def send_to_targets(self, event_bus_name, event):
          if event_bus_name != self.event_bus_name:
             return
          ...
        ...
```

I believe the following change will fix the issue. I can have a PR open soon but am slightly unfamiliar with the contributing process for moto. Any help would be appreciated!

```py
    class Rule(CloudFormationModel):
       ...
       def send_to_targets(self, event_bus_name, event):
          event_bus_arn_pattern = r"^arn:aws:events:[a-zA-Z0-9-]+:\d{12}:event-bus/"
          if re.match(event_bus_arn_pattern, event_bus_name):
             event_bus_name = event_bus_name.split("/")[-1]
          if event_bus_name != self.event_bus_name:
             return
          ...
       ...
```


Discussion:
Hi @TSNoble, thanks for opening this and doing the investigation! That solution looks correct - the arn-to-name conversion is already used in other parts of `events/models.py`, so it makes sense to reuse it here.
There's no need to check against the regex though - just always call `event_bus_name = event_bus_name.split("/")[-1]`

There is a [document](https://github.com/spulec/moto/blob/master/CONTRIBUTING.md) with some guidelines on how to contribute.

It's not mentioned in the docs, but the overall flow for opening a PR is the same for most OS projects:
 - Fork the project
 - Create a new branch
 - Make the change
 - Add a test to verify the change behaves as it should (in this case, in tests/test_events/test_events.py)
 - Push the branch and create a PR
 
Let me know if you need any help.

Resolving patch:
diff --git a/moto/events/models.py b/moto/events/models.py
--- a/moto/events/models.py
+++ b/moto/events/models.py
@@ -82,6 +82,7 @@ def remove_targets(self, ids):
                 self.targets.pop(index)
 
     def send_to_targets(self, event_bus_name, event):
+        event_bus_name = event_bus_name.split("/")[-1]
         if event_bus_name != self.event_bus_name:
             return
 


Test patch:
diff --git a/tests/test_events/test_events.py b/tests/test_events/test_events.py
--- a/tests/test_events/test_events.py
+++ b/tests/test_events/test_events.py
@@ -1318,6 +1318,34 @@ def test_archive_actual_events():
     response["SizeBytes"].should.be.greater_than(0)
 
 
+@mock_events
+def test_archive_event_with_bus_arn():
+    # given
+    client = boto3.client("events", "eu-central-1")
+    event_bus_arn = "arn:aws:events:eu-central-1:{}:event-bus/default".format(
+        ACCOUNT_ID
+    )
+    archive_name = "mock_archive"
+    event_with_bus_arn = {
+        "Source": "source",
+        "DetailType": "type",
+        "Detail": '{ "key1": "value1" }',
+        "EventBusName": event_bus_arn,
+    }
+    client.create_archive(ArchiveName=archive_name, EventSourceArn=event_bus_arn)
+
+    # when
+    response = client.put_events(Entries=[event_with_bus_arn])
+
+    # then
+    response["FailedEntryCount"].should.equal(0)
+    response["Entries"].should.have.length_of(1)
+
+    response = client.describe_archive(ArchiveName=archive_name)
+    response["EventCount"].should.equal(1)
+    response["SizeBytes"].should.be.greater_than(0)
+
+
 @mock_events
 def test_start_replay():
     # given