aws-lambda-layer-cli 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,386 +4,87 @@ A command-line tool for creating and publishing AWS Lambda layers for Node.js an
4
4
 
5
5
  ## Features
6
6
 
7
- - **Create Layers**: Generate Lambda layer zip files for Node.js and Python
8
- - **Publish to AWS**: Directly publish layers to AWS Lambda with IAM credentials
9
- - **Version Management**: Support for package version specification
10
- - **Security**: Input validation and sanitization
11
- - **Smart Naming**: Automatic layer naming with package versions
12
- - **Multiple Packages**: Support for multiple packages in a single layer
13
- - **Runtime Versioning**: Specify Node.js or Python versions
14
- - **Package Managers**: Support for npm (Node.js) and uv/pip (Python)
15
- - **AWS Profile Support**: Use different AWS profiles for publishing
16
- - **Region Specification**: Target specific AWS regions
7
+ - Create and publish Lambda layers for Node.js (npm) and Python (uv/pip)
8
+ - Automatic version management and smart naming
9
+ - Direct publishing to AWS with IAM credentials and region support
10
+ - Support for multiple packages in a single layer
17
11
 
18
12
  ## Installation
19
13
 
20
14
  ### Package Managers (Recommended)
21
15
 
22
- These installs do **not** write to `/usr/local` and do **not** require `sudo`.
23
-
24
16
  #### npm (Node.js)
25
-
26
17
  ```bash
27
18
  npm i -g aws-lambda-layer-cli
28
- aws-lambda-layer-cli --help
29
- ```
30
-
31
- #### pip (Python)
32
-
33
- ```bash
34
- python -m pip install --user aws-lambda-layer-cli
35
- aws-lambda-layer-cli --help
36
19
  ```
37
20
 
38
21
  #### uv (Python)
39
-
40
22
  ```bash
41
23
  uv tool install aws-lambda-layer-cli
42
- aws-lambda-layer-cli --help
43
- ```
44
-
45
- ### Native Installation
46
-
47
- #### Linux/macOS
48
-
49
- ```bash
50
- # Clone or download the repository
51
- git clone https://github.com/yukcw/aws-lambda-layer-cli.git
52
- cd aws-lambda-layer-cli
53
-
54
- # Run installation script (requires sudo)
55
- sudo ./scripts/install.sh
56
- ```
57
-
58
- The installation will:
59
- - Copy scripts to `/usr/local/lib/aws-lambda-layer-cli`
60
- - Create a symlink in `/usr/local/bin` for global access
61
- - Install shell completions for bash and zsh
62
-
63
- #### Windows
64
-
65
- ##### Option 1: PowerShell
66
-
67
- ```powershell
68
- # One-liner installation
69
- powershell -ExecutionPolicy ByPass -c "irm https://raw.githubusercontent.com/yukcw/aws-lambda-layer-cli/main/scripts/install.ps1 | iex"
70
- ```
71
-
72
- Or download and run manually:
73
-
74
- ```powershell
75
- # Download the installer
76
- Invoke-WebRequest -Uri "https://raw.githubusercontent.com/yukcw/aws-lambda-layer-cli/main/scripts/install.ps1" -OutFile "install.ps1"
77
-
78
- # Run the installer (as Administrator)
79
- .\install.ps1
80
24
  ```
81
25
 
