Repository: localstack/localstack

Issue:
Dashboard does not work 
<!-- Love localstack? Please consider supporting our collective:
👉  https://opencollective.com/localstack/donate -->
Run localstack through docker. 
```bash
sudo docker run -it -p 4567-4578:4567-4578 -p 8080:8080 localstack/localstack
```
I have put some objects into s3. 
```bash
$ aws s3 ls foo.bucket
2019-06-22 15:15:02         11 bar.key
```
But the dashboard is still empty.  The dashboard keeps empty even if I add lambda functions and more objects.


Discussion:
Thanks for reporting @FighterNan . I wasn't able to reproduce this issue. Are you sure you're creating the S3 bucket against LocalStack, and not against the real AWS account?

Note that the dashboard is currently configured to display only resources in your local instance, but it does *not* by default show the resources from your AWS account (in order to do that, it would have to be configured with your access credentials, etc)
Thanks for your reply @whummer . 
I'm quite sure I'm creating buckets, objects, and functions in the LocalStack since I have specified the endpoint. I use `boto3` to create a function. 
```python
lambda_client = boto3.client(service_name='lambda',
                              use_ssl=False,
                              aws_access_key_id='fake',
                              aws_secret_access_key='fake',
                              endpoint_url='http://x.x.x.x:4574'
                             )
lambda_client.create_function(FunctionName="foo.function",
                                  Runtime='python2.7',
                                  Role='foo.role',
                                  Handler='lambda.handler',
                                  Code={'ZipFile': zipped_code}
                                   )
 ```
Then I can verify the function has been created using `awscmd`.
```bash
$ aws lambda list-functions  --endpoint-url http://x.x.x.x:4574
{
    "Functions": [
        {
            "FunctionName": "foo.function",
            "FunctionArn": "arn:aws:lambda:us-east-1:000000000000:function:foo.function",
            "Runtime": "python2.7",
            "Role": "foo.role",
            "Handler": "lambda.handler",
            "CodeSize": 238,
            "Description": "",
            "Timeout": 3,
            "LastModified": "2019-06-23T00:12:44.453+0000",
            "CodeSha256": "j9nL122uJlgeEOzVXEtnv/WglSFwIoqRYOpCWLHzWKs=",
            "Version": "$LATEST",
            "TracingConfig": {
                "Mode": "PassThrough"
            },
            "RevisionId": "f168efbe-a506-414a-a460-4dc353deb5df"
        }
    ]
}
```
But the web ui is still empty. As far as my understanding, if I check `Local AWS Endpoints` and use the Name Filter `.*`, there should be some instances in the web UI.
I Have i same problem. web ui is still empty:
Log:
 aws --endpoint-url="http://21ad0c748654:4578" es list-domain-names [Errno 1] Operation not permitted: '/tmp/cache.603fe2759e3fd86a1a62d33a4bf3652a.json'
Adding this to my `docker-compose.yaml` fix the error log,
```
volumes:
      - ...
      - "${TMPDIR:-/tmp/localstack}:/tmp"
      -  ...
```

Web UI is empty till resource is created, eg.
```
aws --endpoint-url="http://localhost:4578" --region us-east-1 s3api create-bucket --bucket my-bucket
```
I am hunting this down myself (noob here).  I suspect it is due to `/tmp/cache.*.json` being owned by root yet `web` process is running as the `localstack` user.  I am not fully sure who launches what, but getting close.

Started via Docker:

```
$ TMPDIR=/private$TMPDIR localstack start --docker
Starting local dev environment. CTRL-C to quit.
docker run -it -e LOCALSTACK_HOSTNAME="localhost" -e LOCALSTACK_HOSTNAME="localhost" --rm --privileged --name localstack_main -p 8080:8080 -p 443:443 -p 4567-4597:4567-4597 -v "/tmp/localstack:/tmp/localstack" -v "/var/run/docker.sock:/var/run/docker.sock" -e DOCKER_HOST="unix:///var/run/docker.sock" -e HOST_TMP_FOLDER="/tmp/localstack" "localstack/localstack" 
...
ready
```

After visiting dashboard:

