@quiltdata/benchling-webhook 0.6.1-20251104T053146Z → 0.6.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 +18 -314
- package/dist/bin/benchling-webhook.d.ts.map +1 -1
- package/dist/bin/benchling-webhook.js +1 -1
- package/dist/bin/benchling-webhook.js.map +1 -1
- package/dist/bin/check-logs.d.ts +7 -0
- package/dist/bin/check-logs.d.ts.map +1 -0
- package/dist/bin/check-logs.js +51 -60
- package/dist/bin/check-logs.js.map +1 -0
- package/dist/bin/cli.js +1 -1
- package/dist/bin/cli.js.map +1 -1
- package/dist/bin/commands/deploy.d.ts.map +1 -1
- package/dist/bin/commands/deploy.js +66 -13
- package/dist/bin/commands/deploy.js.map +1 -1
- package/dist/bin/commands/setup-wizard.d.ts.map +1 -1
- package/dist/bin/commands/setup-wizard.js +60 -4
- package/dist/bin/commands/setup-wizard.js.map +1 -1
- package/dist/bin/dev-deploy.js +6 -6
- package/dist/bin/get-env.d.ts +16 -0
- package/dist/bin/get-env.d.ts.map +1 -0
- package/dist/bin/get-env.js +69 -39
- package/dist/bin/get-env.js.map +1 -0
- package/dist/bin/publish.d.ts +20 -0
- package/dist/bin/publish.d.ts.map +1 -0
- package/dist/bin/publish.js +280 -280
- package/dist/bin/publish.js.map +1 -0
- package/dist/bin/release.d.ts +11 -0
- package/dist/bin/release.d.ts.map +1 -0
- package/dist/bin/release.js +128 -105
- package/dist/bin/release.js.map +1 -0
- package/dist/bin/send-event.d.ts +6 -0
- package/dist/bin/send-event.d.ts.map +1 -0
- package/dist/bin/send-event.js +73 -59
- package/dist/bin/send-event.js.map +1 -0
- package/dist/bin/test-invalid-signature.d.ts +3 -0
- package/dist/bin/test-invalid-signature.d.ts.map +1 -0
- package/dist/bin/test-invalid-signature.js +64 -74
- package/dist/bin/test-invalid-signature.js.map +1 -0
- package/dist/bin/version.d.ts +13 -0
- package/dist/bin/version.d.ts.map +1 -0
- package/dist/bin/version.js +199 -186
- package/dist/bin/version.js.map +1 -0
- package/dist/package.json +6 -6
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -4,342 +4,46 @@ Connects Benchling lab notebook entries to Quilt data packages via webhooks.
|
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- Node.js 18+ with `npx` ([download](https://nodejs.org))
|
|
8
8
|
- [AWS credentials](https://docs.aws.amazon.com/cli/v1/userguide/cli-configure-files.html) configured
|
|
9
9
|
- Existing [Quilt deployment](https://www.quilt.bio/install)
|
|
10
10
|
- Benchling tenant with OAuth app configured
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Quick Start
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Run the guided setup wizard:
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npx @quiltdata/benchling-webhook@latest
|
|
17
|
+
npx @quiltdata/benchling-webhook@latest
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
The wizard will:
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
1. Detect your Quilt stack from AWS CloudFormation
|
|
23
|
+
2. Collect and validate your Benchling credentials
|
|
24
|
+
3. Sync secrets to AWS Secrets Manager
|
|
25
|
+
4. Deploy to AWS
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
aws secretsmanager create-secret \
|
|
28
|
-
--name benchling-webhook-credentials \
|
|
29
|
-
--description "Benchling OAuth credentials" \
|
|
30
|
-
--secret-string '{
|
|
31
|
-
"client_id": "your-benchling-client-id",
|
|
32
|
-
"client_secret": "your-benchling-client-secret",
|
|
33
|
-
"tenant": "your-tenant",
|
|
34
|
-
"app_definition_id": "your-app-definition-id"
|
|
35
|
-
}'
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
> **Note**: The secret must contain `client_id`, `client_secret`, and `tenant`. The `app_definition_id` is optional but recommended.
|
|
39
|
-
|
|
40
|
-
### 3. Deploy to AWS (Secrets-Only Mode - v0.6.0+)
|
|
41
|
-
|
|
42
|
-
**Recommended: Secrets-Only Mode** - Minimal configuration, all settings resolved from AWS:
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
npx @quiltdata/benchling-webhook@latest deploy \
|
|
46
|
-
--quilt-stack-arn "arn:aws:cloudformation:us-east-1:123456789012:stack/QuiltStack/abc123" \
|
|
47
|
-
--benchling-secret "benchling-webhook-credentials"
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
That's it! The deployment automatically resolves:
|
|
51
|
-
|
|
52
|
-
- Quilt catalog URL from your stack
|
|
53
|
-
- S3 bucket configuration
|
|
54
|
-
- Athena database name
|
|
55
|
-
- SQS queue ARN
|
|
56
|
-
- AWS region and account
|
|
57
|
-
|
|
58
|
-
**Alternative: Legacy Mode** - For existing deployments or manual configuration:
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
npx @quiltdata/benchling-webhook@latest deploy \
|
|
62
|
-
--benchling-secrets @benchling-secrets.json \
|
|
63
|
-
--catalog your-catalog.quiltdata.com
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
**See [Secrets Configuration Guide](./docs/SECRETS_CONFIGURATION.md) and [Migration Guide](./docs/MIGRATION_GUIDE_V06.md) for more options**
|
|
67
|
-
|
|
68
|
-
### 4. Install in Benchling
|
|
69
|
-
|
|
70
|
-
After deployment, you'll receive a webhook URL. Set it in your Benchling app settings and [install the app](https://docs.benchling.com/docs/getting-started-benchling-apps#installing-your-app) in your tenant.
|
|
27
|
+
After deployment, install the webhook URL in your [Benchling app settings](https://docs.benchling.com/docs/getting-started-benchling-apps#installing-your-app).
|
|
71
28
|
|
|
72
29
|
## Usage
|
|
73
30
|
|
|
74
31
|
In Benchling: Create entry → Insert Canvas → "Quilt Integration" → Create/Update package
|
|
75
32
|
|
|
76
|
-
##
|
|
77
|
-
|
|
78
|
-
### Deployment Modes (v0.6.0+)
|
|
79
|
-
|
|
80
|
-
#### Secrets-Only Mode (Recommended)
|
|
81
|
-
|
|
82
|
-
The simplest deployment method - just provide two parameters:
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
npx @quiltdata/benchling-webhook@latest deploy \
|
|
86
|
-
--quilt-stack-arn "arn:aws:cloudformation:region:account:stack/QuiltStack/id" \
|
|
87
|
-
--benchling-secret "my-secret-name"
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
**Benefits**:
|
|
91
|
-
|
|
92
|
-
- ✅ Minimal configuration - only 2 parameters needed
|
|
93
|
-
- ✅ Centralized secrets in AWS Secrets Manager
|
|
94
|
-
- ✅ Automatic configuration resolution from CloudFormation
|
|
95
|
-
- ✅ No manual parameter updates when infrastructure changes
|
|
96
|
-
- ✅ Better security - no secrets in CI/CD pipelines
|
|
97
|
-
|
|
98
|
-
**How to find your Quilt Stack ARN**:
|
|
99
|
-
|
|
100
|
-
```bash
|
|
101
|
-
# List your CloudFormation stacks
|
|
102
|
-
aws cloudformation describe-stacks --query 'Stacks[?contains(StackName, `Quilt`)].StackId'
|
|
103
|
-
|
|
104
|
-
# Or from the AWS Console → CloudFormation → Stack Details → Stack info → ARN
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
#### Legacy Mode
|
|
108
|
-
|
|
109
|
-
For existing deployments or manual configuration:
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
# Option 1: Inline JSON
|
|
113
|
-
npx @quiltdata/benchling-webhook@latest deploy \
|
|
114
|
-
--benchling-secrets '{"client_id":"xxx","client_secret":"yyy","tenant":"company"}' \
|
|
115
|
-
--catalog your-catalog.quiltdata.com
|
|
116
|
-
|
|
117
|
-
# Option 2: JSON File
|
|
118
|
-
npx @quiltdata/benchling-webhook@latest deploy \
|
|
119
|
-
--benchling-secrets @benchling-secrets.json \
|
|
120
|
-
--catalog your-catalog.quiltdata.com
|
|
121
|
-
|
|
122
|
-
# Option 3: AWS Secrets Manager ARN
|
|
123
|
-
npx @quiltdata/benchling-webhook@latest deploy \
|
|
124
|
-
--benchling-secrets "arn:aws:secretsmanager:region:account:secret:name" \
|
|
125
|
-
--catalog your-catalog.quiltdata.com
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
**📖 [Complete Configuration Guide](./docs/SECRETS_CONFIGURATION.md)**
|
|
129
|
-
**📖 [Migration Guide to v0.6.0](./docs/MIGRATION_GUIDE_V06.md)**
|
|
130
|
-
|
|
131
|
-
### Secret Format
|
|
132
|
-
|
|
133
|
-
**Required fields**:
|
|
134
|
-
|
|
135
|
-
- `client_id`: Benchling OAuth client ID
|
|
136
|
-
- `client_secret`: Benchling OAuth client secret
|
|
137
|
-
- `tenant`: Benchling tenant name (e.g., "company" for company.benchling.com)
|
|
138
|
-
|
|
139
|
-
**Optional fields**:
|
|
140
|
-
|
|
141
|
-
- `app_definition_id`: Benchling app definition ID
|
|
142
|
-
- `api_url`: Custom Benchling API URL
|
|
143
|
-
|
|
144
|
-
**Example**:
|
|
145
|
-
|
|
146
|
-
```json
|
|
147
|
-
{
|
|
148
|
-
"client_id": "abc123",
|
|
149
|
-
"client_secret": "secret_key",
|
|
150
|
-
"tenant": "mycompany",
|
|
151
|
-
"app_definition_id": "app_def_123"
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### Updating Secrets
|
|
156
|
-
|
|
157
|
-
To update Benchling credentials after deployment:
|
|
158
|
-
|
|
159
|
-
**Method 1: Update in AWS Secrets Manager (Recommended)**
|
|
160
|
-
|
|
161
|
-
```bash
|
|
162
|
-
aws secretsmanager update-secret \
|
|
163
|
-
--secret-id benchling-webhook/credentials \
|
|
164
|
-
--secret-string '{"client_id":"new_id","client_secret":"new_secret","tenant":"company"}'
|
|
165
|
-
|
|
166
|
-
# Restart ECS service to pick up changes
|
|
167
|
-
aws ecs update-service \
|
|
168
|
-
--cluster benchling-webhook-cluster \
|
|
169
|
-
--service benchling-webhook-service \
|
|
170
|
-
--force-new-deployment
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
**Method 2: Redeploy Stack**
|
|
174
|
-
|
|
175
|
-
```bash
|
|
176
|
-
npx @quiltdata/benchling-webhook@latest deploy \
|
|
177
|
-
--benchling-secrets @updated-secrets.json
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
## All Available Commands
|
|
181
|
-
|
|
182
|
-
For all available commands, run:
|
|
33
|
+
## Additional Commands
|
|
183
34
|
|
|
184
35
|
```bash
|
|
185
|
-
npx @quiltdata/benchling-webhook@latest --help
|
|
36
|
+
npx @quiltdata/benchling-webhook@latest --help # Show all commands
|
|
37
|
+
npx @quiltdata/benchling-webhook@latest deploy # Deploy only
|
|
38
|
+
npx @quiltdata/benchling-webhook@latest test # Test integration
|
|
39
|
+
npx @quiltdata/benchling-webhook@latest manifest # Generate app manifest
|
|
186
40
|
```
|
|
187
41
|
|
|
188
|
-
|
|
42
|
+
## Resources
|
|
189
43
|
|
|
190
|
-
-
|
|
191
|
-
-
|
|
192
|
-
- `validate` - Validate configuration without deploying
|
|
193
|
-
- `test` - Test the deployed webhook endpoint
|
|
194
|
-
- `manifest` - Generate Benchling app manifest file
|
|
195
|
-
|
|
196
|
-
### Deploy Options
|
|
197
|
-
|
|
198
|
-
```bash
|
|
199
|
-
npx @quiltdata/benchling-webhook@latest deploy [options]
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
**Secrets-Only Mode (v0.6.0+ - Recommended)**:
|
|
203
|
-
|
|
204
|
-
- `--quilt-stack-arn <arn>` - ARN of Quilt CloudFormation stack
|
|
205
|
-
- `--benchling-secret <name>` - Name or ARN of Benchling secret in Secrets Manager
|
|
206
|
-
|
|
207
|
-
**Legacy Mode Configuration**:
|
|
208
|
-
|
|
209
|
-
- `--benchling-secrets <value>` - Benchling secrets (ARN, JSON, or @file)
|
|
210
|
-
- `--catalog <url>` - Quilt catalog URL
|
|
211
|
-
- `--bucket <name>` - S3 bucket for data
|
|
212
|
-
|
|
213
|
-
**AWS Configuration**:
|
|
214
|
-
|
|
215
|
-
- `--profile <name>` - AWS profile to use
|
|
216
|
-
- `--region <region>` - AWS region to deploy to (auto-detected in secrets-only mode)
|
|
217
|
-
- `--image-tag <tag>` - Docker image tag to deploy (default: latest)
|
|
218
|
-
|
|
219
|
-
**Deployment Options**:
|
|
220
|
-
|
|
221
|
-
- `--env-file <path>` - Path to .env file (default: .env)
|
|
222
|
-
- `--yes` - Skip confirmation prompts
|
|
223
|
-
- `--no-bootstrap-check` - Skip CDK bootstrap verification
|
|
224
|
-
- `--require-approval <level>` - CDK approval level (default: never)
|
|
225
|
-
|
|
226
|
-
### Deprecated Parameters (v0.6.0+)
|
|
227
|
-
|
|
228
|
-
> ⚠️ **Warning**: The following parameters are deprecated and will be removed in v1.0.0
|
|
229
|
-
|
|
230
|
-
- `--tenant` - Use `--benchling-secrets` or secrets-only mode instead
|
|
231
|
-
- `--client-id` - Use `--benchling-secrets` or secrets-only mode instead
|
|
232
|
-
- `--client-secret` - Use `--benchling-secrets` or secrets-only mode instead
|
|
233
|
-
- `--app-id` - Use `--benchling-secrets` or secrets-only mode instead
|
|
234
|
-
|
|
235
|
-
**Migration guide**: See [Migration Guide to v0.6.0](./docs/MIGRATION_GUIDE_V06.md)
|
|
236
|
-
|
|
237
|
-
## Documentation
|
|
238
|
-
|
|
239
|
-
- 📖 [Secrets Configuration Guide](./docs/SECRETS_CONFIGURATION.md) - Comprehensive secrets management documentation
|
|
240
|
-
- 📖 [Architecture Decision Record: Secrets Management](./docs/ADR-001-SECRETS-MANAGEMENT.md) - Design decisions and rationale
|
|
241
|
-
- 📖 [CHANGELOG.md](./CHANGELOG.md) - Version history and release notes
|
|
242
|
-
|
|
243
|
-
## Development
|
|
244
|
-
|
|
245
|
-
For local development and contributing:
|
|
246
|
-
|
|
247
|
-
```bash
|
|
248
|
-
git clone https://github.com/quiltdata/benchling-webhook.git
|
|
249
|
-
cd benchling-webhook
|
|
250
|
-
|
|
251
|
-
# Install dependencies and configure (interactive)
|
|
252
|
-
npm run setup
|
|
253
|
-
|
|
254
|
-
# Build package
|
|
255
|
-
npm run build
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
### Testing Workflow
|
|
259
|
-
|
|
260
|
-
```bash
|
|
261
|
-
# 1. Run unit tests (lint + typecheck + mocked tests)
|
|
262
|
-
npm run test
|
|
263
|
-
|
|
264
|
-
# 2. Run local integration tests (builds Docker, uses real Benchling payloads)
|
|
265
|
-
npm run test:local
|
|
266
|
-
|
|
267
|
-
# 3. Run remote integration tests (deploys dev stack, tests through API Gateway)
|
|
268
|
-
npm run test:remote
|
|
269
|
-
|
|
270
|
-
# Individual test commands
|
|
271
|
-
npm run test:ts # TypeScript tests only
|
|
272
|
-
npm run test:python # Python unit tests only
|
|
273
|
-
npm run build:typecheck # Type checking only
|
|
274
|
-
npm run lint # Linting only
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
### Release Workflow
|
|
278
|
-
|
|
279
|
-
```bash
|
|
280
|
-
# Create and push version tag (triggers release pipeline)
|
|
281
|
-
npm run release:tag
|
|
282
|
-
|
|
283
|
-
# CI will run:
|
|
284
|
-
# - npm run test:remote (builds dev image, deploys dev stack, tests)
|
|
285
|
-
# - npm run release (promotes to production after tests pass)
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
## Troubleshooting
|
|
289
|
-
|
|
290
|
-
### Common Issues
|
|
291
|
-
|
|
292
|
-
**Error: "Invalid secret ARN format"**
|
|
293
|
-
|
|
294
|
-
- Verify ARN format: `arn:aws:secretsmanager:region:account:secret:name`
|
|
295
|
-
- See [Troubleshooting Guide](./docs/SECRETS_CONFIGURATION.md#troubleshooting)
|
|
296
|
-
|
|
297
|
-
**Error: "Missing required field: client_id"**
|
|
298
|
-
|
|
299
|
-
- Check secret JSON includes all required fields: `client_id`, `client_secret`, `tenant`
|
|
300
|
-
- Validate JSON syntax: `echo '{"client_id":"..."}' | jq .`
|
|
301
|
-
|
|
302
|
-
**Deprecation Warning**
|
|
303
|
-
|
|
304
|
-
- Migrate to `--benchling-secrets` parameter
|
|
305
|
-
- See [Migration Guide](./docs/SECRETS_CONFIGURATION.md#migration-guide)
|
|
306
|
-
|
|
307
|
-
**For more help**: See [Secrets Configuration - Troubleshooting](./docs/SECRETS_CONFIGURATION.md#troubleshooting)
|
|
308
|
-
|
|
309
|
-
## Security
|
|
310
|
-
|
|
311
|
-
- Secrets are stored in AWS Secrets Manager with encryption at rest
|
|
312
|
-
- Secrets are masked in all CLI output
|
|
313
|
-
- CloudFormation parameters use `noEcho: true`
|
|
314
|
-
- IAM policies grant least-privilege access
|
|
315
|
-
- CloudTrail logs all secret access for audit
|
|
316
|
-
|
|
317
|
-
**Best Practices**:
|
|
318
|
-
|
|
319
|
-
- Never commit secrets to version control
|
|
320
|
-
- Use AWS Secrets Manager for production deployments
|
|
321
|
-
- Rotate secrets regularly
|
|
322
|
-
- Review IAM policies periodically
|
|
323
|
-
|
|
324
|
-
**For detailed security guidance**: See [Secrets Configuration - Security](./docs/SECRETS_CONFIGURATION.md#security-best-practices)
|
|
325
|
-
|
|
326
|
-
## Support
|
|
327
|
-
|
|
328
|
-
- 🐛 [Report Issues](https://github.com/quiltdata/benchling-webhook/issues)
|
|
329
|
-
- 📧 Security vulnerabilities: <security@quiltdata.com>
|
|
330
|
-
- 📖 [Documentation](./docs/)
|
|
331
|
-
- 💬 [Discussions](https://github.com/quiltdata/benchling-webhook/discussions)
|
|
44
|
+
- [Changelog](./CHANGELOG.md) - Version history
|
|
45
|
+
- [Report Issues](https://github.com/quiltdata/benchling-webhook/issues)
|
|
332
46
|
|
|
333
47
|
## License
|
|
334
48
|
|
|
335
49
|
Apache-2.0
|
|
336
|
-
|
|
337
|
-
## Version
|
|
338
|
-
|
|
339
|
-
See [CHANGELOG.md](./CHANGELOG.md) for version history.
|
|
340
|
-
|
|
341
|
-
**Important:** Always use `@latest` with npx to avoid caching issues:
|
|
342
|
-
|
|
343
|
-
```bash
|
|
344
|
-
npx @quiltdata/benchling-webhook@latest --help
|
|
345
|
-
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"benchling-webhook.d.ts","sourceRoot":"","sources":["../../bin/benchling-webhook.ts"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAC;AACvB,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,QAAA,MAAQ,gBAAgB,
|
|
1
|
+
{"version":3,"file":"benchling-webhook.d.ts","sourceRoot":"","sources":["../../bin/benchling-webhook.ts"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAC;AACvB,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,QAAA,MAAQ,gBAAgB,KAAyB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;IACb,KAAK,EAAE,qBAAqB,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACnC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,CAAC,CAsC1B;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAoBrF;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAuB5D;AAuKD,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -44,7 +44,7 @@ const benchling_webhook_stack_1 = require("../lib/benchling-webhook-stack");
|
|
|
44
44
|
const child_process_1 = require("child_process");
|
|
45
45
|
// Import get-env for library usage
|
|
46
46
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
47
|
-
const { inferStackConfig } = require("./get-env
|
|
47
|
+
const { inferStackConfig } = require("./get-env");
|
|
48
48
|
exports.inferStackConfig = inferStackConfig;
|
|
49
49
|
/**
|
|
50
50
|
* Check if CDK is bootstrapped for the given account/region
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"benchling-webhook.js","sourceRoot":"","sources":["../../bin/benchling-webhook.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,8CAyCC;AAMD,gDAoBC;AAMD,kCAuBC;AA5ID,yBAAuB;AACvB,iDAAmC;AACnC,4EAAuE;AACvE,iDAAyC;AAGzC,mCAAmC;AACnC,iEAAiE;AACjE,MAAM,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"benchling-webhook.js","sourceRoot":"","sources":["../../bin/benchling-webhook.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,8CAyCC;AAMD,gDAoBC;AAMD,kCAuBC;AA5ID,yBAAuB;AACvB,iDAAmC;AACnC,4EAAuE;AACvE,iDAAyC;AAGzC,mCAAmC;AACnC,iEAAiE;AACjE,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@@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
2
3
|
/**
|
|
3
4
|
* Check CloudWatch logs for the deployed Benchling webhook ECS service
|
|
4
5
|
* Uses CloudFormation stack outputs to find the correct log group
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
8
|
require("dotenv/config");
|
|
8
|
-
const
|
|
9
|
-
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
10
|
const STACK_NAME = "BenchlingWebhookStack";
|
|
11
|
-
|
|
12
11
|
// Validate required environment variables
|
|
13
12
|
if (!process.env.CDK_DEFAULT_REGION) {
|
|
14
13
|
console.error("Error: CDK_DEFAULT_REGION is not set in .env file");
|
|
15
14
|
console.error("Please set CDK_DEFAULT_REGION in your .env file");
|
|
16
15
|
process.exit(1);
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
const AWS_REGION = process.env.CDK_DEFAULT_REGION;
|
|
20
|
-
|
|
21
18
|
function getStackOutputs() {
|
|
22
19
|
try {
|
|
23
|
-
const output = execSync(
|
|
24
|
-
`aws cloudformation describe-stacks --stack-name ${STACK_NAME} --region ${AWS_REGION} --query 'Stacks[0].Outputs' --output json`,
|
|
25
|
-
{ encoding: "utf-8" },
|
|
26
|
-
);
|
|
20
|
+
const output = (0, child_process_1.execSync)(`aws cloudformation describe-stacks --stack-name ${STACK_NAME} --region ${AWS_REGION} --query 'Stacks[0].Outputs' --output json`, { encoding: "utf-8" });
|
|
27
21
|
return JSON.parse(output);
|
|
28
|
-
}
|
|
22
|
+
}
|
|
23
|
+
catch (_error) {
|
|
29
24
|
console.error(`Error: Could not get stack outputs for ${STACK_NAME}`);
|
|
30
25
|
console.error("Make sure the stack is deployed and AWS credentials are configured.");
|
|
31
26
|
process.exit(1);
|
|
32
27
|
}
|
|
33
28
|
}
|
|
34
|
-
|
|
35
29
|
function getLogGroupFromOutputs(outputs, logType) {
|
|
36
30
|
let outputKey;
|
|
37
31
|
if (logType === "ecs") {
|
|
38
32
|
outputKey = "EcsLogGroup";
|
|
39
|
-
}
|
|
33
|
+
}
|
|
34
|
+
else if (logType === "api") {
|
|
40
35
|
outputKey = "ApiGatewayLogGroup";
|
|
41
|
-
}
|
|
36
|
+
}
|
|
37
|
+
else if (logType === "api-exec") {
|
|
42
38
|
outputKey = "ApiGatewayExecutionLogGroup";
|
|
43
39
|
}
|
|
44
|
-
|
|
40
|
+
else {
|
|
41
|
+
console.error(`Error: Invalid log type '${logType}'`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
45
44
|
const logGroupOutput = outputs.find((o) => o.OutputKey === outputKey);
|
|
46
|
-
|
|
47
45
|
if (!logGroupOutput) {
|
|
48
46
|
console.error(`Error: Could not find ${outputKey} in stack outputs`);
|
|
49
47
|
console.error("Make sure the stack has been deployed with the latest changes.");
|
|
50
48
|
process.exit(1);
|
|
51
49
|
}
|
|
52
|
-
|
|
53
50
|
return logGroupOutput.OutputValue;
|
|
54
51
|
}
|
|
55
|
-
|
|
56
52
|
function printStackInfo(outputs, logGroup, logType) {
|
|
57
53
|
console.log("=".repeat(80));
|
|
58
54
|
console.log("Benchling Webhook Stack Information");
|
|
59
55
|
console.log("=".repeat(80));
|
|
60
|
-
|
|
61
56
|
const clusterName = outputs.find((o) => o.OutputKey === "FargateServiceClusterNameCD3B109F");
|
|
62
57
|
const serviceName = outputs.find((o) => o.OutputKey === "FargateServiceServiceName24CFD869");
|
|
63
58
|
const webhookEndpoint = outputs.find((o) => o.OutputKey === "WebhookEndpoint");
|
|
@@ -66,23 +61,27 @@ function printStackInfo(outputs, logGroup, logType) {
|
|
|
66
61
|
const apiLogGroup = outputs.find((o) => o.OutputKey === "ApiGatewayLogGroup");
|
|
67
62
|
const apiExecLogGroup = outputs.find((o) => o.OutputKey === "ApiGatewayExecutionLogGroup");
|
|
68
63
|
const albDns = outputs.find((o) => o.OutputKey === "LoadBalancerDNS");
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (serviceName)
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
64
|
+
if (clusterName)
|
|
65
|
+
console.log(`Cluster: ${clusterName.OutputValue}`);
|
|
66
|
+
if (serviceName)
|
|
67
|
+
console.log(`Service: ${serviceName.OutputValue}`);
|
|
68
|
+
if (webhookEndpoint)
|
|
69
|
+
console.log(`Endpoint: ${webhookEndpoint.OutputValue}`);
|
|
70
|
+
if (albDns)
|
|
71
|
+
console.log(`ALB DNS: ${albDns.OutputValue}`);
|
|
72
|
+
if (version)
|
|
73
|
+
console.log(`Version: ${version.OutputValue}`);
|
|
76
74
|
console.log("");
|
|
77
75
|
console.log("Log Groups:");
|
|
78
|
-
if (ecsLogGroup)
|
|
79
|
-
|
|
80
|
-
if (
|
|
81
|
-
|
|
76
|
+
if (ecsLogGroup)
|
|
77
|
+
console.log(` ECS: ${ecsLogGroup.OutputValue}${logType === "ecs" ? " (viewing)" : ""}`);
|
|
78
|
+
if (apiLogGroup)
|
|
79
|
+
console.log(` API Access: ${apiLogGroup.OutputValue}${logType === "api" ? " (viewing)" : ""}`);
|
|
80
|
+
if (apiExecLogGroup)
|
|
81
|
+
console.log(` API Exec: ${apiExecLogGroup.OutputValue}${logType === "api-exec" ? " (viewing)" : ""}`);
|
|
82
82
|
console.log("=".repeat(80));
|
|
83
83
|
console.log("");
|
|
84
84
|
}
|
|
85
|
-
|
|
86
85
|
function main() {
|
|
87
86
|
const args = process.argv.slice(2);
|
|
88
87
|
const logType = args.find((arg) => arg.startsWith("--type="))?.split("=")[1] || "all";
|
|
@@ -90,27 +89,22 @@ function main() {
|
|
|
90
89
|
const since = args.find((arg) => arg.startsWith("--since="))?.split("=")[1] || "5m";
|
|
91
90
|
const follow = args.includes("--follow") || args.includes("-f");
|
|
92
91
|
const tail = args.find((arg) => arg.startsWith("--tail="))?.split("=")[1] || "100";
|
|
93
|
-
|
|
94
92
|
// Validate log type
|
|
95
93
|
if (!["ecs", "api", "api-exec", "all"].includes(logType)) {
|
|
96
94
|
console.error("Error: --type must be 'ecs', 'api', 'api-exec', or 'all'");
|
|
97
95
|
process.exit(1);
|
|
98
96
|
}
|
|
99
|
-
|
|
100
97
|
// Get stack outputs
|
|
101
98
|
const outputs = getStackOutputs();
|
|
102
|
-
|
|
103
99
|
// Handle 'all' type - show all three log groups
|
|
104
100
|
if (logType === "all") {
|
|
105
101
|
printStackInfo(outputs, null, "all");
|
|
106
102
|
console.log("Showing logs from all sources (most recent first):\n");
|
|
107
|
-
|
|
108
103
|
const logGroupDefs = [
|
|
109
104
|
{ type: "ECS", group: outputs.find((o) => o.OutputKey === "EcsLogGroup")?.OutputValue },
|
|
110
105
|
{ type: "API-Access", group: outputs.find((o) => o.OutputKey === "ApiGatewayLogGroup")?.OutputValue },
|
|
111
106
|
{ type: "API-Exec", group: outputs.find((o) => o.OutputKey === "ApiGatewayExecutionLogGroup")?.OutputValue },
|
|
112
107
|
];
|
|
113
|
-
|
|
114
108
|
// Warn about missing log groups
|
|
115
109
|
const missingGroups = logGroupDefs.filter(lg => !lg.group);
|
|
116
110
|
if (missingGroups.length > 0) {
|
|
@@ -120,63 +114,60 @@ function main() {
|
|
|
120
114
|
});
|
|
121
115
|
console.log("");
|
|
122
116
|
}
|
|
123
|
-
|
|
124
117
|
const logGroups = logGroupDefs.filter(lg => lg.group);
|
|
125
|
-
|
|
126
118
|
for (const { type, group } of logGroups) {
|
|
127
119
|
console.log(`\n${"=".repeat(80)}`);
|
|
128
120
|
console.log(`${type}: ${group}`);
|
|
129
121
|
console.log("=".repeat(80));
|
|
130
|
-
|
|
131
122
|
let command = `aws logs tail "${group}"`;
|
|
132
123
|
command += ` --region ${AWS_REGION}`;
|
|
133
124
|
command += ` --since ${since}`;
|
|
134
|
-
command +=
|
|
125
|
+
command += " --format short";
|
|
135
126
|
if (filterPattern) {
|
|
136
127
|
command += ` --filter-pattern "${filterPattern}"`;
|
|
137
128
|
}
|
|
138
129
|
command += ` 2>&1 | tail -${tail}`;
|
|
139
|
-
|
|
140
130
|
try {
|
|
141
|
-
const output = execSync(command, { encoding: "utf-8", shell: "/bin/bash" });
|
|
131
|
+
const output = (0, child_process_1.execSync)(command, { encoding: "utf-8", shell: "/bin/bash" });
|
|
142
132
|
if (output.trim()) {
|
|
143
133
|
console.log(output);
|
|
144
|
-
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
145
136
|
console.log(`(No logs in the last ${since})`);
|
|
146
137
|
}
|
|
147
|
-
}
|
|
148
|
-
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
141
|
+
console.log(`Error reading ${type} logs: ${errorMessage}`);
|
|
149
142
|
}
|
|
150
143
|
}
|
|
151
144
|
return;
|
|
152
145
|
}
|
|
153
|
-
|
|
154
146
|
const logGroup = getLogGroupFromOutputs(outputs, logType);
|
|
155
147
|
printStackInfo(outputs, logGroup, logType);
|
|
156
|
-
|
|
157
148
|
// Build AWS logs command
|
|
158
149
|
let command = `aws logs tail ${logGroup}`;
|
|
159
150
|
command += ` --region ${AWS_REGION}`;
|
|
160
151
|
command += ` --since ${since}`;
|
|
161
|
-
command +=
|
|
162
|
-
|
|
152
|
+
command += " --format short";
|
|
163
153
|
if (filterPattern) {
|
|
164
154
|
command += ` --filter-pattern "${filterPattern}"`;
|
|
165
155
|
}
|
|
166
|
-
|
|
167
156
|
if (follow) {
|
|
168
157
|
command += " --follow";
|
|
169
158
|
console.log("Following logs (Press Ctrl+C to stop)...\n");
|
|
170
|
-
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
171
161
|
command += ` | tail -${tail}`;
|
|
172
162
|
console.log(`Showing last ${tail} log entries from the past ${since}...\n`);
|
|
173
163
|
}
|
|
174
|
-
|
|
175
164
|
// Execute logs command
|
|
176
165
|
try {
|
|
177
|
-
execSync(command, { stdio: "inherit" });
|
|
178
|
-
}
|
|
179
|
-
|
|
166
|
+
(0, child_process_1.execSync)(command, { stdio: "inherit" });
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
const hasStatus = error && typeof error === "object" && "status" in error;
|
|
170
|
+
if (hasStatus && error.status !== 130) {
|
|
180
171
|
// Ignore Ctrl+C exit (status 130)
|
|
181
172
|
console.error("\nError fetching logs. Make sure:");
|
|
182
173
|
console.error("1. The stack is deployed");
|
|
@@ -186,7 +177,6 @@ function main() {
|
|
|
186
177
|
}
|
|
187
178
|
}
|
|
188
179
|
}
|
|
189
|
-
|
|
190
180
|
function printHelp() {
|
|
191
181
|
console.log("Usage: npm run logs [options]");
|
|
192
182
|
console.log("");
|
|
@@ -214,18 +204,19 @@ function printHelp() {
|
|
|
214
204
|
console.log(" npm run logs -- --type=ecs --follow # Follow ECS logs");
|
|
215
205
|
console.log(" npm run logs -- --type=api-exec --since=10m # Last 10 min of execution logs");
|
|
216
206
|
}
|
|
217
|
-
|
|
218
207
|
if (require.main === module) {
|
|
219
208
|
const args = process.argv.slice(2);
|
|
220
209
|
if (args.includes("--help") || args.includes("-h")) {
|
|
221
210
|
printHelp();
|
|
222
211
|
process.exit(0);
|
|
223
212
|
}
|
|
224
|
-
|
|
225
213
|
try {
|
|
226
214
|
main();
|
|
227
|
-
}
|
|
228
|
-
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
218
|
+
console.error("Error:", errorMessage);
|
|
229
219
|
process.exit(1);
|
|
230
220
|
}
|
|
231
221
|
}
|
|
222
|
+
//# sourceMappingURL=check-logs.js.map
|