Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 39b2784

Browse files
authored
add docs about using AWS CLI v2 from Docker image (#3164)
1 parent e7dd61c commit 39b2784

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

‎README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,49 @@ awslocal kinesis list-streams
319319
**UPDATE**: Use the environment variable `$LOCALSTACK_HOSTNAME` to determine the target host
320320
inside your Lambda function. See [Configurations](#Configurations) section for more details.
321321

322+
## Using the official AWS CLI version 2 Docker image with Localstack Docker container
323+
324+
By default the container running [amazon/aws-cli](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-docker.html) is isolated from `0.0.0.0:4566` on the host machine, that means that aws-cli cannot reach localstack through your shell.
325+
326+
To ensure that the two docker containers can communicate create a network on the docker engine:
327+
328+
```bash
329+
$ â–¶ docker network create localstack
330+
0c9cb3d37b0ea1bfeb6b77ade0ce5525e33c7929d69f49c3e5ed0af457bdf123
331+
```
332+
Then modify the `docker-compose.yml` specifying the network to use:
333+
334+
```yml
335+
networks:
336+
default:
337+
external:
338+
name: "localstack"
339+
```
340+
341+
Run AWS Cli v2 docker container using this network (example):
342+
343+
```bash
344+
$ â–¶ docker run --network localstack --rm -it amazon/aws-cli --endpoint-url=http://localstack:4566 lambda list-functions
345+
{
346+
"Functions": []
347+
}
348+
```
349+
350+
If you use AWS CLI v2 from a docker container often, create an alias:
351+
352+
```bash
353+
$ â–¶ alias laws='docker run --network localstack --rm -it amazon/aws-cli --endpoint-url=http://localstack:4566'
354+
```
355+
356+
So you can type:
357+
358+
```bash
359+
$ â–¶ laws lambda list-functions
360+
{
361+
"Functions": []
362+
}
363+
```
364+
322365
### Client Libraries
323366

324367
* Python: https://github.com/localstack/localstack-python-client

0 commit comments

Comments
 (0)