Skip to content

Commit bea308b

Browse files
docs(aws): migrate infrastructure-as-code guides from wrapper scripts to lstk
Replace awslocal/tflocal/samlocal/cdklocal instructions in the Terraform, AWS SAM, and AWS CDK guides (plus stray awslocal mentions in Crossplane, Cloud Custodian, Former2, Pulumi, Serverless Framework, and Chalice) with the equivalent lstk subcommands. Add a new Deprecated Wrapper Scripts reference page documenting the old scripts for anyone still relying on them, linked from each migrated page. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 30a6510 commit bea308b

11 files changed

Lines changed: 364 additions & 118 deletions

File tree

src/content/docs/aws/connecting/aws-cli.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ You can use the AWS CLI with LocalStack using one or more of the following appro
1717
- [LocalStack AWS CLI](#localstack-aws-cli-lstk-aws) - Use the `lstk aws` command to set the configuration options for you.
1818
- [Using AWS CLI from a pre-built container](#using-aws-cli-from-a-pre-built-container) - Use Amazon's pre-built AWS CLI container image instead of installing `aws` locally.
1919

20+
:::note
21+
`lstk aws` supersedes the older [`awslocal` wrapper script](/aws/connecting/infrastructure-as-code/deprecated-wrapper-scripts#awslocal), which is deprecated but still available if you need it.
22+
:::
23+
2024
## AWS CLI
2125

2226
If you don't already have `aws` (version 2) installed, follow the [official AWS CLI installation instructions](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).

src/content/docs/aws/connecting/infrastructure-as-code/aws-cdk.md

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,43 @@ The AWS Cloud Development Kit (CDK) is an Infrastructure-as-Code (IaC) tool usin
1414

1515
## AWS CDK CLI for LocalStack
1616

17-
`cdklocal` is a thin wrapper script for using the [AWS CDK](https://github.com/aws/aws-cdk) library against local APIs provided by LocalStack.
17+
[`lstk cdk`](/aws/developer-tools/running-localstack/lstk/#cdk) proxies the [AWS CDK](https://github.com/aws/aws-cdk) library against local APIs provided by LocalStack. It requires the AWS CDK CLI version `2.177.0` or newer on your `PATH`.
18+
19+
:::note
20+
`lstk cdk` supersedes the older [`cdklocal` wrapper script](/aws/connecting/infrastructure-as-code/deprecated-wrapper-scripts#cdklocal), which is deprecated but still available if you need it.
21+
:::
1822

1923
### Installation
2024

21-
The `cdklocal` command line is published as an [npm library](https://www.npmjs.com/package/aws-cdk-local):
25+
Install `lstk` by following the [`lstk` installation instructions](/aws/developer-tools/running-localstack/lstk/#installation).
26+
You'll also need the AWS CDK CLI installed separately:
2227

2328
```bash
2429
# Install globally
25-
npm install -g aws-cdk-local aws-cdk
30+
npm install -g aws-cdk
2631

2732
# Verify it installed correctly
28-
cdklocal --version
29-
# e.g. 1.65.5
33+
cdk --version
3034
```
3135

32-
:::note
33-
34-
Using `cdklocal` locally (e.g. within the `node_modules` of your repo instead of globally installed) does not work at the moment for some setups, so make sure you install both `aws-cdk` and `aws-cdk-local` with the `-G` flag.
35-
:::
36-
3736
### Usage
3837

39-
`cdklocal` can be used as a drop-in replacement of where you would otherwise use `cdk` when targeting the AWS Cloud.
38+
`lstk cdk` can be used as a drop-in replacement of where you would otherwise use `cdk` when targeting the AWS Cloud.
4039

4140
```bash
42-
cdklocal --help
41+
lstk cdk --help
4342
```
4443

4544
### Configuration
4645

46+
`lstk cdk`'s only lstk-specific flag (before the CDK action) is `--region <region>` (default `us-east-1`); CDK always targets the default LocalStack account `000000000000`, so there is no `--account` flag.
47+
4748
The following environment variables can be configured:
4849

4950
- `AWS_ENDPOINT_URL`: The endpoint URL (i.e., protocol, host, and port) to connect to LocalStack (default: `http://localhost.localstack.cloud:4566`)
50-
- `LAMBDA_MOUNT_CODE`: Whether to use local Lambda code mounting (via setting `hot-reload` S3 bucket name)
51+
- `AWS_ENDPOINT_URL_S3`: The S3-specific endpoint URL, required alongside `AWS_ENDPOINT_URL` and must include `.s3.` to correctly identify S3 API calls
52+
- `LSTK_CDK_CMD`: Binary to invoke (default `cdk`)
53+
- `AWS_REGION`: Fallback for `--region`
5154

5255
### Example
5356

@@ -62,20 +65,20 @@ The CDK command line ships with a sample app generator to run a quick test for g
6265
```bash
6366
# create sample app
6467
mkdir /tmp/test; cd /tmp/test
65-
cdklocal init sample-app --language=javascript
68+
lstk cdk init sample-app --language=javascript
6669

6770
# bootstrap localstack environment
68-
cdklocal bootstrap
71+
lstk cdk bootstrap
6972

7073
# deploy the sample app
71-
cdklocal deploy
74+
lstk cdk deploy
7275
> Do you wish to deploy these changes (y/n)? y
7376
```
7477

75-
Once the deployment is done, you can inspect the created resources via the [`awslocal`](https://github.com/localstack/awscli-local) command line
78+
Once the deployment is done, you can inspect the created resources via the [`lstk aws`](/aws/developer-tools/running-localstack/lstk/#aws) command line
7679

7780
```bash
78-
awslocal sns list-topics
81+
lstk aws sns list-topics
7982
{
8083
"Topics": [
8184
{
@@ -107,21 +110,5 @@ When this lambda is executed locally from the `/tmp` folder, the package can not
107110

108111
## CDK Version Compatibility
109112

110-
`cdklocal` works with all installed versions of the Node.js `aws-cdk` package.
111-
However, issues exist for `aws-cdk >= 2.177.0`.
112-
113-
For these versions:
114-
115-
- We unset AWS-related environment variables like `AWS_PROFILE` before calling `cdk`.
116-
- We explicitly set `AWS_ENDPOINT_URL` and `AWS_ENDPOINT_URL_S3` to point to LocalStack.
117-
118-
Some environment variables may cause conflicting config, such as wrong region or accidental deploys to real AWS.
119-
To allow specific variables (e.g., `AWS_REGION`), use `AWS_ENVAR_ALLOWLIST`:
120-
121-
```bash
122-
AWS_ENVAR_ALLOWLIST=AWS_REGION,AWS_DEFAULT_REGION AWS_DEFAULT_REGION=eu-central-1 AWS_REGION=eu-central-1 cdklocal ...
123-
```
124-
125-
If you manually set `AWS_ENDPOINT_URL`, it will be used.
126-
You must also set `AWS_ENDPOINT_URL_S3`, and it must include `.s3.` to correctly identify S3 API calls.
127-
See full configuration details [on our configuration docs](https://github.com/localstack/aws-cdk-local?tab=readme-ov-file#configurations).
113+
`lstk cdk` requires AWS CDK CLI `2.177.0` or newer, as noted in [Installation](#installation).
114+
If you're using an older `aws-cdk` version, or the legacy `cdklocal` wrapper script, see [CDK Version Compatibility](/aws/connecting/infrastructure-as-code/deprecated-wrapper-scripts#cdklocal) on the deprecated wrapper scripts page for the relevant environment-variable workarounds.

src/content/docs/aws/connecting/infrastructure-as-code/aws-chalice.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Using LocalStack, you can kick-start your development process, create a new Chal
2020
Start LocalStack inside a Docker container by running:
2121

2222
```bash
23-
localstack start -d
23+
lstk start
2424
```
2525

2626
Install the `chalice-local` package by running:

src/content/docs/aws/connecting/infrastructure-as-code/aws-sam.md

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,29 @@ The AWS Serverless Application Model (SAM) is an open-source framework for devel
1212
It uses a simplified syntax to define functions, APIs, databases, and event source mappings.
1313
When you deploy, SAM converts its syntax into AWS CloudFormation syntax, helping you create serverless applications more quickly.
1414

15-
LocalStack can work with SAM using the AWS SAM CLI for LocalStack.
16-
This CLI comes in the form of a `samlocal` wrapper script, which lets you deploy SAM applications on LocalStack.
17-
This guide explains how to set up local AWS resources using the `samlocal` wrapper script.
15+
LocalStack can work with SAM using [`lstk sam`](/aws/developer-tools/running-localstack/lstk/#sam), which lets you deploy SAM applications on LocalStack.
16+
This guide explains how to set up local AWS resources using `lstk sam`.
1817

19-
## `samlocal` wrapper script
18+
## `lstk sam`
2019

21-
`samlocal` is a wrapper for the `sam` command line interface, facilitating the use of SAM framework with LocalStack.
22-
When executing deployment commands like `samlocal ["build", "deploy", "validate", "package"]`, the script configures the SAM settings for LocalStack and runs the specified SAM command.
20+
`lstk sam` proxies the `sam` command line interface, facilitating the use of the SAM framework with LocalStack.
21+
When executing deployment commands like `lstk sam [ build | deploy | validate | package ]`, it configures the SAM settings for LocalStack and runs the specified SAM command.
2322

24-
### Install the `samlocal` wrapper script
23+
:::note
24+
`lstk sam` supersedes the older [`samlocal` wrapper script](/aws/connecting/infrastructure-as-code/deprecated-wrapper-scripts#samlocal), which is deprecated but still available if you need it.
25+
:::
2526

26-
You can install the `samlocal` wrapper script by running the following command:
27+
### Install lstk
2728

28-
```bash
29-
pip install aws-sam-cli-local
30-
```
29+
To use `lstk sam`, install `lstk` by following the [`lstk` installation instructions](/aws/developer-tools/running-localstack/lstk/#installation).
30+
You'll also need the [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html) (version `1.95.0` or newer) installed and on your `PATH`.
3131

3232
### Create a new SAM project
3333

3434
You can initialize a new SAM project using the following command:
3535

3636
```bash
37-
samlocal init
37+
lstk sam init
3838
```
3939

4040
Select `1` to create a new SAM application using an AWS Quick Start template.
@@ -50,19 +50,29 @@ Then, enter the project name and press `Enter`.
5050
After initializing the SAM project, enter the project directory and deploy the application using the following command:
5151

5252
```bash
53-
samlocal deploy --guided
53+
lstk sam deploy --guided
5454
```
5555

5656
Enter the default values for the deployment, such as the stack name, region, and confirm the changes.
57-
The `samlocal` wrapper will package and deploy the application to LocalStack.
57+
`lstk sam` will package and deploy the application to LocalStack.
5858

5959
### Configuration
6060

61-
| Environment Variable | Default value | Description |
62-
|------------------------|--------------------------------------------------|-------------------------------------------------------------------------|
63-
| AWS_ENDPOINT_URL | `http://localhost.localstack.cloud:4566` | URL at which the `boto3` client can reach LocalStack |
64-
| EDGE_PORT (Deprecated) | `4566` | Port number under which the LocalStack edge service is available |
65-
| LOCALSTACK_HOSTNAME (Deprecated) | `localhost` | Host under which the LocalStack edge service is available
61+
The `lstk sam` command supports several options and environment variables beyond what is available with the standard `sam` command.
62+
| Option | Default | Description |
63+
|----------------------|-----------------|--------------|
64+
| `--region <region>` | `us-east-1` | Deployment region |
65+
| `--account <id>` | `000000000000` | Target AWS account id (12 digits) |
66+
67+
`lstk sam`-specific flags must appear **before** the SAM action (for example, `lstk sam --region us-west-2 build`)
68+
69+
| Environment Variable | Default value | Description |
70+
|-------------------------|----------------|--------------|
71+
| `AWS_ENDPOINT_URL` | - | Override the auto-resolved LocalStack endpoint |
72+
| `AWS_ENDPOINT_URL_S3` | - | Override the auto-resolved LocalStack S3 endpoint |
73+
| `LSTK_SAM_CMD` | `sam` | Binary to invoke |
74+
| `AWS_REGION` | - | Fallback for `--region` |
75+
| `AWS_ACCESS_KEY_ID` | - | Fallback for `--account` |
6676

6777
## Debugging on VS Code
6878

src/content/docs/aws/connecting/infrastructure-as-code/cloud-custodian.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ You can use Cloud Custodian with LocalStack by just specifying the Cloud Custodi
1616

1717
## Getting started
1818

19-
This guide is designed for users who are new to Cloud Custodian and assumes basic knowledge of the AWS CLI and our [`awslocal`](https://github.com/localstack/awscli-local) wrapper script.
19+
This guide is designed for users who are new to Cloud Custodian and assumes basic knowledge of the AWS CLI and our [`lstk aws`](/aws/developer-tools/running-localstack/lstk/#aws) command.
2020

2121
Start your LocalStack container using your preferred method.
2222
We will demonstrate how you can spin up an EC2 instance and tag it with the key `Custodian`, and then use Cloud Custodian to stop the instance.
@@ -33,12 +33,12 @@ After installing Cloud Custodian, you can configure a [custom LocalStack profile
3333

3434
### Create an EC2 instance
3535

36-
You can create an EC2 instance using the `awslocal` wrapper script.
36+
You can create an EC2 instance using `lstk aws`.
3737
You can use the [`RunInstances`](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RunInstances.html) API to create an EC2 instance.
3838
The following example creates an EC2 instance with the tag `Custodian` (any value):
3939

4040
```bash
41-
awslocal ec2 run-instances \
41+
lstk aws ec2 run-instances \
4242
--image-id ami-ff0fea8310f3 \
4343
--count 1 \
4444
--instance-type t3.nano \

src/content/docs/aws/connecting/infrastructure-as-code/crossplane.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ crossplane-test-bucket True True crossplane-test-bucket 30s
194194
```
195195

196196
...
197-
and the bucket it should also be visible when querying the local S3 buckets in LocalStack via [`awslocal`](https://github.com/localstack/awscli-local):
197+
and the bucket it should also be visible when querying the local S3 buckets in LocalStack via [`lstk aws`](/aws/developer-tools/running-localstack/lstk/#aws):
198198

199199
```bash
200-
awslocal s3 ls
200+
lstk aws s3 ls
201201
```
202202

203203
```bash title="Output"
@@ -233,7 +233,7 @@ crossplane-test-queue True True http://host.docker.internal:4566/000000
233233
...and the queue should be visible when listing the SQS queues in LocalStack:
234234

235235
```bash
236-
awslocal sqs list-queues
236+
lstk aws sqs list-queues
237237
```
238238

239239
```bash title="Output"

0 commit comments

Comments
 (0)