82
- This will:
83
- - Download the tool to `%USERPROFILE%\.aws-lambda-layer-cli`
84
- - Add it to your PATH
85
- - Create Windows wrapper scripts
86
-
87
- ##### Option 2: Manual Installation
88
-
89
- 1. Install prerequisites:
90
- - [Git for Windows](https://gitforwindows.org/) (includes Git Bash)
91
- - [AWS CLI](https://aws.amazon.com/cli/) (for publish command)
92
-
93
- 2. Download the scripts from the [repository](https://github.com/yukcw/aws-lambda-layer-cli)
94
-
95
- 3. Extract to a directory and add to PATH
96
-
97
26
  ### Requirements
27
+ - **System**: Linux, macOS, or Windows (WSL recommended)
28
+ - **Tools**: `zip`, `aws-cli` (for publishing), `node` (for Node.js layers), `python` (for Python layers)
98
29
 
99
- - **Linux/macOS**: Bash shell
100
- - **Windows**: Windows Subsystem for Linux (WSL) (recommended), or Git Bash/Cygwin
101
- - **AWS CLI**: Required for `publish` command
102
- - **Node.js**: Required for Node.js layer creation
103
- - **Python**: Required for Python layer creation (uv recommended)
104
- - **zip**: Required for creating zip archives
105
-
106
- **Note**: If using WSL, ensure that AWS CLI, Node.js, Python, and zip are installed within WSL for proper functionality.
107
-
108
- ## Uninstallation
109
-
110
- ### Package managers
111
-
112
- ```bash
113
- # npm
114
- npm uninstall -g aws-lambda-layer-cli
115
-
116
- # pip
117
- python -m pip uninstall aws-lambda-layer-cli
118
-
119
- # uv
120
- uv tool uninstall aws-lambda-layer-cli
121
- ```
122
-
123
- ### Linux/macOS
124
-
125
- ```bash
126
- sudo ./scripts/uninstall.sh
127
- ```
128
-
129
- ### Windows
130
-
131
- #### Using PowerShell
132
-
133
- ```powershell
134
- # Download and run the uninstaller
135
- Invoke-WebRequest -Uri "https://raw.githubusercontent.com/yukcw/aws-lambda-layer-cli/main/scripts/uninstall.ps1" -OutFile "uninstall.ps1"
136
- .\uninstall.ps1
137
- ```
138
-
139
- Or run directly without downloading:
140
-
141
- ```powershell
142
- powershell -ExecutionPolicy ByPass -c "irm https://raw.githubusercontent.com/yukcw/aws-lambda-layer-cli/main/scripts/uninstall.ps1 | iex"
143
- ```
144
- #### Troubleshooting Windows Installation
145
-
146
- If you encounter issues:
147
-
148
- 1. **"bash: command not found"**
149
- - Install [Git for Windows](https://gitforwindows.org/) or [WSL](https://docs.microsoft.com/en-us/windows/wsl/install)
150
- - Restart PowerShell/Command Prompt after installation
151
-
152
- 2. **"No such file or directory"**
153
- - Try running: `bash "$env:USERPROFILE\.aws-lambda-layer-cli\aws-lambda-layer-cli" --help`
154
- - Or reinstall: `powershell -ExecutionPolicy ByPass -c "irm https://raw.githubusercontent.com/yukcw/aws-lambda-layer-cli/main/scripts/install.ps1 | iex"`
155
-
156
- 3. **Permission issues**
157
- - Run PowerShell as Administrator
158
- - Or run: `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`
159
30
  ## Usage
160
31
 
161
- ### Basic Syntax
162
-
163
32
  ```bash
164
- # Create a local zip file
165
- aws-lambda-layer zip --nodejs <packages> [options]
166
- aws-lambda-layer zip --python <packages> [options]
167
-
168
- # Publish directly to AWS
169
- aws-lambda-layer publish --nodejs <packages> [options]
170
- aws-lambda-layer publish --python <packages> [options]
33
+ aws-lambda-layer-cli <command> [options]
171
34
  ```
172
35
 
173
36
  ### Commands
174
-
175
- - **zip**: Create and package a Lambda layer as zip file
176
- - **publish**: Create and publish a Lambda layer to AWS (uses IAM credentials)
177
- - **help**: Show help message
178
-
179
- ### Runtime Options
180
-
181
- - `--nodejs`, `--node`, `-n`: Create a Node.js Lambda layer
182
- - `--python`, `--py`, `-p`: Create a Python Lambda layer
183
- - `--runtime=RUNTIME`: Specify runtime (nodejs or python)
184
-
185
- ### Common Options
186
-
187
- - `--name`: Name for the output zip file / layer name
188
- - `--description`: Description for the layer (publish command only)
189
- - `-h`, `--help`: Show help message
190
-
191
- ### AWS Options (publish command only)
192
-
193
- - `--profile`: AWS CLI profile to use (default: default profile)
194
- - `--region`: AWS region (e.g., us-east-1, ap-east-1)
195
-
196
- ### Node.js Specific Options
197
-
198
- - `--node-version`: Node.js version (default: 24)
199
-
200
- ### Python Specific Options
201
-
202
- - `--python-version`: Python version (default: 3.14)
203
- - `--no-uv`: Use pip/venv instead of uv
37
+ - `zip`: Create a local zip file
38
+ - `publish`: Create and publish a layer to AWS
39
+ - `completion`: Generate shell completion scripts
40
+ - `uninstall`: Uninstall the tool
41
+ - `help`: Show help message
42
+
43
+ ### Options
44
+
45
+ | Option | Description |
46
+ |--------|-------------|
47
+ | `--nodejs, -n <pkgs>` | Create Node.js layer (comma-separated packages) |
48
+ | `--python, -p <pkgs>` | Create Python layer (comma-separated packages) |
49
+ | `--name` | Custom layer name |
50
+ | `--description` | Layer description (publish only) |
51
+ | `--profile` | AWS CLI profile (publish only) |
52
+ | `--region` | AWS region (publish only) |
53
+ | `--node-version` | Node.js version (default: 24) |
54
+ | `--python-version` | Python version (default: 3.14) |
55
+ | `--no-uv` | Use pip/venv instead of uv |
56
+ | `-v, --version` | Show version |
204
57
 
205
58
  ## Examples
206
59
 
207
- ### Node.js Examples
208
-
209
- #### Create Local Zip Files
210
-
211
- ```bash
212
- # Single package with version
213
- aws-lambda-layer zip --nodejs express@4.18.2
214
-
215
- # Multiple packages with versions
216
- aws-lambda-layer zip --nodejs express@4.18.2,axios@1.6.2,lodash@4.17.21
217
-
218
- # With custom name
219
- aws-lambda-layer zip --nodejs axios,lodash --name utility-layer
220
-
221
- # With specific Node.js version
222
- aws-lambda-layer zip --nodejs express@4.18.2 --node-version 20
223
-
224
- # Scoped packages
225
- aws-lambda-layer zip --nodejs @babel/core@7.23.0,@babel/types@7.23.0
226
- ```
227
-
228
- #### Publish to AWS
229
-
230
- ```bash
231
- # Basic publish
232
- aws-lambda-layer publish --nodejs express@4.18.2 --description "Express layer"
233
-
234
- # With custom layer name
235
- aws-lambda-layer publish --nodejs date-fns,uuid --name utility-layer --description "Utility packages"
236
-
237
- # Using specific AWS profile
238
- aws-lambda-layer publish --nodejs express@4.18.2 --profile production --description "Express layer"
239
-
240
- # Specify AWS region
241
- aws-lambda-layer publish --nodejs axios --region ap-east-1 --description "Axios layer"
242
-
243
- # With both profile and region
244
- aws-lambda-layer publish --nodejs lodash --profile dev --region us-east-1 --description "Lodash layer"
245
- ```
246
-
247
- ### Python Examples
248
-
249
- #### Create Local Zip Files
250
-
60
+ ### Node.js
251
61
  ```bash
252
- # Single package with version
253
- aws-lambda-layer zip --python numpy==1.26.0
254
-
255
- # Multiple packages
256
- aws-lambda-layer zip --python numpy==1.26.0,pandas==2.1.3,requests>=2.31.0
257
-
258
- # With custom name
259
- aws-lambda-layer zip --python requests,pytz --name web-utils
62
+ # Create local zip with multiple packages
63
+ aws-lambda-layer-cli zip --nodejs express@4.18.2,axios --name my-layer
260
64
 
261
- # With specific Python version
262
- aws-lambda-layer zip --python numpy==1.26.0 --python-version 3.12
263
-
264
- # Using pip instead of uv
265
- aws-lambda-layer zip --python pandas==2.1.3 --no-uv
65
+ # Publish to AWS with specific profile and region
66
+ aws-lambda-layer-cli publish --nodejs lodash --profile prod --region us-east-1 --description "Utils"
266
67
  ```
267
68
 
268
- #### Publish to AWS
269
-
69
+ ### Python
270
70
  ```bash
271
- # Basic publish
272
- aws-lambda-layer publish --python numpy==1.26.0 --description "NumPy layer"
71
+ # Create local zip with specific python version
72
+ aws-lambda-layer-cli zip --python numpy==1.26.0,pandas --python-version 3.12
273
73
 
274
- # Multiple packages with description
275
- aws-lambda-layer publish --python requests==2.31.0,pytz==2023.3 --description "Web utilities"
276
-
277
- # Using specific AWS profile
278
- aws-lambda-layer publish --python pandas==2.1.3 --profile production --description "Pandas layer"
279
-
280
- # Specify AWS region
281
- aws-lambda-layer publish --python numpy==1.26.0 --region us-west-2 --description "NumPy layer"
282
-
283
- # With both profile and region
284
- aws-lambda-layer publish --python scikit-learn --profile ml-account --region eu-west-1 --description "ML layer"
74
+ # Publish to AWS
75
+ aws-lambda-layer-cli publish --python requests --name web-layer
285
76
  ```
286
77
 
287
- ## Package Version Formats
288
-
289
- ### Node.js
290
- - `express@4.18.2` - Exact version
291
- - `axios` - Latest version
292
- - `lodash@^4.17.0` - Compatible version
293
- - `@babel/core@7.23.0,@babel/types@7.23.0` - Multiple scoped packages
294
-
295
- ### Python
296
- - `numpy==1.26.0` - Exact version
297
- - `pandas` - Latest version
298
- - `requests>=2.31.0` - Minimum version
299
- - `pytz~=2023.3` - Compatible version
300
-
301
- ## Publishing to AWS
302
-
303
- ### Requirements
304
-
305
- Before using the `publish` command, ensure you have:
306
-
307
- 1. **AWS CLI installed and configured**
308
- ```bash
309
- aws configure
310
- # or for specific profile
311
- aws configure --profile production
312
- ```
313
-
314
- 2. **IAM Permissions**: Your IAM user/role needs:
315
- - `lambda:PublishLayerVersion`
316
- - `sts:GetCallerIdentity` (for account verification)
317
- - `iam:ListAccountAliases` (optional, for account info)
318
-
319
- 3. **Region Configuration**: Either:
320
- - Set default region: `aws configure set region us-east-1`
321
- - Or use `--region` flag when publishing
322
-
323
- 4. **zip command installed**: Ensure the `zip` command is available on your system.
324
-
325
- ### Confirmation Prompt
326
-
327
- When publishing, you'll see:
328
- 1. AWS Account ID
329
- 2. AWS Profile (if specified)
330
- 3. Account Aliases (if available)
331
- 4. Target Region
332
- 5. Confirmation prompt: `Do you want to proceed? [Y/n]:`
333
-
334
- Press Y (or Enter for default Yes) to proceed, or N to cancel.
335
-
336
- ## Output
337
-
338
- ### Zip Command
339
- Creates a zip file in the current directory with format:
340
- - Node.js: `<package-name>-<version>-nodejs<node-version>.zip`
341
- - Python: `<package-name>-<version>-python<python-version>.zip`
342
-
343
- ### Publish Command
344
- - Uploads layer to AWS Lambda
345
- - Returns Layer ARN
346
- - Shows usage examples
347
- - Provides command to attach to existing Lambda functions
348
-
349
- ## Troubleshooting
350
-
351
- ### Common Issues
352
-
353
- 1. **AWS credentials not configured**
354
- ```bash
355
- aws configure
356
- # or
357
- aws configure --profile your-profile
358
- ```
359
-
360
- 2. **IAM permissions missing**
361
- - Ensure your AWS credentials has `lambda:PublishLayerVersion` permission
362
-
363
- 3. **Layer name already exists**
364
- - Use `--name` option to specify a different name
365
- - Or delete the existing layer version
366
-
367
- 4. **Zip file too large**
368
- - AWS limit: 50MB for direct upload
369
- - Consider using fewer packages or S3 upload for larger layers
370
-
371
- 5. **Region not configured**
372
- - Use `--region` flag or configure default region:
373
- ```bash
374
- aws configure set region us-east-1
375
- ```
376
-
377
78
  ## Shell Completion
378
79
 
379
- Completions are installed for bash and zsh. Restart your shell or source the completion files:
80
+ Add to your shell config (`~/.bashrc` or `~/.zshrc`):
380
81
 
381
82
  ```bash
382
83
  # Bash
383
- source /etc/bash_completion.d/aws-lambda-layer-completion.bash
84
+ source <(aws-lambda-layer-cli completion --bash)
384
85
 
385
86
  # Zsh
386
- source /usr/local/share/zsh/site-functions/_aws-lambda-layer
87
+ source <(aws-lambda-layer-cli completion --zsh)
387
88
  ```
388
89
 
389
90
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-lambda-layer-cli",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "CLI tool for creating and publishing AWS Lambda layers for Node.js and Python.",
5
5
  "keywords": [
6
6
  "aws",
@@ -82,6 +82,7 @@ show_help() {
82
82
  printf " ${YELLOW}--profile${NC} AWS CLI profile to use (default: default profile)\n"
83
83
  printf " ${YELLOW}--region${NC} AWS region (e.g., us-east-1, ap-east-1)\n"
84
84
  printf "${BLUE}Other Options:${NC}\n"
85
+ printf " ${YELLOW}--version, -v${NC} Show tool version information\n"
85
86
  printf " ${YELLOW}--node-version${NC} Node.js version (default: 24)\n"
86
87
  printf " ${YELLOW}--python-version${NC} Python version (default: 3.14)\n"
87
88
  printf " ${YELLOW}--no-uv${NC} Use pip/venv instead of uv\n\n"