```
2019-07-16T01:00:17:WARNING:localstack.dashboard.infra: Error running command: { test `which aws` || . .venv/bin/activate; }; aws --endpoint-url="http://localhost:4578" es list-domain-names [Errno 1] Operation not permitted: '/tmp/cache.7c4ae8e0f503846b210fa13439b2d3bd.json'
2019-07-16T01:00:18:WARNING:localstack.dashboard.infra: Error running command: { test `which aws` || . .venv/bin/activate; }; aws --endpoint-url="http://localhost:4569" dynamodb list-tables [Errno 1] Operation not permitted: '/tmp/cache.7c4ae8e0f503846b210fa13439b2d3bd.json'
2019-07-16T01:00:18:WARNING:localstack.dashboard.infra: Error running command: { test `which aws` || . .venv/bin/activate; }; aws --endpoint-url="http://localhost:4572" s3api list-buckets [Errno 1] Operation not permitted: '/tmp/cache.7c4ae8e0f503846b210fa13439b2d3bd.json'
2019-07-16T01:00:19:WARNING:localstack.dashboard.infra: Error running command: { test `which aws` || . .venv/bin/activate; }; aws --endpoint-url="http://localhost:4568" kinesis list-streams [Errno 1] Operation not permitted: '/tmp/cache.7c4ae8e0f503846b210fa13439b2d3bd.json'
2019-07-16T01:00:20:WARNING:localstack.dashboard.infra: Error running command: { test `which aws` || . .venv/bin/activate; }; aws --endpoint-url="http://localhost:4573" firehose list-delivery-streams [Errno 1] Operation not permitted: '/tmp/cache.7c4ae8e0f503846b210fa13439b2d3bd.json'
2019-07-16T01:00:21:WARNING:localstack.dashboard.infra: Error running command: { test `which aws` || . .venv/bin/activate; }; aws --endpoint-url="http://localhost:4574" lambda list-functions [Errno 1] Operation not permitted: '/tmp/cache.7c4ae8e0f503846b210fa13439b2d3bd.json'
2019-07-16T01:00:21:WARNING:localstack.dashboard.infra: Error running command: { test `which aws` || . .venv/bin/activate; }; aws --endpoint-url="http://localhost:4576" sqs list-queues [Errno 1] Operation not permitted: '/tmp/cache.7c4ae8e0f503846b210fa13439b2d3bd.json'
```

Debugging via Docker:

```
$ docker container exec --user=localstack -it -e LOCALSTACK_HOSTNAME="localhost" -e LOCALSTACK_HOSTNAME="localhost" --privileged -e DOCKER_HOST="unix:///var/run/docker.sock" -e HOST_TMP_FOLDER="/Users/ronald.petty/tmp/localstack" localstack_main sh
```
```
/opt/code/localstack $ ps wuxa | grep web
   20 localsta  0:00 bash -c if [ "$START_WEB" = "0" ]; then exit 0; fi; make web
   22 localsta  0:00 make web
   24 localsta  0:02 python bin/localstack web
  714 localsta  0:13 python /opt/code/localstack/bin/localstack web
  786 localsta  0:00 grep web
```
```
/opt/code/localstack $ touch /tmp/cache.7c4ae8e0f503846b210fa13439b2d3bd.json
touch: /tmp/cache.7c4ae8e0f503846b210fa13439b2d3bd.json: Permission denied
```
```
/opt/code/localstack $ whoami
localstack
```
> I Have i same problem. web ui is still empty:
> Log:
> aws --endpoint-url="http://21ad0c748654:4578" es list-domain-names [Errno 1] Operation not permitted: '/tmp/cache.603fe2759e3fd86a1a62d33a4bf3652a.json'

I have the same issue

### OS information

```
ProductName:	Mac OS X
ProductVersion:	10.14.5
BuildVersion:	18F132
```

### docker-compose.yml

```
version: '3.2'

services:
  localstack:
    image: localstack/localstack
    container_name: localstack
    ports:
      - "4567-4597:4567-4597"
      - "${PORT_WEB_UI-8080}:${PORT_WEB_UI-8080}"
    environment:
      - DEFAULT_REGION=us-east-1
      - LOCALSTACK_HOSTNAME=localstack
      - SERVICES=iam,s3,ec2,rotue53,cloudwatch,cloudwatchlogs
      - DEBUG=1
      - DATA_DIR=/tmp/localstack/data
      - PORT_WEB_UI=${PORT_WEB_UI- }
      #- LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR- }
      #- KINESIS_ERROR_PROBABILITY=${KINESIS_ERROR_PROBABILITY- }
      - DOCKER_HOST=unix:///var/run/docker.sock
    volumes:
      - './.localstack:/tmp/localstack'
      - "/var/run/docker.sock:/var/run/docker.sock"
```

