localstack-samples / localstack-pro-samples

Sample projects to demonstrate advanced LocalStack features
178 stars 56 forks source link

Starting localstack pro via docker compose fails with API key #252

Open hereiskeith opened 3 weeks ago

hereiskeith commented 3 weeks ago

Following this doc to try to run localstack pro via docker compose: https://docs.localstack.cloud/getting-started/installation/#:~:text=Starting%20LocalStack%20with%20Docker%2DCompose

As suggested by the doc, I have added my auth token to the LOCALSTACK_AUTH_TOKEN environment variable expecting everything to start working. However the start-up process failed right away complaining no API key set up... This is not mentioned in the Quick Start Guide though.

I checked https://app.localstack.cloud/workspace/api-keys, but localstack didn't allow me to generate an API key either since it is being deprecated, which is understandable.

May I have any suggestions how I could resolve or work around it? (with a true valid license token in hand), thanks! image

this is the docker-compose.yml file I ran

version: "3.8"

services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}"
    image: localstack/localstack-pro  # required for Pro
    ports:
      - "127.0.0.1:4566:4566"            # LocalStack Gateway
      - "127.0.0.1:4510-4559:4510-4559"  # external services port range
      - "127.0.0.1:443:443"              # LocalStack HTTPS Gateway (Pro)
    environment:
      # Activate LocalStack Pro: https://docs.localstack.cloud/getting-started/auth-token/
      - LOCALSTACK_AUTH_TOKEN=my-token  # required for Pro
      # LocalStack configuration: https://docs.localstack.cloud/references/configuration/
      - DEBUG=1
      - PERSISTENCE=1
      - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"
API key activation failed! 🔑❌
localstack-main  |
localstack-main  | We could not get the API Key from the environment variable `LOCALSTACK_API_KEY`
localstack-main  |
localstack-main  | Due to this error, Localstack has quit. LocalStack pro features can only be used with a valid license.
localstack-main  |
localstack-main  | - Please check that your API key is set up correctly and that you are using the correct key.
localstack-main  |   You can find your API key in our webapp at https://app.localstack.cloud.
localstack-main  | - If you want to continue using LocalStack without pro features you can set `ACTIVATE_PRO=0`.
localstack-main  |
localstack-main  |
localstack-main  | During handling of the above exception, another exception occurred:
localstack-main  |
localstack-main  | Traceback (most recent call last):
localstack-main  |   File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
localstack-main  |     return _run_code(code, main_globals, None,
localstack-main  |   File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
localstack-main  |
localstack-main  |     exec(code, run_globals)
localstack-main  |   File "/opt/code/localstack/.venv/lib/python3.10/site-packages/localstack/runtime/main.py", line 28, in <module>
localstack-main  |     main()
localstack-main  |   File "/opt/code/localstack/.venv/lib/python3.10/site-packages/localstack/runtime/main.py", line 20, in main
localstack-main  |     infra.start_infra(asynchronous=False)
localstack-main  |   File "/opt/code/localstack/.venv/lib/python3.10/site-packages/localstack/services/infra.py", line 415, in start_infra
localstack-main  |     stop_infra()
localstack-main  |   File "/opt/code/localstack/.venv/lib/python3.10/site-packages/localstack/services/infra.py", line 279, in stop_infra
localstack-main  |     hooks.on_infra_shutdown.run()
localstack-main  |   File "/opt/code/localstack/.venv/lib/python3.10/site-packages/localstack/runtime/hooks.py", line 64, in run_in_order
localstack-main  |     fn_plugin(*args, **kwargs)
localstack-main  |   File "/opt/code/localstack/.venv/lib/python3.10/site-packages/plugin/core.py", line 183, in __call__
localstack-main  |     return self.fn(*args, **kwargs)
localstack-main  |   File "/opt/code/localstack/.venv/lib/python3.10/site-packages/localstack_ext/extensions/plugins.py", line 9, in extensions_on_infra_shutdown
localstack-main  |     def extensions_on_infra_shutdown():from localstack_ext.extensions.platform import run_on_infra_shutdown_hook as A;A()
localstack-main  | ModuleNotFoundError: No module named 'localstack_ext.extensions.platform'
localstack-main  | LocalStack supervisor: localstack process (PID 15) returned with exit code 1
localstack-main  | LocalStack supervisor: exiting
alexrashed commented 2 weeks ago

Hi @hereiskeith! As mentioned in #251, usually issues concerning LocalStack are created in localstack/localstack, but we can tackle this right here too. It seems like you have a heavily outdated version of LocalStack (which doesn't even yet support the auth tokens). Please make sure to explicitly pull the latest version of the image when using it:

docker pull localstack/localstack-pro:latest

Afterwards the auth token should be picked up just fine. Please let me know if this solves your issues.