How to persist resource data to LocalStack cloud?

I started LocalStack Pro from docker compose:

docker-compose.yaml

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_KEY" # required for Pro
      # LocalStack configuration: https://docs.localstack.cloud/references/configuration/
      - DEBUG=${DEBUG:-0}
      - PERSISTENCE=${PERSISTENCE:-0}
    volumes:
      - '${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack'
      - '/var/run/docker.sock:/var/run/docker.sock'
docker compose up

Then created an EKS cluster in another terminal via

awslocal eks create-cluster \
  --name cluster1 \
  --role-arn "arn:aws:iam::000000000000:role/eks-role" \
  --resources-vpc-config "{}"

But after I shutdown the docker containers by Ctrl + C in the docker compose window, and run docker compose up again, I can’t find the EKS cluster anymore.

In my local environment, there generated a directory named volume.

  • docker-compose.yaml
  • volume

I think the data has been persisted to my local. Why can’t I find the cluster which created last time?

Hi @seikyo-cho-lvgs,

You will need to active the persistence by setting the environment variable PERSISTENCE to 1.

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_KEY" # required for Pro
      # LocalStack configuration: https://docs.localstack.cloud/references/configuration/
      - DEBUG=${DEBUG:-0}
      - PERSISTENCE=1
    volumes:
      - '${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack'
      - '/var/run/docker.sock:/var/run/docker.sock'

For more configuration options please visit Configuration | Docs (localstack.cloud)

1 Like

Hi @Marcel ,

Thank you very much for you kind help again!