# Type of request: This is a ...

[**X**] bug report
[ ] feature request

# Detailed description
When I create a secret using **secretsmanager** whose name has slashes in it (i.e `my/secret/param1`), I'm not able to retreive it later using **ssm**, because it is not able to find it.

Some further details:
- If I retreive it using `secretsmanager get-secret-value --secret-id my/secret/param1`, the secret is there
- Oddly enough, if I create a param for each "path" (i.e `my`, `my/secret`, `my/secret/param1`) I can retreive it with **ssm**
- The aforementioned hack doesn't totally work, because if I later create another secret with the same path (i.e `my/secret/param2`), I get the value of `param1` instead of the value of `param2` when retreiving with **ssm**

...

## Expected behavior
When creating a secret with **secretsmanager** and the secret name contains slashes (i.e `my/secret/param1`), I should be able to retrieve the information with **ssm** looking for the path `/aws/reference/secretsmanager/my/secret/param1` as it is specified in AWS docs (https://docs.aws.amazon.com/systems-manager/latest/userguide/integration-ps-secretsmanager.html)
...

## Actual behavior
The secret is successfully created using **secretsmanager**, but it is not found when retreiving it from **ssm**.
...

# Steps to reproduce
**1)** Create the secret
```
aws --endpoint-url http://localstack:4566 secretsmanager create-secret --name my/secret/param1 --secret-string '{"data": "here"}'
```
Result:
```
{
    "ARN": "arn:aws:secretsmanager:us-east-1:1234567890:secret:my/secret/param1-TwmCI",
    "Name": "my/secret/param1",
    "VersionId": "c62f31d3-6f9f-46e2-9570-09f14cb51b37"
}
```
**2)** Check secret is there
```
aws --endpoint-url http://localstack:4566 secretsmanager get-secret-value --secret-id my/secret/param1
```
Result:
```
{
    "ARN": "arn:aws:secretsmanager:us-east-1:1234567890:secret:my/secret/param1-TwmCI",
    "Name": "my/secret/param1",
    "VersionId": "c62f31d3-6f9f-46e2-9570-09f14cb51b37",
    "SecretString": "{\"data\": \"here\"}",
    "VersionStages": [
        "AWSCURRENT"
    ],
    "CreatedDate": "2020-11-11T23:45:15+00:00"
}
```
**3)** Retrieve from ssm
```
aws --endpoint-url http://localstack:4566 ssm get-parameter \
    --name /aws/reference/secretsmanager/my/secret/param1 \
    --with-decryption
```
Result:
```
An error occurred (500) when calling the GetParameter operation (reached max retries: 2):
```
Localstack log:
```
2020-11-11T23:48:15:WARNING:bootstrap.py: Thread run method <function AdaptiveThreadPool.submit.<locals>._run at 0x7f5c4456c790>(None) failed: An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets Manager can't find the specified secret. Traceback (most recent call last):
  File "/opt/code/localstack/localstack/utils/bootstrap.py", line 578, in run
    result = self.func(self.params)
  File "/opt/code/localstack/localstack/utils/async_utils.py", line 28, in _run
    return fn(*args, **kwargs)
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 571, in handler
    response = modify_and_forward(method=method, path=path_with_params, data_bytes=data, headers=headers,
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 341, in modify_and_forward
    listener_result = listener.forward_request(method=method,
  File "/opt/code/localstack/localstack/services/edge.py", line 81, in forward_request
    return do_forward_request(api, port, method, path, data, headers)
  File "/opt/code/localstack/localstack/services/edge.py", line 86, in do_forward_request
    result = do_forward_request_inmem(api, port, method, path, data, headers)
  File "/opt/code/localstack/localstack/services/edge.py", line 106, in do_forward_request_inmem
    response = modify_and_forward(method=method, path=path, data_bytes=data, headers=headers,
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 341, in modify_and_forward
    listener_result = listener.forward_request(method=method,
  File "/opt/code/localstack/localstack/services/ssm/ssm_listener.py", line 62, in forward_request
    return get_secrets_information(name, resource_name)
  File "/opt/code/localstack/localstack/services/ssm/ssm_listener.py", line 22, in get_secrets_information
    secret_info = client.get_secret_value(SecretId=resource_name)
  File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 676, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets Manager can't find the specified secret.

2020-11-11T23:48:15:WARNING:localstack.utils.server.http2_server: Error in proxy handler for request POST http://localstack:4566/: An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets Manager can't find the specified secret. Traceback (most recent call last):
  File "/opt/code/localstack/localstack/utils/server/http2_server.py", line 107, in index
    raise result
  File "/opt/code/localstack/localstack/utils/bootstrap.py", line 578, in run
    result = self.func(self.params)
  File "/opt/code/localstack/localstack/utils/async_utils.py", line 28, in _run
    return fn(*args, **kwargs)
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 571, in handler
    response = modify_and_forward(method=method, path=path_with_params, data_bytes=data, headers=headers,
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 341, in modify_and_forward
    listener_result = listener.forward_request(method=method,
  File "/opt/code/localstack/localstack/services/edge.py", line 81, in forward_request
    return do_forward_request(api, port, method, path, data, headers)
  File "/opt/code/localstack/localstack/services/edge.py", line 86, in do_forward_request
    result = do_forward_request_inmem(api, port, method, path, data, headers)
  File "/opt/code/localstack/localstack/services/edge.py", line 106, in do_forward_request_inmem
    response = modify_and_forward(method=method, path=path, data_bytes=data, headers=headers,
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 341, in modify_and_forward
    listener_result = listener.forward_request(method=method,
  File "/opt/code/localstack/localstack/services/ssm/ssm_listener.py", line 62, in forward_request
    return get_secrets_information(name, resource_name)
  File "/opt/code/localstack/localstack/services/ssm/ssm_listener.py", line 22, in get_secrets_information
    secret_info = client.get_secret_value(SecretId=resource_name)
  File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 676, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets Manager can't find the specified secret.

2020-11-11T23:48:16:WARNING:bootstrap.py: Thread run method <function AdaptiveThreadPool.submit.<locals>._run at 0x7f5c4456c8b0>(None) failed: An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets Manager can't find the specified secret. Traceback (most recent call last):
  File "/opt/code/localstack/localstack/utils/bootstrap.py", line 578, in run
    result = self.func(self.params)
  File "/opt/code/localstack/localstack/utils/async_utils.py", line 28, in _run
    return fn(*args, **kwargs)
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 571, in handler
    response = modify_and_forward(method=method, path=path_with_params, data_bytes=data, headers=headers,
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 341, in modify_and_forward
    listener_result = listener.forward_request(method=method,
  File "/opt/code/localstack/localstack/services/edge.py", line 81, in forward_request
    return do_forward_request(api, port, method, path, data, headers)
  File "/opt/code/localstack/localstack/services/edge.py", line 86, in do_forward_request
    result = do_forward_request_inmem(api, port, method, path, data, headers)
  File "/opt/code/localstack/localstack/services/edge.py", line 106, in do_forward_request_inmem
    response = modify_and_forward(method=method, path=path, data_bytes=data, headers=headers,
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 341, in modify_and_forward
    listener_result = listener.forward_request(method=method,
  File "/opt/code/localstack/localstack/services/ssm/ssm_listener.py", line 62, in forward_request
    return get_secrets_information(name, resource_name)
  File "/opt/code/localstack/localstack/services/ssm/ssm_listener.py", line 22, in get_secrets_information
    secret_info = client.get_secret_value(SecretId=resource_name)
  File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 676, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets Manager can't find the specified secret.

2020-11-11T23:48:16:WARNING:localstack.utils.server.http2_server: Error in proxy handler for request POST http://localstack:4566/: An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets Manager can't find the specified secret. Traceback (most recent call last):
  File "/opt/code/localstack/localstack/utils/server/http2_server.py", line 107, in index
    raise result
  File "/opt/code/localstack/localstack/utils/bootstrap.py", line 578, in run
    result = self.func(self.params)
  File "/opt/code/localstack/localstack/utils/async_utils.py", line 28, in _run
    return fn(*args, **kwargs)
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 571, in handler
    response = modify_and_forward(method=method, path=path_with_params, data_bytes=data, headers=headers,
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 341, in modify_and_forward
    listener_result = listener.forward_request(method=method,
  File "/opt/code/localstack/localstack/services/edge.py", line 81, in forward_request
    return do_forward_request(api, port, method, path, data, headers)
  File "/opt/code/localstack/localstack/services/edge.py", line 86, in do_forward_request
    result = do_forward_request_inmem(api, port, method, path, data, headers)
  File "/opt/code/localstack/localstack/services/edge.py", line 106, in do_forward_request_inmem
    response = modify_and_forward(method=method, path=path, data_bytes=data, headers=headers,
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 341, in modify_and_forward
    listener_result = listener.forward_request(method=method,
  File "/opt/code/localstack/localstack/services/ssm/ssm_listener.py", line 62, in forward_request
    return get_secrets_information(name, resource_name)
  File "/opt/code/localstack/localstack/services/ssm/ssm_listener.py", line 22, in get_secrets_information
    secret_info = client.get_secret_value(SecretId=resource_name)
  File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 676, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets Manager can't find the specified secret.

2020-11-11T23:48:18:WARNING:bootstrap.py: Thread run method <function AdaptiveThreadPool.submit.<locals>._run at 0x7f5c42ac1c10>(None) failed: An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets Manager can't find the specified secret. Traceback (most recent call last):
  File "/opt/code/localstack/localstack/utils/bootstrap.py", line 578, in run
    result = self.func(self.params)
  File "/opt/code/localstack/localstack/utils/async_utils.py", line 28, in _run
    return fn(*args, **kwargs)
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 571, in handler
    response = modify_and_forward(method=method, path=path_with_params, data_bytes=data, headers=headers,
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 341, in modify_and_forward
    listener_result = listener.forward_request(method=method,
  File "/opt/code/localstack/localstack/services/edge.py", line 81, in forward_request
    return do_forward_request(api, port, method, path, data, headers)
  File "/opt/code/localstack/localstack/services/edge.py", line 86, in do_forward_request
    result = do_forward_request_inmem(api, port, method, path, data, headers)
  File "/opt/code/localstack/localstack/services/edge.py", line 106, in do_forward_request_inmem
    response = modify_and_forward(method=method, path=path, data_bytes=data, headers=headers,
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 341, in modify_and_forward
    listener_result = listener.forward_request(method=method,
  File "/opt/code/localstack/localstack/services/ssm/ssm_listener.py", line 62, in forward_request
    return get_secrets_information(name, resource_name)
  File "/opt/code/localstack/localstack/services/ssm/ssm_listener.py", line 22, in get_secrets_information
    secret_info = client.get_secret_value(SecretId=resource_name)
  File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 676, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets Manager can't find the specified secret.

2020-11-11T23:48:18:WARNING:localstack.utils.server.http2_server: Error in proxy handler for request POST http://localstack:4566/: An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets Manager can't find the specified secret. Traceback (most recent call last):
  File "/opt/code/localstack/localstack/utils/server/http2_server.py", line 107, in index
    raise result
  File "/opt/code/localstack/localstack/utils/bootstrap.py", line 578, in run
    result = self.func(self.params)
  File "/opt/code/localstack/localstack/utils/async_utils.py", line 28, in _run
    return fn(*args, **kwargs)
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 571, in handler
    response = modify_and_forward(method=method, path=path_with_params, data_bytes=data, headers=headers,
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 341, in modify_and_forward
    listener_result = listener.forward_request(method=method,
  File "/opt/code/localstack/localstack/services/edge.py", line 81, in forward_request
    return do_forward_request(api, port, method, path, data, headers)
  File "/opt/code/localstack/localstack/services/edge.py", line 86, in do_forward_request
    result = do_forward_request_inmem(api, port, method, path, data, headers)
  File "/opt/code/localstack/localstack/services/edge.py", line 106, in do_forward_request_inmem
    response = modify_and_forward(method=method, path=path, data_bytes=data, headers=headers,
  File "/opt/code/localstack/localstack/services/generic_proxy.py", line 341, in modify_and_forward
    listener_result = listener.forward_request(method=method,
  File "/opt/code/localstack/localstack/services/ssm/ssm_listener.py", line 62, in forward_request
    return get_secrets_information(name, resource_name)
  File "/opt/code/localstack/localstack/services/ssm/ssm_listener.py", line 22, in get_secrets_information
    secret_info = client.get_secret_value(SecretId=resource_name)
  File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 676, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets Manager can't find the specified secret.
```
BONUS 1
**4)** Create "path secrets" and retrieve from ssm succesfully
```
aws --endpoint-url http://localstack:4566 secretsmanager create-secret --name my --secret-string '{"data": "here"}'
aws --endpoint-url http://localstack:4566 secretsmanager create-secret --name my/secret --secret-string '{"data": "here"}'
aws --endpoint-url http://localstack:4566 ssm get-parameter \
    --name /aws/reference/secretsmanager/my/secret/param1 \
    --with-decryption
```
Result:
```
{
    "Parameter": {
        "Name": "/aws/reference/secretsmanager/my/secret/param1",
        "Type": "SecureString",
        "Value": "{\"data\": \"here\"}",
        "SourceResult": {
            "ARN": "arn:aws:secretsmanager:us-east-1:1234567890:secret:my-ERxpI",
            "Name": "my",
            "VersionId": "f1b530dd-9b94-4d1d-9dd0-881626fd6f9f",
            "SecretString": "{\"data\": \"here\"}",
            "VersionStages": [
                "AWSCURRENT"
            ],
            "CreatedDate": "2020-11-11T23:54:40.000Z"
        },
        "LastModifiedDate": "2020-11-11T23:54:40+00:00"
    }
}
```
BONUS 2
**5)** Create a new secret with same path but different name (`my/secret/param2`), and when retrieving, I get param1 value instead of param2
```
aws --endpoint-url http://localstack:4566 secretsmanager create-secret --name my/secret/param2 --secret-string '{"DIFERENT_DATA": "FROM_PARAM_2"}'
aws --endpoint-url http://localstack:4566 ssm get-parameter \
    --name /aws/reference/secretsmanager/my/secret/param2 \
    --with-decryption
```
Result:
```
{
    "Parameter": {
        "Name": "/aws/reference/secretsmanager/my/secret/param2",    <------ PATH FOR param2
        "Type": "SecureString",
        "Value": "{\"data\": \"here\"}",     <----- VALUE FROM param1
        "SourceResult": {
            "ARN": "arn:aws:secretsmanager:us-east-1:1234567890:secret:my-ERxpI",
            "Name": "my",
            "VersionId": "f1b530dd-9b94-4d1d-9dd0-881626fd6f9f",
            "SecretString": "{\"data\": \"here\"}",
            "VersionStages": [
                "AWSCURRENT"
            ],
            "CreatedDate": "2020-11-11T23:54:40.000Z"
        },
        "LastModifiedDate": "2020-11-11T23:54:40+00:00"
    }
}
```
## Command used to start LocalStack
Started with docker-compose with the following service settings:
```
version: "3.7"
services:
  localstack:
    image: localstack/localstack:0.12.2
    environment:
      SERVICES: ssm,sts,sqs,sns,dynamodb,cloudwatch,s3,secretsmanager
      HOSTNAME_EXTERNAL: localstack
```
...

