### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

Lambda refs get lost

### Expected Behavior

Lambda refs work in state machines

### How are you starting LocalStack?

With a docker-compose file

### Steps To Reproduce

#### How are you starting localstack (e.g., `bin/localstack` command, arguments, or `docker-compose.yml`)

    docker run localstack/localstack

#### Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

    awslocal s3 mb s3://mybucket


### Environment

```markdown
- OS: 
- LocalStack:
```


### Anything else?

This is based on a conversation I had with @dominikschubert 
import time
from typing import Callable
from typing_extensions import Literal
def wait_until(
    fn: Callable[[], bool],
    wait: float = 1.0,
    max_retries: int = 10,
    strategy: Literal["exponential", "static", "linear"] = "exponential",
    _retries: int = 0,
    _max_wait: float = 240,
) -> None:
    """waits until a given condition is true, rechecking it periodically"""
    if max_retries < _retries:
        return
    completed = fn()
    if not completed:
        if wait > _max_wait:
            return
        time.sleep(wait)
        next_wait = wait  
        if strategy == "linear":
            next_wait = (wait / _retries) * (_retries + 1)
        elif strategy == "exponential":
            next_wait = wait ** 2
        wait_until(fn, next_wait, max_retries, strategy, _retries + 1, _max_wait)