Skip to content

Commit 8b5ba36

Browse files
docs(aws/tutorials): migrate /aws/tutorials section to use lstk (#875)
1 parent 01b493d commit 8b5ba36

17 files changed

Lines changed: 326 additions & 381 deletions

src/content/docs/aws/tutorials/aws-proxy-localstack-extension.mdx

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,23 @@ In this tutorial, you will learn how to install the AWS Cloud Proxy extension an
2929

3030
## Prerequisites
3131

32-
- [LocalStack CLI](/aws/getting-started/installation#localstack-cli) with [`LOCALSTACK_AUTH_TOKEN`](/aws/getting-started/auth-token)
32+
- [`lstk`](/aws/getting-started/installation#lstk) with [`LOCALSTACK_AUTH_TOKEN`](/aws/getting-started/auth-token)
3333
- [Docker](https://docs.docker.com/)
34-
- [AWS CLI](https://docs.aws.amazon.com/cli/v1/userguide/cli-chap-install.html) with [`awslocal` wrapper](https://github.com/localstack/awscli-local)
34+
- [AWS CLI](https://docs.aws.amazon.com/cli/v1/userguide/cli-chap-install.html) with [`lstk aws`](/aws/connecting/aws-cli#localstack-aws-cli-lstk-aws)
3535
- [LocalStack account](https://www.localstack.cloud/pricing)
3636
- [AWS Account](https://aws.amazon.com/) with an [`AWS_ACCESS_KEY_ID` & `AWS_SECRET_ACCESS_KEY`](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_CreateAccessKey)
3737

3838
## Install the AWS Cloud Proxy extension
3939

4040
To install the AWS Cloud Proxy Extension, follow these steps:
4141

42-
1. Launch your LocalStack container using the `localstack` CLI, ensuring that `LOCALSTACK_AUTH_TOKEN` is available in the environment.
42+
1. Launch your LocalStack container using the `lstk` CLI, ensuring that `LOCALSTACK_AUTH_TOKEN` is available in the environment.
4343
2. Visit the [Extensions library](https://app.localstack.cloud/extensions/library) page on the LocalStack Web Application.
4444
![Extensions Library](/images/aws/aws-proxy-tutorial/extensions-library.png)
4545
3. Scroll down to find the **AWS Cloud Proxy** card, then click on the **Install on Instance** button.
4646
![Installing AWS Cloud Proxy extension](/images/aws/aws-proxy-tutorial/installing-aws-proxy-extensions.png)
4747

4848
Once the installation is complete, you will notice that your LocalStack container has restarted with the AWS Cloud Proxy extension successfully installed.
49-
To confirm the installation, execute the following command:
50-
51-
```bash
52-
localstack extensions list
53-
```
54-
55-
```bash title="Output"
56-
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
57-
┃ Name ┃ Summary ┃ Version ┃ Author ┃ Plugin name ┃
58-
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
59-
│ localstack-extension-aws-re… │ LocalStack Extension: AWS │ 0.1.11 │ LocalStack Team │ aws-proxy │
60-
│ │ Cloud Proxy │ │ │ │
61-
└──────────────────────────────┴──────────────────────────────┴─────────┴─────────────────┴────────────────┘
62-
```
63-
64-
After verifying the successful installation, you can shut down the LocalStack container to re-start it with additional configuration variables.
6549

6650
## Tutorial: Working with the AWS Cloud Proxy Extension
6751

@@ -83,15 +67,15 @@ In the following sections, you will create the SQS queue on your local machine a
8367
Begin by running your LocalStack container with the following configuration:
8468

8569
```bash
86-
EXTRA_CORS_ALLOWED_ORIGINS=https://aws-proxy.localhost.localstack.cloud:4566 \
87-
DEBUG=1 \
88-
localstack start
70+
LOCALSTACK_EXTRA_CORS_ALLOWED_ORIGINS=https://aws-proxy.localhost.localstack.cloud:4566 \
71+
LOCALSTACK_DEBUG=1 \
72+
lstk start
8973
```
9074

9175
In the above command:
9276

93-
- The `EXTRA_CORS_ALLOWED_ORIGINS` variable allows the AWS Cloud Proxy extension's web interface to connect with the LocalStack container.
94-
- The `DEBUG` variable enables verbose logging allowing you to see the printed statements from the Lambda function.
77+
- The `LOCALSTACK_EXTRA_CORS_ALLOWED_ORIGINS` variable allows the AWS Cloud Proxy extension's web interface to connect with the LocalStack container.
78+
- The `LOCALSTACK_DEBUG` variable enables verbose logging allowing you to see the printed statements from the Lambda function.
9579

9680
Next, create a file named `testlambda.py` and add the following Python code to it:
9781

@@ -104,7 +88,7 @@ Execute the following commands to create the local Lambda function:
10488

10589
```bash
10690
(zip testlambda.zip testlambda.py)
107-
awslocal lambda create-function \
91+
lstk aws lambda create-function \
10892
--function-name func1 \
10993
--runtime python3.8 \
11094
--role arn:aws:iam::000000000000:role/r1 --handler testlambda.handler \
@@ -129,7 +113,7 @@ awslocal lambda create-function \
129113
You can create the local SQS queue named `test-queue` by executing the following command:
130114

131115
```bash
132-
awslocal sqs create-queue --queue-name test-queue
116+
lstk aws sqs create-queue --queue-name test-queue
133117
```
134118

135119
```bash title="Output"
@@ -152,7 +136,7 @@ Before invoking, set up an event source mapping between the SQS queue and the La
152136
Configure the queue for Lambda using the following command:
153137

154138
```bash
155-
awslocal lambda create-event-source-mapping \
139+
lstk aws lambda create-event-source-mapping \
156140
--function-name func1 \
157141
--batch-size 1 \
158142
--event-source-arn arn:aws:sqs:us-east-1:000000000000:test-queue
@@ -172,7 +156,7 @@ awslocal lambda create-event-source-mapping \
172156
You can then send a message to the SQS queue to trigger the local Lambda function:
173157

174158
```bash
175-
awslocal sqs send-message \
159+
lstk aws sqs send-message \
176160
--queue-url http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/test-queue \
177161
--message-body '{}'
178162
```
@@ -227,7 +211,7 @@ You will observe the local Lambda function being invoked once again, with corres
227211
2024-03-26T07:45:16.524 DEBUG --- [db58fad602e5] l.s.l.i.version_manager : [func1-ed938bb0-e1ee-41fb-a844-db58fad602e5] END RequestId: ed938bb0-e1ee-41fb-a844-db58fad602e5
228212
```
229213

230-
You can even run the standard `awslocal` commands in your terminal that would query the remote cloud resources, instead of the local ones.
214+
You can even run the standard `lstk aws` commands in your terminal that would query the remote cloud resources, instead of the local ones.
231215

232216
Upon completion, you can click **Disable** on the AWS Cloud Proxy extension web interface to deactivate the proxy configuration.
233217
Additionally, you can delete the remote SQS queue to avoid AWS billing for long-running resources.

src/content/docs/aws/tutorials/cloud-pods-collaborative-debugging.mdx

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ The full sample application can be found [on GitHub](https://github.com/localsta
3131

3232
### **Prerequisites**
3333

34-
- [LocalStack CLI](/aws/getting-started/installation#localstack-cli) (preferably using `pip`)
34+
- [`lstk`](/aws/getting-started/installation#lstk)
3535
- [Docker](https://docs.docker.com/engine/install/)
36-
- [Terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli) or [OpenTofu](https://opentofu.org/docs/intro/install/) and [terraform-local](/aws/connecting/infrastructure-as-code/terraform#install-the-tflocal-wrapper-script)
36+
- [Terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli) or [OpenTofu](https://opentofu.org/docs/intro/install/) and [`lstk terraform`](/aws/connecting/infrastructure-as-code/terraform#lstk-terraform)
3737
- Optional for Lambda build & editing: [Maven 3.9.4](https://maven.apache.org/install.html) & [Java 21](https://www.java.com/en/download/help/download_options.html)
3838

3939
- Basic knowledge of AWS services (API Gateway, Lambda, DynamoDB, IAM)
@@ -72,6 +72,12 @@ export LOCALSTACK_AUTH_TOKEN=<your-auth-token>
7272
docker compose up
7373
```
7474

75+
Given that you've started LocalStack via `docker-compose`, you'll need to configure the `lstk` CLI to contact your container:
76+
77+
```bash
78+
export LSTK_ENDPOINT_URL=http://localhost.localstack.cloud:4566
79+
```
80+
7581
### The Terraform Configuration File
7682

7783
The entire Terraform configuration file for setting up the application stack is available in the same repository at
@@ -81,12 +87,12 @@ navigate to the project's root folder and use the following commands:
8187

8288
```bash
8389
cd terraform
84-
tflocal init
85-
tflocal plan
86-
tflocal apply --auto-approve
90+
lstk terraform init
91+
lstk terraform plan
92+
lstk terraform apply --auto-approve
8793
```
8894

89-
`tflocal` is a small wrapper script to run Terraform against LocalStack.
95+
`lstk terraform` runs Terraform against LocalStack, using LocalStack endpoints as AWS provider overrides.
9096
The endpoints for all services are configured to point to the
9197
LocalStack API, which allows you to deploy your unmodified Terraform scripts against LocalStack.
9298

@@ -132,7 +138,7 @@ The Terraform configuration file outputs the REST API ID of the API Gateway.
132138
We can capture that value and use it further to invoke the **`add-product`** Lambda:
133139

134140
```bash
135-
export rest_api_id=$(cd terraform; tflocal output --raw rest_api_id)
141+
export rest_api_id=$(cd terraform; lstk terraform output --raw rest_api_id)
136142
```
137143

138144
The endpoint for the API Gateway is constructed similarly to the one on AWS:
@@ -186,10 +192,10 @@ The Lambda code and the configurations look fine to him.
186192

187193
### Creating a Cloud Pod
188194

189-
To share this exact environment and issue with Alice, a more experienced colleague, Bob only needs to run a simple `localstack pod` command:
195+
To share this exact environment and issue with Alice, a more experienced colleague, Bob only needs to run a simple `lstk snapshot save` command:
190196

191197
```bash
192-
localstack pod save cloud-pod-product-app
198+
lstk snapshot save pod:cloud-pod-product-app
193199
```
194200

195201
```bash title="Output"
@@ -201,31 +207,16 @@ Services: sts,iam,apigateway,dynamodb,lambda,s3,cloudwatch,logs
201207

202208
LocalStack provides a remote storage backend that can be used to store the state of your application and share it with your team members.
203209

204-
The Cloud Pods CLI is included in the LocalStack CLI installation, so there's no need for additional plugins to begin using it.
210+
Cloud Pods are managed through the `snapshot` command, included in the `lstk` CLI installation, so there's no need for additional plugins to begin using it.
205211
The `LOCALSTACK_AUTH_TOKEN` needs to be set as an environment variable.
206212

207-
Additionally, there are other commands for managing Cloud Pods included in the CLI:
208-
209-
```bash
210-
localstack pod --help
211-
```
212-
213-
```bash title="Output"
214-
Usage: localstack pod [OPTIONS] COMMAND [ARGS]...
215-
216-
Manage the state of your instance via Cloud Pods.
217-
218-
Options:
219-
-h, --help Show this message and exit.
213+
Additionally, there are other `snapshot` subcommands for managing Cloud Pods:
220214

221-
Commands:
222-
delete Delete a Cloud Pod
223-
list List all available Cloud Pods
224-
load Load the state of a Cloud Pod into the application runtime
225-
remote Manage Cloud Pod remotes
226-
save Create a new Cloud Pod
227-
versions List all available versions for a Cloud Pod
228-
```
215+
- `lstk snapshot save` (alias `lstk save`) — create a new Cloud Pod
216+
- `lstk snapshot load` (alias `lstk load`) — load the state of a Cloud Pod into the application runtime
217+
- `lstk snapshot list` — list all available Cloud Pods
218+
- `lstk snapshot remove` — delete a Cloud Pod
219+
- `lstk snapshot show` — show metadata for a Cloud Pod
229220

230221
### Pulling and Loading the Cloud Pod
231222

@@ -237,7 +228,7 @@ Now, in a fresh LocalStack instance, Alice can immediately load the Cloud Pod, b
237228
same organization:
238229

239230
```bash
240-
localstack pod load cloud-pod-product-app
231+
lstk snapshot load pod:cloud-pod-product-app
241232
```
242233

243234
```bash title="Output"
@@ -329,10 +320,10 @@ start to finish.
329320

330321
### Other Remote Options
331322

332-
For organizations with specific data regulations, LocalStack offers multiple remote storage options for Cloud Pods,
323+
For organizations with specific data regulations, LocalStack offers an Amazon S3 storage option,
333324
allowing full control with on-premises storage if needed.
334325
That way, Bob, Alice and Carol could collaborate using an S3 bucket for remote storage.
335-
The Cloud Pods command-line interface enables users to manage these remotes with ease, by following the instructions in the
326+
The `lstk` command-line interface enables users to manage this storage with ease, by following the instructions in the
336327
[documentation](/aws/developer-tools/snapshots/saving-snapshots-to-s3).
337328

338329
## Conclusion

src/content/docs/aws/tutorials/ecs-ecr-container-app.mdx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Deploying containers on Elastic Container Service (ECS) clusters using Elastic Container Registry (ECR) and AWS Fargate, with LocalStack"
3-
description: Set up an NGINX web server via Elastic Container Service (ECS) and Elastic Container Registry (ECR) to serve a static website using LocalStack. Learn how you can use CloudFormation templates to declaratively define, create, and deploy your architecture locally with LocalStack's `awslocal` CLI.
3+
description: Set up an NGINX web server via Elastic Container Service (ECS) and Elastic Container Registry (ECR) to serve a static website using LocalStack. Learn how you can use CloudFormation templates to declaratively define, create, and deploy your architecture locally with LocalStack's `lstk aws` CLI.
44
services:
55
- ecs
66
- ecr
@@ -26,7 +26,7 @@ This tutorial will showcase using LocalStack to set up an NGINX web server to se
2626
## Prerequisites
2727

2828
- [LocalStack for AWS](https://localstack.cloud/pricing/)
29-
- [awslocal](/aws/connecting/aws-cli#localstack-aws-cli-awslocal)
29+
- [`lstk aws`](/aws/connecting/aws-cli#localstack-aws-cli-lstk-aws)
3030
- [Docker](https://docker.io/)
3131
- [curl](https://curl.se/download.html)
3232

@@ -43,17 +43,17 @@ ENV foo=bar
4343

4444
The `Dockerfile` uses the official `nginx` image from Docker Hub, which allows us to serve the default index page.
4545
Before building our Docker image, we need to start LocalStack and create an ECR repository to push our Docker image.
46-
To start LocalStack with the `LOCALSTACK_AUTH_TOKEN` environment variable, run the following command:
46+
To start LocalStack, run the following command:
4747

4848
```bash
49-
LOCALSTACK_AUTH_TOKEN=<your-auth-token> localstack start -d
49+
lstk start
5050
```
5151

5252
Next, we will create an ECR repository to push our Docker image.
53-
We will use the `awslocal` CLI to create the repository.
53+
We will use the `lstk aws` CLI to create the repository.
5454

5555
```bash
56-
awslocal ecr create-repository --repository-name sample-ecr-repo
56+
lstk aws ecr create-repository --repository-name sample-ecr-repo
5757
```
5858

5959
The output of this command will contain the `repositoryUri` value that we'll need in the next step:
@@ -360,13 +360,13 @@ Outputs:
360360
To deploy the CloudFormation template we created earlier, use the following command:
361361

362362
```bash
363-
awslocal cloudformation create-stack --stack-name infra --template-body file://templates/ecs.infra.yml
363+
lstk aws cloudformation create-stack --stack-name infra --template-body file://templates/ecs.infra.yml
364364
```
365365

366366
Wait until the stack status changes to `CREATE_COMPLETE` by running the following command:
367367

368368
```bash
369-
awslocal cloudformation wait stack-create-complete --stack-name infra
369+
lstk aws cloudformation wait stack-create-complete --stack-name infra
370370
```
371371

372372
You can also check your deployed stack on the LocalStack Web Application by navigating to the [CloudFormation resource browser](https://app.localstack.cloud/resources/cloudformation/stacks).
@@ -535,36 +535,36 @@ Resources:
535535
Next, let's deploy the CloudFormation template by running the following command:
536536

537537
```bash
538-
awslocal cloudformation create-stack --stack-name ecs --template-body file://templates/ecs.sample.yml --parameters ParameterKey=ImageUrl,ParameterValue=<REPOSITORY_URI>
538+
lstk aws cloudformation create-stack --stack-name ecs --template-body file://templates/ecs.sample.yml --parameters ParameterKey=ImageUrl,ParameterValue=<REPOSITORY_URI>
539539
```
540540

541541
Replace `<REPOSITORY_URI>` with the URI of the Docker image that you want to deploy.
542542
Wait for the stack to be created by running the following command:
543543

544544
```bash
545-
awslocal cloudformation wait stack-create-complete --stack-name ecs
545+
lstk aws cloudformation wait stack-create-complete --stack-name ecs
546546
```
547547

548548
Now that the ECS service has been deployed successfully, let's access the application endpoint.
549549
First, let's list all the ECS clusters we have deployed in our local environment by running the following command to retrieve the cluster ARN:
550550

551551
```bash
552-
awslocal ecs list-clusters | jq -r '.clusterArns[0]'
552+
lstk aws ecs list-clusters | jq -r '.clusterArns[0]'
553553
```
554554

555555
Save the output of the above command as `CLUSTER_ARN`, as we will use it to list the tasks running in the cluster.
556556
Next, run the following command to list the task ARN:
557557

558558
```bash
559-
awslocal ecs list-tasks --cluster <CLUSTER_ARN> | jq -r '.taskArns[0]'
559+
lstk aws ecs list-tasks --cluster <CLUSTER_ARN> | jq -r '.taskArns[0]'
560560
```
561561

562562
Save the task ARN as `TASK_ARN`.
563563
Let us now list the port number on which the application is running.
564564
Run the following command:
565565

566566
```bash
567-
awslocal ecs describe-tasks --cluster <CLUSTER_ARN> --tasks <TASK_ARN> | jq -r '.tasks[0].containers[0].networkBindings[0].hostPort'
567+
lstk aws ecs describe-tasks --cluster <CLUSTER_ARN> --tasks <TASK_ARN> | jq -r '.tasks[0].containers[0].networkBindings[0].hostPort'
568568
```
569569

570570
Earlier, we configured the application to run on port `45139`, in our `HostPort` parameter.
@@ -581,7 +581,7 @@ You should see the default index page of the NGINX web server.
581581
## Conclusion
582582

583583
In this tutorial, we have demonstrated how to deploy a containerized service locally using Amazon ECS, ECR, and LocalStack.
584-
We have also shown how you can use CloudFormation templates with the awslocal CLI to deploy your local AWS infrastructure.
584+
We have also shown how you can use CloudFormation templates with the `lstk aws` CLI to deploy your local AWS infrastructure.
585585

586586
With LocalStack, you can easily mount code from your host filesystem into the ECS container, allowing for a quicker debugging loop that doesn't require rebuilding and redeploying the task's Docker image for each change.
587587

0 commit comments

Comments
 (0)