When I run `TMPDIR=/private$TMPDIR docker-compose up` 

### Container Logs

```
localstack    | 2019-07-25T06:27:42:WARNING:localstack.dashboard.infra: Error running command: { test `which aws` || . .venv/bin/activate; }; aws --endpoint-url="http://localstack:4572" s3api get-bucket-notification-configuration --bucket demo_bucket [Errno 1] Operation not permitted: '/tmp/cache.8a3017c2ef4733fe265d0f8b15ebda06.json'
```
Hitting this as well, can successfuly run aws cli commands against the localstack instance but the UI can't display any of the s3 resources

docker-compose.yml

```
version: '3.2'
services:
  localstack:
    image: localstack/localstack:latest
    container_name: localstack_s3
    ports:
      - '4563-4584:4563-4584'
      - '8055:8080'
    environment:
      - SERVICES=s3
      - DEBUG=1
      - DATA_DIR=/tmp/localstack/data
    volumes:
      - './.localstack:/tmp/localstack'
     # - '/var/run/docker.sock:/var/run/docker.sock'
    networks:
      aws_local:
        ipv4_address: 192.168.10.2
        aliases:
          - localstack-s3
networks:
  aws_local:
    external:
      name: aws-local
```

log messagine indicating failure to list-buckets

```
2019-07-26T02:03:24:WARNING:localstack.dashboard.infra: Error running command: { test `which aws` || . .venv/bin/activate; }; aws --endpoint-url="http://fcba5ecdc4f1:4572" s3api list-buckets [Errno 1] Operation not permitted: '/tmp/cache.59b17a619639bbfe8aea9e201259d92b.json'
```
Having the same issue and same errors as the others. Tried downgrading to the 0.8.10 image, and the problem went away for me...

Edit: WIll add that I'm getting `Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.29/containers/json: dial unix /var/run/docker.sock: connect: permission denied`.

Made sure my user was added to the docker group (the recommend solution) but it didn't fix it.

In case it helps, my setup is Ubuntu 18.04 in a VM, latest docker/docker-compose and a docker-compose.yml similar to the above. The commands I'm running are:

`aws --endpoint-url=http://localhost:4572 s3 mb s3://demo-bucket`  and
`aws --endpoint-url=http://localhost:4572 s3api put-bucket-acl --bucket demo-bucket --acl public-read`

Getting the same error in the log as everyone else when refreshing the page. But with the exact same setup and aws commands in the older version of localstack it works.
Can confirm, getting the same error as everyone else right now


    localstack    | Ready.
    localstack    | 2019-07-29T21:54:43:INFO:localstack.utils.persistence: Restored 2 API calls from persistent file: /tmp/localstack/data/s3_api_calls.json
    localstack    | 2019-07-29T21:54:55:WARNING:localstack.dashboard.infra: Error running command: { test `which aws` || . .venv/bin/activate; }; aws --endpoint-url="http://localhost:4578" es list-domain-names [Errno 1] Operation not permitted: '/tmp/cache.c08081ce4cb73d03925a460cdbf70ce8.json' 
    localstack    | 2019-07-29T21:54:56:WARNING:localstack.dashboard.infra: Error running command: { test `which aws` || . .venv/bin/activate; }; aws --endpoint-url="http://localhost:4572" s3api list-buckets [Errno 1] Operation not permitted: '/tmp/cache.c08081ce4cb73d03925a460cdbf70ce8.json' 
    localstack    | 2019-07-29T21:54:57:WARNING:localstack.dashboard.infra: Error running command: { test `which aws` || . .venv/bin/activate; }; aws --endpoint-url="http://localhost:4574" lambda list-functions [Errno 1] Operation not permitted: '/tmp/cache.c08081ce4cb73d03925a460cdbf70ce8.json' 


