Repository: localstack/localstack

Issue:
bug: ssm putParameter require event services
### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

With the container configure with only ssm services (SERVICES=ssm), if I call ssm putParameter it returns an exception.

`software.amazon.awssdk.services.ssm.model.ParameterAlreadyExistsException: The parameter already exists. To overwrite this value, set the overwrite option in the request to true. (Service: Ssm, Status Code: 400, Request ID: 292e5d4e-2e7d-4b3b-a669-2cfd3974912d)`

This exception suppress the root cause 

```
software.amazon.awssdk.core.exception.SdkClientException: Request attempt 1 failure: exception while calling ssm.PutParameter: Traceback (most recent call last):
  File "/opt/code/localstack/localstack/aws/chain.py", line 90, in handle
    handler(self, self.context, response)
  File "/opt/code/localstack/localstack/aws/handlers/service.py", line 123, in __call__
    handler(chain, context, response)
  File "/opt/code/localstack/localstack/aws/handlers/service.py", line 93, in __call__
    skeleton_response = self.skeleton.invoke(context)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/code/localstack/localstack/aws/skeleton.py", line 154, in invoke
    return self.dispatch_request(context, instance)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/code/localstack/localstack/aws/skeleton.py", line 166, in dispatch_request
    result = handler(context, instance) or {}
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/code/localstack/localstack/aws/forwarder.py", line 135, in _call
    return handler(context, req)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/code/localstack/localstack/aws/skeleton.py", line 118, in __call__
    return self.fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/code/localstack/localstack/services/ssm/provider.py", line 145, in put_parameter
    SsmProvider._notify_event_subscribers(context.account_id, context.region, nname, "Create")
  File "/opt/code/localstack/localstack/services/ssm/provider.py", line 427, in _notify_event_subscribers
    events.put_events(Entries=[event])
  File "/opt/code/localstack/.venv/lib/python3.11/site-packages/botocore/client.py", line 535, in _api_call
    return self._make_api_call(operation_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/code/localstack/.venv/lib/python3.11/site-packages/botocore/client.py", line 983, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InternalFailure) when calling the PutEvents operation: Service 'events' is not enabled. Please check your 'SERVICES' configuration variable.
 (Service: Ssm, Status Code: 500, Request ID: d8ce8b14-02e8-463d-9504-fb9ef6ac396c)
```

Adding "events", to the list of service does fix the issue.

### Expected Behavior

No exception and no need to add "events".

### How are you starting LocalStack?

Custom (please describe below)

### Steps To Reproduce

#### How are you starting localstack (e.g., `bin/localstack` command, arguments, or `docker-compose.yml`)

With testcontainer `new LocalStackContainer("3.0.0").withServices("ssm")`

#### Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

```
SsmClient ssmClient;
ssmClient.putParameter(r -> r.name(SYNC_PARAM).type(ParameterType.SECURE_STRING).value(TEXT));
```


### Environment

```markdown
- OS: WSL Ubuntu 20.04
- LocalStack: 3.0.0
```


### Anything else?

```
 File "/opt/code/localstack/localstack/services/ssm/provider.py", line 145, in put_parameter
    SsmProvider._notify_event_subscribers(context.account_id, context.region, nname, "Create")
  File "/opt/code/localstack/localstack/services/ssm/provider.py", line 427, in _notify_event_subscribers
    events.put_events(Entries=[event])
```

It seems that ssm provider require events under the hood.


Discussion:
Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our [Slack Community](https://localstack.cloud/contact/) for real-time help and drop a message to LocalStack Pro Support if you are a Pro user! If you are willing to contribute towards fixing this issue, please have a look at our [contributing guidelines](https://github.com/localstack/.github/blob/main/CONTRIBUTING.md) and our [contributing guide](https://docs.localstack.cloud/contributing/).

Resolving patch:
diff --git a/localstack/services/ssm/provider.py b/localstack/services/ssm/provider.py
--- a/localstack/services/ssm/provider.py
+++ b/localstack/services/ssm/provider.py
@@ -1,5 +1,6 @@
 import copy
 import json
+import logging
 import time
 from abc import ABC
 from typing import Dict, Optional
@@ -79,10 +80,13 @@
 )
 from localstack.aws.connect import connect_to
 from localstack.services.moto import call_moto, call_moto_with_request
+from localstack.utils.bootstrap import is_api_enabled
 from localstack.utils.collections import remove_attributes
 from localstack.utils.objects import keys_to_lower
 from localstack.utils.patch import patch
 
+LOG = logging.getLogger(__name__)
+
 PARAM_PREFIX_SECRETSMANAGER = "/aws/reference/secretsmanager"
 
 
@@ -416,6 +420,12 @@ def _get_params_and_secrets(
     def _notify_event_subscribers(
         account_id: str, region_name: str, name: ParameterName, operation: str
     ):
+        if not is_api_enabled("events"):
+            LOG.warning(
+                "Service 'events' is not enabled: skip emitting SSM event. "
+                "Please check your 'SERVICES' configuration variable."
+            )
+            return
         """Publish an EventBridge event to notify subscribers of changes."""
         events = connect_to(aws_access_key_id=account_id, region_name=region_name).events
         detail = {"name": name, "operation": operation}


Test patch: