|
| 1 | +# Setting Up and Running LocalStack |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +LocalStack provides a fully functional local AWS cloud stack that allows you to develop and test cloud applications offline. |
| 6 | +It runs inside a Docker container and emulates a wide range of AWS services, including S3, DynamoDB, Lambda, and others. |
| 7 | +This guide describes how to install, configure, and start LocalStack using the LocalStack CLI. |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +Before proceeding, ensure that your system has the following installed: |
| 12 | + |
| 13 | +- Docker (required to run LocalStack containers). For instructions on how to install Docker, see [Docker's official documentation](https://docs.docker.com/get-docker/). |
| 14 | +- A working internet connection for the initial image pull |
| 15 | + |
| 16 | +## Installation |
| 17 | + |
| 18 | +### Brew (macOS or Linux with Homebrew) |
| 19 | + |
| 20 | +Install the LocalStack CLI through the official LocalStack Homebrew tap: |
| 21 | + |
| 22 | +```bash |
| 23 | +brew install localstack/tap/localstack-cli |
| 24 | +``` |
| 25 | + |
| 26 | +## Starting LocalStack |
| 27 | + |
| 28 | +Once installed, you can start LocalStack in detached mode by running: |
| 29 | + |
| 30 | +```bash |
| 31 | +localstack start -d |
| 32 | +``` |
| 33 | + |
| 34 | +You should see output similar to the following: |
| 35 | + |
| 36 | +```bash |
| 37 | + __ _______ __ __ |
| 38 | + / / ____ _________ _/ / ___// /_____ ______/ /__ |
| 39 | + / / / __ \/ ___/ __ `/ /\__ \/ __/ __ `/ ___/ //_/ |
| 40 | + / /___/ /_/ / /__/ /_/ / /___/ / /_/ /_/ / /__/ ,< |
| 41 | + /_____/\____/\___/\__,_/_//____/\__/\__,_/\___/_/|_| |
| 42 | + |
| 43 | +- LocalStack CLI: 4.9.0 |
| 44 | +- Profile: default |
| 45 | +- App: https://app.localstack.cloud |
| 46 | + |
| 47 | +[17:00:15] starting LocalStack in Docker mode localstack.py:512 |
| 48 | + preparing environment bootstrap.py:1322 |
| 49 | + configuring container bootstrap.py:1330 |
| 50 | + starting container bootstrap.py:1340 |
| 51 | +[17:00:16] detaching bootstrap.py:1344 |
| 52 | +``` |
| 53 | + |
| 54 | +This command downloads and launches the LocalStack Docker image, setting up the emulated AWS services locally. |
| 55 | + |
| 56 | +## Checking Service Status |
| 57 | + |
| 58 | +After LocalStack starts, you can view the status of available services by running: |
| 59 | + |
| 60 | +```bash |
| 61 | +localstack status services |
| 62 | +``` |
| 63 | + |
| 64 | +You should see a table listing all active services: |
| 65 | + |
| 66 | +```bash |
| 67 | +┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓ |
| 68 | +┃ Service ┃ Status ┃ |
| 69 | +┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩ |
| 70 | +│ acm │ ✔ available │ |
| 71 | +│ apigateway │ ✔ available │ |
| 72 | +│ cloudformation │ ✔ available │ |
| 73 | +│ cloudwatch │ ✔ available │ |
| 74 | +│ config │ ✔ available │ |
| 75 | +│ dynamodb │ ✔ available │ |
| 76 | +│ s3 │ ✔ available │ |
| 77 | +... |
| 78 | +``` |
| 79 | + |
| 80 | +## Integration with AWS CLI |
| 81 | + |
| 82 | +Once LocalStack is running, you can use the AWS CLI to interact with the emulated services by specifying the LocalStack endpoint. |
| 83 | + |
| 84 | +For example, to list S3 buckets: |
| 85 | + |
| 86 | +```bash |
| 87 | +aws --profile cloud_cache --endpoint-url http://s3.localhost.localstack.cloud:4566 s3 ls |
| 88 | +``` |
| 89 | + |
| 90 | +This command connects to the LocalStack S3 service instead of AWS. |
| 91 | + |
| 92 | +For details on setting up AWS credentials, see [Configuring an AWS CLI Profile for LocalStack](./Configuring%20an%20AWS%20CLI%20Profile%20for%20LocalStack.md). |
| 93 | + |
| 94 | +## Stopping LocalStack |
| 95 | + |
| 96 | +To stop LocalStack, you can use the following command: |
| 97 | + |
| 98 | +```bash |
| 99 | +localstack stop |
| 100 | +``` |
0 commit comments