Skip to content

Commit 3704bb4

Browse files
authored
Merge pull request #92 from localstack/missing_aws_cdk_exception
Throw somewhat better exception if aws-cdk is missing
2 parents 348de14 + 98ce115 commit 3704bb4

File tree

7 files changed

+49
-20
lines changed

7 files changed

+49
-20
lines changed

.github/workflows/integrations.go.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ jobs:
2626
# The AWS CDK only supports third-party languages "until its EOL (End Of Life) shared by the vendor or community"
2727
# https://github.com/aws/aws-cdk
2828
# Golang EOL overview: https://endoflife.date/go
29-
- { language: go, node-version: '16.x', go-version: '1.17.8', region: us-east-1}
30-
- { language: go, node-version: '16.x', go-version: '1.18', region: us-east-1}
31-
- { language: go, node-version: '18.x', go-version: '1.20', region: us-east-1}
29+
- { language: go, node-version: '18.x', go-version: '1.18', region: us-east-1}
30+
- { language: go, node-version: '20.x', go-version: '1.20', region: us-east-1}
31+
- { language: go, node-version: '22.x', go-version: '1.22', region: us-east-1}
3232

3333
env:
3434
AWS_REGION: ${{ matrix.region }}

.github/workflows/integrations.node.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
strategy:
2424
matrix:
2525
include:
26-
- { language: javascript, node-version: '16.x', region: us-east-1}
27-
- { language: typescript, node-version: '16.x', region: eu-west-2}
28-
- { language: typescript, node-version: '16.x', region: us-east-1}
29-
- { language: typescript, node-version: '14.x', region: us-east-1}
26+
- { language: javascript, node-version: '18.x', region: us-east-1}
27+
- { language: typescript, node-version: '20.x', region: eu-west-2}
28+
- { language: typescript, node-version: '21.x', region: us-east-1}
29+
- { language: typescript, node-version: '22.x', region: us-east-1}
3030

3131
env:
3232
AWS_REGION: ${{ matrix.region }}

.github/workflows/integrations.python.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ jobs:
2323
strategy:
2424
matrix:
2525
include:
26-
- { language: python, node-version: '16.x', python-version: '3.10', region: us-east-1}
27-
- { language: python, node-version: '16.x', python-version: '3.9', region: us-east-1}
28-
- { language: python, node-version: '16.x', python-version: '3.8', region: us-east-1}
26+
- { language: python, node-version: '18.x', python-version: '3.9', region: us-east-1}
27+
- { language: python, node-version: '20.x', python-version: '3.10', region: us-east-1}
28+
- { language: python, node-version: '21.x', python-version: '3.11', region: us-east-1}
29+
- { language: python, node-version: '22.x', python-version: '3.12', region: us-east-1}
2930

3031
env:
3132
AWS_REGION: ${{ matrix.region }}

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This project provides a thin wrapper script `cdklocal` for using the [AWS CDK](h
99
## Quick Installation
1010

1111
The `cdklocal` command line is published as an [npm library](https://www.npmjs.com/package/aws-cdk-local):
12-
```
12+
```bash
1313
$ npm install -g aws-cdk-local aws-cdk
1414
...
1515
$ cdklocal --version
@@ -21,6 +21,13 @@ $ cdklocal --version
2121

2222
(Note: Depending on your local setup, you may or may not have to use the global `npm` installation flag `-g` above.)
2323

24+
### Mac OS specific `MODULE_NOT_FOUND` issue
25+
On Mac OS, brew can be used to install AWS CDK, which might result in a `MODULE_NOT_FOUND` error from `cdklocal`.
26+
To resolve this, set the `NODE_PATH` variable pointing to your AWS CDK's `node_module` folder to expand the lookup path for modules.
27+
```bash
28+
$ export NODE_PATH=$NODE_PATH:/opt/homebrew/Cellar/aws-cdk/<CDK_VERSION>/libexec/lib/node_modules
29+
```
30+
2431
## Configurations
2532

2633
The following environment variables can be configured:
@@ -35,19 +42,19 @@ The following environment variables can be configured:
3542
## Deploying a Sample App
3643

3744
The CDK command line ships with a sample app generator to run a quick test for getting started:
38-
```
45+
```bash
3946
$ mkdir /tmp/test; cd /tmp/test
4047
$ cdklocal init sample-app --language=javascript
4148
...
4249
```
4350

4451
Make sure that LocalStack is installed and started up with the required services:
45-
```
52+
```bash
4653
$ SERVICES=serverless,sqs,sns localstack start
4754
```
4855

4956
Then deploy the sample app against the local APIs via the `cdklocal` command line:
50-
```
57+
```bash
5158
$ cdklocal deploy
5259
...
5360
Do you wish to deploy these changes (y/n)? y
@@ -57,7 +64,7 @@ arn:aws:cloudformation:us-east-1:000000000000:stack/TestStack/e3debc0a-311e-4968
5764
```
5865

5966
Once the deployment is done, you can inspect the created resources via the [`awslocal`](https://github.com/localstack/awscli-local) command line:
60-
```
67+
```bash
6168
$ awslocal sns list-topics
6269
{
6370
"Topics": [
@@ -70,6 +77,7 @@ $ awslocal sns list-topics
7077

7178
## Change Log
7279

80+
* 2.18.1: Throw better exception if `aws-cdk` not found
7381
* 2.18.0: Add support for AWS_ENDPOINT_URL, USE_SSL, and BUCKET_MARKER_LOCAL configurations
7482
* 2.17.0: Fix IPv4 fallback check to prevent IPv6 connection issue with `localhost` on macOS
7583
* 2.16.0: Add check to prevent IPv6 connection issue with `localhost` on MacOS

bin/cdklocal

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,16 +363,36 @@ const applyPatches = (provider, CdkToolkit, SDK, ToolkitInfo, patchAssets = true
363363
};
364364

365365
const patchPre_2_14 = () => {
366-
const provider = require("aws-cdk/lib/api/aws-auth");
366+
var provider = null;
367+
try {
368+
provider = require("aws-cdk/lib/api/aws-auth");
369+
} catch(e) {
370+
if (e.code == "MODULE_NOT_FOUND") {
371+
console.log(e);
372+
console.error("`aws-cdk` module NOT found! Have you tried adding it to your `NODE_PATH`?");
373+
throw e;
374+
}
375+
}
376+
367377
const {CdkToolkit} = require("aws-cdk/lib/cdk-toolkit");
368378
const {SDK} = require("aws-cdk/lib/api/aws-auth/sdk");
369379
const {ToolkitInfo} = require("aws-cdk/lib/api");
370380

381+
371382
applyPatches(provider, CdkToolkit, SDK, ToolkitInfo);
372383
};
373384

374385
const patchPost_2_14 = () => {
375-
const lib = require("aws-cdk/lib");
386+
var lib = null;
387+
try {
388+
lib = require("aws-cdk/lib");
389+
} catch(e) {
390+
if (e.code == "MODULE_NOT_FOUND") {
391+
console.log(e);
392+
console.log("`aws-cdk` module NOT found! Have you tried to add it to your `NODE_PATH`?");
393+
process.exit(1);
394+
}
395+
}
376396

377397
applyPatches(lib, lib, lib.SDK, lib.ToolkitInfo, false);
378398
};

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "aws-cdk-local",
33
"description": "CDK Toolkit for use with LocalStack",
4-
"version": "2.18.0",
4+
"version": "2.18.1",
55
"bin": {
66
"cdklocal": "bin/cdklocal"
77
},

0 commit comments

Comments
 (0)