**docker-compose file**

    version: "2.1"
    services:
      localstack:
        image: localstack/localstack
        container_name: localstack
        ports:
          # - "4567-4584:4567-4584"
          - '4563-4584:4563-4584'
          - '8055:8080'
         environment:
          - SERVICES=s3,lambda,es
          - DEBUG=0
          - DEFAULT_REGION=us-west-2
          - DATA_DIR=/tmp/localstack/data
          - HOSTNAME=localhost
          - LAMBDA_EXECUTOR=local
          - DOCKER_HOST=unix:///var/run/docker.sock
         volumes:
          - ./.localstack:/tmp/localstack
    # healthcheck:
    #     test: ["CMD", "curl", "-f", "http://localhost:4571"]
    #     interval: 15s
    #     timeout: 20s
    #     retries: 5

The warning goes away for me with the following docker compose file, note the **user:localstack** entry in it. 

However, there's another error in the `graphCtrl` JS controller where the `$http` directive uses deprecated `success` handler instead of `then`.

```
version: '3.2'
services:
  localstack:
    image: localstack/localstack:latest
    container_name: localstack_demo
    user: localstack
    ports:
      - '4563-4584:4563-4584'
      - '8055:8080'
    environment:
      - SERVICES=s3
      - DEBUG=1
      - DATA_DIR=/tmp/localstack/data
    volumes:
      - './.tmp:/tmp'
      - '/var/run/docker.sock:/var/run/docker.sock'
```
@kink80 

When I put `user:localstack` I get this error 

      PermissionError: [Errno 1] Operation not permitted: '/opt/code/localstack/localstack/infra/elasticsearch/tmp'


If I put `user:root` it starts up correctly but still getting the error

    2019-07-30T20:04:53:WARNING:localstack.dashboard.infra: Error running command: { test `which aws` || . .venv/bin/activate; }; aws --endpoint-url="http://localhost:4578" es list-domain-names [Errno 1] Operation not permitted: '/tmp/cache.a743de848abda9c36cceb4392861a8f6.json'
Did you also set the `DATA_DIR` and `volumes` in the same way as shown above?
Experiencing the same issues. 

The files causing the initial errors are actually on the docker image (tests?) e.g. 
/tmp/cache.a743de848abda9c36cceb4392861a8f6.json

chowning them to localstack:localstack gets rid of the error in the log and the cache gets subsequently cleared when refreshing the UI, however still no data is being displayed e.g. for s3 buckets/files working fine on the command line.

There is also a javascript error in Chrome

> angular.js:15567 Error: transition superseded
    at $StateProvider.$get (angular-ui-router.js:2827)
    at Object.invoke (angular.js:5141)
    at angular.js:4930
    at getService (angular.js:5084)
    at injectionArgs (angular.js:5109)
    at Object.invoke (angular.js:5133)
    at angular.js:8778
    at forEach (angular.js:387)
    at Object.<anonymous> (angular.js:8776)
    at Object.invoke (angular.js:5141) "Possibly unhandled rejection: {}"
(anonymous) @ angular.js:15567
(anonymous) @ angular.js:11846
processChecks @ angular.js:17975
$digest @ angular.js:19112
$apply @ angular.js:19500
bootstrapApply @ angular.js:1963
invoke @ angular.js:5141
doBootstrap @ angular.js:1961
bootstrap @ angular.js:1981
angularInit @ angular.js:1866
(anonymous) @ angular.js:36430
e @ jquery.min.js:2
t @ jquery.min.js:2
setTimeout (async)
(anonymous) @ jquery.min.js:2
c @ jquery.min.js:2
fireWith @ jquery.min.js:2
fire @ jquery.min.js:2
c @ jquery.min.js:2
fireWith @ jquery.min.js:2
ready @ jquery.min.js:2
B @ jquery.min.js:2
angular.js:15567 Error: transition prevented
    at $StateProvider.$get (angular-ui-router.js:2828)
    at Object.invoke (angular.js:5141)
    at angular.js:4930
    at getService (angular.js:5084)
    at injectionArgs (angular.js:5109)
    at Object.invoke (angular.js:5133)
    at angular.js:8778
    at forEach (angular.js:387)
    at Object.<anonymous> (angular.js:8776)
    at Object.invoke (angular.js:5141) "Possibly unhandled rejection: {}"