## Client code (AWS SDK code snippet, or sequence of "awslocal" commands)
```
aws --endpoint-url http://localstack:4566 secretsmanager create-secret --name my/secret/param1 --secret-string '{"data": "here"}'
aws --endpoint-url http://localstack:4566 ssm get-parameter \
    --name /aws/reference/secretsmanager/my/secret/param1 \
    --with-decryption
```
...

import json
from requests.models import Request
from localstack.utils.common import to_str
from localstack.utils.aws import aws_stack
from localstack.utils.persistence import PersistingProxyListener
ACTION_PUT_PARAM = 'AmazonSSM.PutParameter'
ACTION_GET_PARAM = 'AmazonSSM.GetParameter'
ACTION_GET_PARAMS = 'AmazonSSM.GetParameters'
def normalize_name(param_name):
    param_name = param_name.strip('/')
    param_name = param_name.replace('//', '/')
    if '/' in param_name:
        param_name = '/%s' % param_name
    return param_name
def get_secrets_information(name, resource_name):
    client = aws_stack.connect_to_service('secretsmanager')
    secret_info = client.get_secret_value(SecretId=resource_name)
    del secret_info['ResponseMetadata']
    result = {'Parameter': {'SourceResult': secret_info, 'Name': name, 'Value':
              secret_info.get('SecretString'), 'Type': 'SecureString',
                            'LastModifiedDate': secret_info.get('CreatedDate')}}
    return result
class ProxyListenerSSM(PersistingProxyListener):