(anonymous) @ angular.js:15567
(anonymous) @ angular.js:11846
processChecks @ angular.js:17975
$digest @ angular.js:19112
$apply @ angular.js:19500
bootstrapApply @ angular.js:1963
invoke @ angular.js:5141
doBootstrap @ angular.js:1961
bootstrap @ angular.js:1981
angularInit @ angular.js:1866
(anonymous) @ angular.js:36430
e @ jquery.min.js:2
t @ jquery.min.js:2
setTimeout (async)
(anonymous) @ jquery.min.js:2
c @ jquery.min.js:2
fireWith @ jquery.min.js:2
fire @ jquery.min.js:2
c @ jquery.min.js:2
fireWith @ jquery.min.js:2
ready @ jquery.min.js:2
B @ jquery.min.js:2
angular.js:15567 Error: transition aborted
    at $StateProvider.$get (angular-ui-router.js:2829)
    at Object.invoke (angular.js:5141)
    at angular.js:4930
    at getService (angular.js:5084)
    at injectionArgs (angular.js:5109)
    at Object.invoke (angular.js:5133)
    at angular.js:8778
    at forEach (angular.js:387)
    at Object.<anonymous> (angular.js:8776)
    at Object.invoke (angular.js:5141) "Possibly unhandled rejection: {}"
(anonymous) @ angular.js:15567
(anonymous) @ angular.js:11846
processChecks @ angular.js:17975
$digest @ angular.js:19112
$apply @ angular.js:19500
bootstrapApply @ angular.js:1963
invoke @ angular.js:5141
doBootstrap @ angular.js:1961
bootstrap @ angular.js:1981
angularInit @ angular.js:1866
(anonymous) @ angular.js:36430
e @ jquery.min.js:2
t @ jquery.min.js:2
setTimeout (async)
(anonymous) @ jquery.min.js:2
c @ jquery.min.js:2
fireWith @ jquery.min.js:2
fire @ jquery.min.js:2
c @ jquery.min.js:2
fireWith @ jquery.min.js:2
ready @ jquery.min.js:2
B @ jquery.min.js:2
angular.js:15567 Error: transition failed
    at $StateProvider.$get (angular-ui-router.js:2830)
    at Object.invoke (angular.js:5141)
    at angular.js:4930
    at getService (angular.js:5084)
    at injectionArgs (angular.js:5109)
    at Object.invoke (angular.js:5133)
    at angular.js:8778
    at forEach (angular.js:387)
    at Object.<anonymous> (angular.js:8776)
    at Object.invoke (angular.js:5141) "Possibly unhandled rejection: {}"`


There seem to be some files in the Docker image which are owned by `root` and therefore causing issues with the processes running inside the container as `localstack`.

```
$ docker run --name localstack -it -e SERVICES=s3 localstack/localstack:0.10.0
$ docker exec -it localstack sh
/opt/code/localstack # ls -l /tmp/
total 168
-rw-r--r--    1 root     root          1299 Aug  3 18:48 cache.04f3aeb71d4a992f80548e35ec919bf1.json
-rw-r--r--    1 root     root             0 Aug  3 18:48 cache.132d9d5d939f0096c790df8777b439d8.json
<snip>
```

You can get it running while waiting for an upstream fix by fixing the permissions and committing to a new image:
```
$ docker run -d --name localstack -it -e SERVICES=s3 localstack/localstack
$ docker exec -it localstack sh -c 'chown -R localstack:localstack /tmp/cache.*'
$ docker stop localstack
$ docker commit localstack mylocalstack
$ docker rm localstack
```

Now reference `mylocalstack`:
```
version: '2.1'
services:
  localstack:
    image: mylocalstack
```
@jkinred, after changing permissions, error is not showing but still dashboard is empty.

Looks like response is proper but unable to display.

<img width="1439" alt="Screenshot 2019-08-06 at 12 26 07 AM" src="https://user-images.githubusercontent.com/25296268/62488055-03c0c380-b7e1-11e9-8dd0-36f1544431bc.png">

<img width="885" alt="Screenshot 2019-08-07 at 5 42 29 PM" src="https://user-images.githubusercontent.com/977460/62612802-cb34fd00-b93a-11e9-9e83-c3ea02bf640e.png">

Same issue here. UI problems goes away after downgrading to 0.8.10.

<img width="1260" alt="Screenshot 2019-08-07 at 5 57 31 PM" src="https://user-images.githubusercontent.com/977460/62613835-d852eb80-b93c-11e9-838a-c3d52ed2798e.png">

I've noticed the dashboard behaving very inconsistently recently in Safari (sometimes loading no, some, or all of the resources), but it is more consistent in Chrome.

In Chrome, as long as I load `http://localhost:8282` then everything works well. But this url redirects to `http://localhost:8282/#/infra` and if I hit refresh then no resources will display. 
Hi all, managed to fix it by changing the docker compose file. The default tmpdir in the docker-compose file template appears to be incorrect and needs to be changed to `"${TMPDIR:-/tmp/localstack}:/tmp"`
Furthermore, LocalStack appears to check if the environment is an AWS environment, so to pass the ```test `which aws` || . .venv/bin/activate``` command, you must set an environment variable `AWS_EXECUTION_ENV=True`

Please reference my docker-compose file below for a working template
```
version: "3"

services:
  localstack:
    image: localstack/localstack:latest
    ports:
      - "4568-4597:4568-4597"
      - "${PORT_WEB_UI-8080}:${PORT_WEB_UI-8080}"
    environment:
      - DOCKER_HOST=unix:///var/run/docker.sock
      - SERVICES=dynamodb,s3,lambda,cloudwatchlogs,iam,sqs,kinesis
      - DEFAULT_REGION=us-west-2
      - AWS_DEFAULT_REGION=us-west-2
      - AWS_EXECUTION_ENV=True
    volumes:
      - "${TMPDIR:-/tmp/localstack}:/tmp"
```
Have tried most of the suggestions here (including your exact docker-compose @Deblob12) and it's still not working for me. It appears to be a front end JS issue introduced some time after the 0.8.x release. I don't have any problems getting the right response back from the graph endpoint, it's just not printing to the screen. Not sure why it works for some and not others, but for me it consistently doesn't work unless I downgrade to the older Localstack. I'm also having issues with the IAM service being only partially implemented, but that's a separate problem.
@unleashit, a front end JS issue might explain the difference I'm seeing between Chrome and Safari. What browser are you using?
Mainly the latest Chrome in Ubuntu 18, but have occasionally tried Firefox (no difference).  

Resolving patch:
diff --git a/localstack/utils/bootstrap.py b/localstack/utils/bootstrap.py
--- a/localstack/utils/bootstrap.py
+++ b/localstack/utils/bootstrap.py
@@ -210,6 +210,13 @@ def contains(apis, api):
     return apis
 
 
+def is_api_enabled(api):
+    apis = canonicalize_api_names()
+    for a in apis:
+        if a == api or a.startswith('%s:' % api):
+            return True
+
+
 def start_infra_locally():
     bootstrap_installation()
     from localstack.services import infra
diff --git a/localstack/utils/common.py b/localstack/utils/common.py
--- a/localstack/utils/common.py
+++ b/localstack/utils/common.py
@@ -41,7 +41,7 @@
 # cache clean variables
 CACHE_CLEAN_TIMEOUT = 60 * 5
 CACHE_MAX_AGE = 60 * 60
-CACHE_FILE_PATTERN = os.path.join(tempfile.gettempdir(), 'cache.*.json')
+CACHE_FILE_PATTERN = os.path.join(tempfile.gettempdir(), '_random_dir_', 'cache.*.json')
 last_cache_clean_time = {'time': 0}
 mutex_clean = threading.Semaphore(1)
 mutex_popen = threading.Semaphore(1)
@@ -886,6 +886,7 @@ def pipe_streams(*args):
 
     hash = md5(cmd)
     cache_file = CACHE_FILE_PATTERN.replace('*', hash)
+    mkdir(os.path.dirname(CACHE_FILE_PATTERN))
     if os.path.isfile(cache_file):
         # check file age
         mod_time = os.path.getmtime(cache_file)
@@ -999,3 +1000,7 @@ def isoformat_milliseconds(t):
         return t.isoformat(timespec='milliseconds')
     except TypeError:
         return t.isoformat()[:-3]
+
+
+# Code that requires util functions from above
+CACHE_FILE_PATTERN = CACHE_FILE_PATTERN.replace('_random_dir_', short_uid())


Test patch: