@stacksjs/ts-cloud 0.1.3 → 0.1.5

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.
Files changed (187) hide show
  1. package/README.md +98 -13
  2. package/dist/aws/acm.d.ts +129 -0
  3. package/dist/aws/application-autoscaling.d.ts +282 -0
  4. package/dist/aws/bedrock.d.ts +2292 -0
  5. package/dist/aws/client.d.ts +79 -0
  6. package/dist/aws/cloudformation.d.ts +105 -0
  7. package/dist/aws/cloudfront.d.ts +265 -0
  8. package/dist/aws/cloudwatch-logs.d.ts +48 -0
  9. package/dist/aws/comprehend.d.ts +505 -0
  10. package/dist/aws/connect.d.ts +377 -0
  11. package/dist/aws/deploy-imap.d.ts +14 -0
  12. package/dist/aws/dynamodb.d.ts +176 -0
  13. package/dist/aws/ec2.d.ts +272 -0
  14. package/dist/aws/ecr.d.ts +149 -0
  15. package/dist/aws/ecs.d.ts +162 -0
  16. package/dist/aws/elasticache.d.ts +71 -0
  17. package/dist/aws/elbv2.d.ts +248 -0
  18. package/dist/aws/email.d.ts +175 -0
  19. package/dist/aws/eventbridge.d.ts +142 -0
  20. package/dist/aws/iam.d.ts +638 -0
  21. package/dist/aws/imap-server.d.ts +119 -0
  22. package/{src/aws/index.ts → dist/aws/index.d.ts} +62 -83
  23. package/{src/aws/kendra.ts → dist/aws/kendra.d.ts} +71 -386
  24. package/dist/aws/lambda.d.ts +232 -0
  25. package/dist/aws/opensearch.d.ts +87 -0
  26. package/dist/aws/personalize.d.ts +516 -0
  27. package/dist/aws/polly.d.ts +214 -0
  28. package/dist/aws/rds.d.ts +240 -0
  29. package/dist/aws/rekognition.d.ts +543 -0
  30. package/dist/aws/route53-domains.d.ts +113 -0
  31. package/dist/aws/route53.d.ts +215 -0
  32. package/dist/aws/s3.d.ts +212 -0
  33. package/dist/aws/scheduler.d.ts +140 -0
  34. package/dist/aws/secrets-manager.d.ts +170 -0
  35. package/dist/aws/ses.d.ts +288 -0
  36. package/dist/aws/setup-phone.d.ts +0 -0
  37. package/dist/aws/setup-sms.d.ts +115 -0
  38. package/dist/aws/sms.d.ts +304 -0
  39. package/dist/aws/smtp-server.d.ts +61 -0
  40. package/dist/aws/sns.d.ts +117 -0
  41. package/dist/aws/sqs.d.ts +65 -0
  42. package/dist/aws/ssm.d.ts +179 -0
  43. package/dist/aws/sts.d.ts +15 -0
  44. package/dist/aws/support.d.ts +104 -0
  45. package/dist/aws/test-imap.d.ts +0 -0
  46. package/dist/aws/textract.d.ts +403 -0
  47. package/dist/aws/transcribe.d.ts +60 -0
  48. package/dist/aws/translate.d.ts +358 -0
  49. package/dist/aws/voice.d.ts +219 -0
  50. package/dist/bin/cli.js +1724 -0
  51. package/dist/config.d.ts +7 -0
  52. package/dist/deploy/index.d.ts +2 -0
  53. package/dist/deploy/static-site-external-dns.d.ts +51 -0
  54. package/dist/deploy/static-site.d.ts +71 -0
  55. package/dist/dns/cloudflare.d.ts +52 -0
  56. package/dist/dns/godaddy.d.ts +38 -0
  57. package/dist/dns/index.d.ts +45 -0
  58. package/dist/dns/porkbun.d.ts +18 -0
  59. package/dist/dns/route53-adapter.d.ts +38 -0
  60. package/{src/dns/types.ts → dist/dns/types.d.ts} +26 -63
  61. package/dist/dns/validator.d.ts +78 -0
  62. package/dist/generators/index.d.ts +1 -0
  63. package/dist/generators/infrastructure.d.ts +30 -0
  64. package/{src/index.ts → dist/index.d.ts} +70 -93
  65. package/dist/index.js +7881 -0
  66. package/dist/push/apns.d.ts +60 -0
  67. package/dist/push/fcm.d.ts +117 -0
  68. package/dist/push/index.d.ts +14 -0
  69. package/dist/security/pre-deploy-scanner.d.ts +69 -0
  70. package/dist/ssl/acme-client.d.ts +67 -0
  71. package/dist/ssl/index.d.ts +2 -0
  72. package/dist/ssl/letsencrypt.d.ts +48 -0
  73. package/dist/types.d.ts +1 -0
  74. package/dist/utils/cli.d.ts +123 -0
  75. package/dist/validation/index.d.ts +1 -0
  76. package/dist/validation/template.d.ts +23 -0
  77. package/package.json +8 -8
  78. package/bin/cli.ts +0 -133
  79. package/bin/commands/analytics.ts +0 -328
  80. package/bin/commands/api.ts +0 -379
  81. package/bin/commands/assets.ts +0 -221
  82. package/bin/commands/audit.ts +0 -501
  83. package/bin/commands/backup.ts +0 -682
  84. package/bin/commands/cache.ts +0 -294
  85. package/bin/commands/cdn.ts +0 -281
  86. package/bin/commands/config.ts +0 -202
  87. package/bin/commands/container.ts +0 -105
  88. package/bin/commands/cost.ts +0 -208
  89. package/bin/commands/database.ts +0 -401
  90. package/bin/commands/deploy.ts +0 -674
  91. package/bin/commands/domain.ts +0 -397
  92. package/bin/commands/email.ts +0 -423
  93. package/bin/commands/environment.ts +0 -285
  94. package/bin/commands/events.ts +0 -424
  95. package/bin/commands/firewall.ts +0 -145
  96. package/bin/commands/function.ts +0 -116
  97. package/bin/commands/generate.ts +0 -280
  98. package/bin/commands/git.ts +0 -139
  99. package/bin/commands/iam.ts +0 -464
  100. package/bin/commands/index.ts +0 -48
  101. package/bin/commands/init.ts +0 -120
  102. package/bin/commands/logs.ts +0 -148
  103. package/bin/commands/network.ts +0 -579
  104. package/bin/commands/notify.ts +0 -489
  105. package/bin/commands/queue.ts +0 -407
  106. package/bin/commands/scheduler.ts +0 -370
  107. package/bin/commands/secrets.ts +0 -54
  108. package/bin/commands/server.ts +0 -629
  109. package/bin/commands/shared.ts +0 -97
  110. package/bin/commands/ssl.ts +0 -138
  111. package/bin/commands/stack.ts +0 -325
  112. package/bin/commands/status.ts +0 -385
  113. package/bin/commands/storage.ts +0 -450
  114. package/bin/commands/team.ts +0 -96
  115. package/bin/commands/tunnel.ts +0 -489
  116. package/bin/commands/utils.ts +0 -202
  117. package/build.ts +0 -15
  118. package/cloud +0 -2
  119. package/src/aws/acm.ts +0 -768
  120. package/src/aws/application-autoscaling.ts +0 -845
  121. package/src/aws/bedrock.ts +0 -4074
  122. package/src/aws/client.ts +0 -878
  123. package/src/aws/cloudformation.ts +0 -896
  124. package/src/aws/cloudfront.ts +0 -1531
  125. package/src/aws/cloudwatch-logs.ts +0 -154
  126. package/src/aws/comprehend.ts +0 -839
  127. package/src/aws/connect.ts +0 -1056
  128. package/src/aws/deploy-imap.ts +0 -384
  129. package/src/aws/dynamodb.ts +0 -340
  130. package/src/aws/ec2.ts +0 -1385
  131. package/src/aws/ecr.ts +0 -621
  132. package/src/aws/ecs.ts +0 -615
  133. package/src/aws/elasticache.ts +0 -301
  134. package/src/aws/elbv2.ts +0 -942
  135. package/src/aws/email.ts +0 -928
  136. package/src/aws/eventbridge.ts +0 -248
  137. package/src/aws/iam.ts +0 -1689
  138. package/src/aws/imap-server.ts +0 -2100
  139. package/src/aws/lambda.ts +0 -786
  140. package/src/aws/opensearch.ts +0 -158
  141. package/src/aws/personalize.ts +0 -977
  142. package/src/aws/polly.ts +0 -559
  143. package/src/aws/rds.ts +0 -888
  144. package/src/aws/rekognition.ts +0 -846
  145. package/src/aws/route53-domains.ts +0 -359
  146. package/src/aws/route53.ts +0 -1046
  147. package/src/aws/s3.ts +0 -2318
  148. package/src/aws/scheduler.ts +0 -571
  149. package/src/aws/secrets-manager.ts +0 -769
  150. package/src/aws/ses.ts +0 -1081
  151. package/src/aws/setup-phone.ts +0 -104
  152. package/src/aws/setup-sms.ts +0 -580
  153. package/src/aws/sms.ts +0 -1735
  154. package/src/aws/smtp-server.ts +0 -531
  155. package/src/aws/sns.ts +0 -758
  156. package/src/aws/sqs.ts +0 -382
  157. package/src/aws/ssm.ts +0 -807
  158. package/src/aws/sts.ts +0 -92
  159. package/src/aws/support.ts +0 -391
  160. package/src/aws/test-imap.ts +0 -86
  161. package/src/aws/textract.ts +0 -780
  162. package/src/aws/transcribe.ts +0 -108
  163. package/src/aws/translate.ts +0 -641
  164. package/src/aws/voice.ts +0 -1379
  165. package/src/config.ts +0 -35
  166. package/src/deploy/index.ts +0 -7
  167. package/src/deploy/static-site-external-dns.ts +0 -906
  168. package/src/deploy/static-site.ts +0 -1125
  169. package/src/dns/godaddy.ts +0 -412
  170. package/src/dns/index.ts +0 -183
  171. package/src/dns/porkbun.ts +0 -362
  172. package/src/dns/route53-adapter.ts +0 -414
  173. package/src/dns/validator.ts +0 -369
  174. package/src/generators/index.ts +0 -5
  175. package/src/generators/infrastructure.ts +0 -1660
  176. package/src/push/apns.ts +0 -452
  177. package/src/push/fcm.ts +0 -506
  178. package/src/push/index.ts +0 -58
  179. package/src/ssl/acme-client.ts +0 -478
  180. package/src/ssl/index.ts +0 -7
  181. package/src/ssl/letsencrypt.ts +0 -747
  182. package/src/types.ts +0 -2
  183. package/src/utils/cli.ts +0 -398
  184. package/src/validation/index.ts +0 -5
  185. package/src/validation/template.ts +0 -405
  186. package/test/index.test.ts +0 -128
  187. package/tsconfig.json +0 -18
@@ -1,424 +0,0 @@
1
- import type { CLI } from '@stacksjs/clapp'
2
- import * as cli from '../../src/utils/cli'
3
- import { EventBridgeClient } from '../../src/aws/eventbridge'
4
- import { loadValidatedConfig } from './shared'
5
-
6
- export function registerEventsCommands(app: CLI): void {
7
- app
8
- .command('events:list', 'List all EventBridge rules')
9
- .option('--region <region>', 'AWS region')
10
- .option('--bus <name>', 'Event bus name', { default: 'default' })
11
- .action(async (options: { region?: string; bus: string }) => {
12
- cli.header('EventBridge Rules')
13
-
14
- try {
15
- const config = await loadValidatedConfig()
16
- const region = options.region || config.project.region || 'us-east-1'
17
- const eventbridge = new EventBridgeClient(region)
18
-
19
- const spinner = new cli.Spinner('Fetching rules...')
20
- spinner.start()
21
-
22
- const result = await eventbridge.listRules({ EventBusName: options.bus })
23
- const rules = result.Rules || []
24
-
25
- spinner.succeed(`Found ${rules.length} rule(s)`)
26
-
27
- if (rules.length === 0) {
28
- cli.info('No EventBridge rules found')
29
- cli.info('Use `cloud events:create` to create a new rule')
30
- return
31
- }
32
-
33
- cli.table(
34
- ['Name', 'State', 'Schedule/Pattern', 'Description'],
35
- rules.map(rule => [
36
- rule.Name || 'N/A',
37
- rule.State || 'N/A',
38
- rule.ScheduleExpression || (rule.EventPattern ? 'Event Pattern' : 'N/A'),
39
- (rule.Description || '').substring(0, 40),
40
- ]),
41
- )
42
- }
43
- catch (error: any) {
44
- cli.error(`Failed to list rules: ${error.message}`)
45
- process.exit(1)
46
- }
47
- })
48
-
49
- app
50
- .command('events:create <name>', 'Create a new EventBridge rule')
51
- .option('--region <region>', 'AWS region', { default: 'us-east-1' })
52
- .option('--bus <name>', 'Event bus name', { default: 'default' })
53
- .option('--schedule <expression>', 'Schedule expression (rate or cron)')
54
- .option('--pattern <json>', 'Event pattern JSON')
55
- .option('--pattern-file <path>', 'Event pattern from JSON file')
56
- .option('--description <text>', 'Rule description')
57
- .option('--disabled', 'Create in disabled state')
58
- .action(async (name: string, options: {
59
- region: string
60
- bus: string
61
- schedule?: string
62
- pattern?: string
63
- patternFile?: string
64
- description?: string
65
- disabled?: boolean
66
- }) => {
67
- cli.header('Create EventBridge Rule')
68
-
69
- try {
70
- if (!options.schedule && !options.pattern && !options.patternFile) {
71
- cli.error('Either --schedule or --pattern/--pattern-file is required')
72
- cli.info('\nExamples:')
73
- cli.info(' Schedule: --schedule "rate(5 minutes)"')
74
- cli.info(' Pattern: --pattern \'{"source": ["aws.ec2"]}\'')
75
- return
76
- }
77
-
78
- const eventbridge = new EventBridgeClient(options.region)
79
-
80
- let eventPattern: string | undefined
81
-
82
- if (options.patternFile) {
83
- const file = Bun.file(options.patternFile)
84
- eventPattern = await file.text()
85
- }
86
- else if (options.pattern) {
87
- eventPattern = options.pattern
88
- }
89
-
90
- cli.info(`Name: ${name}`)
91
- cli.info(`Event Bus: ${options.bus}`)
92
- if (options.schedule) {
93
- cli.info(`Schedule: ${options.schedule}`)
94
- }
95
- if (eventPattern) {
96
- cli.info(`Event Pattern: ${eventPattern}`)
97
- }
98
- cli.info(`State: ${options.disabled ? 'DISABLED' : 'ENABLED'}`)
99
-
100
- const confirmed = await cli.confirm('\nCreate this rule?', true)
101
- if (!confirmed) {
102
- cli.info('Operation cancelled')
103
- return
104
- }
105
-
106
- const spinner = new cli.Spinner('Creating rule...')
107
- spinner.start()
108
-
109
- const result = await eventbridge.putRule({
110
- Name: name,
111
- EventBusName: options.bus,
112
- ScheduleExpression: options.schedule,
113
- EventPattern: eventPattern,
114
- Description: options.description,
115
- State: options.disabled ? 'DISABLED' : 'ENABLED',
116
- })
117
-
118
- spinner.succeed('Rule created')
119
-
120
- cli.success(`\nRule ARN: ${result.RuleArn}`)
121
- cli.info('\nNote: Add targets to the rule with `cloud events:target`')
122
- }
123
- catch (error: any) {
124
- cli.error(`Failed to create rule: ${error.message}`)
125
- process.exit(1)
126
- }
127
- })
128
-
129
- app
130
- .command('events:delete <name>', 'Delete an EventBridge rule')
131
- .option('--region <region>', 'AWS region', { default: 'us-east-1' })
132
- .option('--bus <name>', 'Event bus name', { default: 'default' })
133
- .option('--force', 'Remove all targets and delete rule')
134
- .action(async (name: string, options: { region: string; bus: string; force?: boolean }) => {
135
- cli.header('Delete EventBridge Rule')
136
-
137
- try {
138
- const eventbridge = new EventBridgeClient(options.region)
139
-
140
- cli.warn(`This will delete rule: ${name}`)
141
-
142
- const confirmed = await cli.confirm('\nDelete this rule?', false)
143
- if (!confirmed) {
144
- cli.info('Operation cancelled')
145
- return
146
- }
147
-
148
- const spinner = new cli.Spinner('Checking targets...')
149
- spinner.start()
150
-
151
- // Check for targets
152
- const targets = await eventbridge.listTargetsByRule({
153
- Rule: name,
154
- EventBusName: options.bus,
155
- })
156
-
157
- if (targets.Targets && targets.Targets.length > 0) {
158
- if (!options.force) {
159
- spinner.fail('Rule has targets')
160
- cli.info(`\nThe rule has ${targets.Targets.length} target(s).`)
161
- cli.info('Use --force to remove targets and delete the rule.')
162
- return
163
- }
164
-
165
- spinner.text = 'Removing targets...'
166
-
167
- await eventbridge.removeTargets({
168
- Rule: name,
169
- EventBusName: options.bus,
170
- Ids: targets.Targets.map(t => t.Id!),
171
- })
172
- }
173
-
174
- spinner.text = 'Deleting rule...'
175
-
176
- await eventbridge.deleteRule({
177
- Name: name,
178
- EventBusName: options.bus,
179
- })
180
-
181
- spinner.succeed('Rule deleted')
182
- }
183
- catch (error: any) {
184
- cli.error(`Failed to delete rule: ${error.message}`)
185
- process.exit(1)
186
- }
187
- })
188
-
189
- app
190
- .command('events:describe <name>', 'Show EventBridge rule details')
191
- .option('--region <region>', 'AWS region', { default: 'us-east-1' })
192
- .option('--bus <name>', 'Event bus name', { default: 'default' })
193
- .action(async (name: string, options: { region: string; bus: string }) => {
194
- cli.header(`Rule: ${name}`)
195
-
196
- try {
197
- const eventbridge = new EventBridgeClient(options.region)
198
-
199
- const spinner = new cli.Spinner('Fetching rule...')
200
- spinner.start()
201
-
202
- const rule = await eventbridge.describeRule({
203
- Name: name,
204
- EventBusName: options.bus,
205
- })
206
-
207
- if (!rule) {
208
- spinner.fail('Rule not found')
209
- return
210
- }
211
-
212
- // Get targets
213
- const targets = await eventbridge.listTargetsByRule({
214
- Rule: name,
215
- EventBusName: options.bus,
216
- })
217
-
218
- spinner.succeed('Rule loaded')
219
-
220
- cli.info('\nRule Information:')
221
- cli.info(` Name: ${rule.Name}`)
222
- cli.info(` ARN: ${rule.Arn}`)
223
- cli.info(` State: ${rule.State}`)
224
- cli.info(` Event Bus: ${rule.EventBusName}`)
225
-
226
- if (rule.Description) {
227
- cli.info(` Description: ${rule.Description}`)
228
- }
229
-
230
- if (rule.ScheduleExpression) {
231
- cli.info(`\nSchedule Expression: ${rule.ScheduleExpression}`)
232
- }
233
-
234
- if (rule.EventPattern) {
235
- cli.info('\nEvent Pattern:')
236
- console.log(JSON.stringify(JSON.parse(rule.EventPattern), null, 2))
237
- }
238
-
239
- if (targets.Targets && targets.Targets.length > 0) {
240
- cli.info(`\nTargets (${targets.Targets.length}):`)
241
- for (const target of targets.Targets) {
242
- cli.info(` - ${target.Id}: ${target.Arn}`)
243
- if (target.Input) {
244
- cli.info(` Input: ${target.Input}`)
245
- }
246
- }
247
- }
248
- else {
249
- cli.info('\nNo targets configured.')
250
- }
251
- }
252
- catch (error: any) {
253
- cli.error(`Failed to get rule: ${error.message}`)
254
- process.exit(1)
255
- }
256
- })
257
-
258
- app
259
- .command('events:target <ruleName>', 'Add a target to an EventBridge rule')
260
- .option('--region <region>', 'AWS region', { default: 'us-east-1' })
261
- .option('--bus <name>', 'Event bus name', { default: 'default' })
262
- .option('--id <id>', 'Target ID')
263
- .option('--arn <arn>', 'Target ARN (Lambda, SQS, SNS, etc.)')
264
- .option('--role <arn>', 'IAM role ARN (for some targets)')
265
- .option('--input <json>', 'Constant JSON input')
266
- .option('--input-path <path>', 'JSONPath expression for input')
267
- .action(async (ruleName: string, options: {
268
- region: string
269
- bus: string
270
- id?: string
271
- arn?: string
272
- role?: string
273
- input?: string
274
- inputPath?: string
275
- }) => {
276
- cli.header('Add EventBridge Target')
277
-
278
- try {
279
- if (!options.arn) {
280
- cli.error('--arn is required')
281
- return
282
- }
283
-
284
- const eventbridge = new EventBridgeClient(options.region)
285
-
286
- const targetId = options.id || `target-${Date.now()}`
287
-
288
- cli.info(`Rule: ${ruleName}`)
289
- cli.info(`Target ID: ${targetId}`)
290
- cli.info(`Target ARN: ${options.arn}`)
291
-
292
- const confirmed = await cli.confirm('\nAdd this target?', true)
293
- if (!confirmed) {
294
- cli.info('Operation cancelled')
295
- return
296
- }
297
-
298
- const spinner = new cli.Spinner('Adding target...')
299
- spinner.start()
300
-
301
- const target: any = {
302
- Id: targetId,
303
- Arn: options.arn,
304
- }
305
-
306
- if (options.role) {
307
- target.RoleArn = options.role
308
- }
309
-
310
- if (options.input) {
311
- target.Input = options.input
312
- }
313
-
314
- if (options.inputPath) {
315
- target.InputPath = options.inputPath
316
- }
317
-
318
- await eventbridge.putTargets({
319
- Rule: ruleName,
320
- EventBusName: options.bus,
321
- Targets: [target],
322
- })
323
-
324
- spinner.succeed('Target added')
325
-
326
- cli.success(`\nTarget ${targetId} added to rule ${ruleName}`)
327
- }
328
- catch (error: any) {
329
- cli.error(`Failed to add target: ${error.message}`)
330
- process.exit(1)
331
- }
332
- })
333
-
334
- app
335
- .command('events:buses', 'List event buses')
336
- .option('--region <region>', 'AWS region')
337
- .action(async (options: { region?: string }) => {
338
- cli.header('Event Buses')
339
-
340
- try {
341
- const config = await loadValidatedConfig()
342
- const region = options.region || config.project.region || 'us-east-1'
343
- const eventbridge = new EventBridgeClient(region)
344
-
345
- const spinner = new cli.Spinner('Fetching event buses...')
346
- spinner.start()
347
-
348
- const result = await eventbridge.listEventBuses()
349
- const buses = result.EventBuses || []
350
-
351
- spinner.succeed(`Found ${buses.length} event bus(es)`)
352
-
353
- if (buses.length === 0) {
354
- cli.info('No event buses found')
355
- return
356
- }
357
-
358
- cli.table(
359
- ['Name', 'ARN', 'Policy'],
360
- buses.map(bus => [
361
- bus.Name || 'N/A',
362
- bus.Arn || 'N/A',
363
- bus.Policy ? 'Custom' : 'Default',
364
- ]),
365
- )
366
- }
367
- catch (error: any) {
368
- cli.error(`Failed to list event buses: ${error.message}`)
369
- process.exit(1)
370
- }
371
- })
372
-
373
- app
374
- .command('events:enable <name>', 'Enable an EventBridge rule')
375
- .option('--region <region>', 'AWS region', { default: 'us-east-1' })
376
- .option('--bus <name>', 'Event bus name', { default: 'default' })
377
- .action(async (name: string, options: { region: string; bus: string }) => {
378
- cli.header('Enable EventBridge Rule')
379
-
380
- try {
381
- const eventbridge = new EventBridgeClient(options.region)
382
-
383
- const spinner = new cli.Spinner('Enabling rule...')
384
- spinner.start()
385
-
386
- await eventbridge.enableRule({
387
- Name: name,
388
- EventBusName: options.bus,
389
- })
390
-
391
- spinner.succeed('Rule enabled')
392
- }
393
- catch (error: any) {
394
- cli.error(`Failed to enable rule: ${error.message}`)
395
- process.exit(1)
396
- }
397
- })
398
-
399
- app
400
- .command('events:disable <name>', 'Disable an EventBridge rule')
401
- .option('--region <region>', 'AWS region', { default: 'us-east-1' })
402
- .option('--bus <name>', 'Event bus name', { default: 'default' })
403
- .action(async (name: string, options: { region: string; bus: string }) => {
404
- cli.header('Disable EventBridge Rule')
405
-
406
- try {
407
- const eventbridge = new EventBridgeClient(options.region)
408
-
409
- const spinner = new cli.Spinner('Disabling rule...')
410
- spinner.start()
411
-
412
- await eventbridge.disableRule({
413
- Name: name,
414
- EventBusName: options.bus,
415
- })
416
-
417
- spinner.succeed('Rule disabled')
418
- }
419
- catch (error: any) {
420
- cli.error(`Failed to disable rule: ${error.message}`)
421
- process.exit(1)
422
- }
423
- })
424
- }
@@ -1,145 +0,0 @@
1
- import type { CLI } from '@stacksjs/clapp'
2
- import * as cli from '../../src/utils/cli'
3
-
4
- export function registerFirewallCommands(app: CLI): void {
5
- app
6
- .command('firewall:rules', 'List WAF rules')
7
- .option('--env <environment>', 'Environment (production, staging, development)')
8
- .action(async (options?: { env?: string }) => {
9
- cli.header('WAF Rules')
10
-
11
- const environment = options?.env || 'production'
12
-
13
- cli.info(`Environment: ${environment}\n`)
14
-
15
- cli.table(
16
- ['Rule', 'Priority', 'Action', 'Requests Blocked'],
17
- [
18
- ['Rate Limit', '1', 'Block', '1,234'],
19
- ['Geo Block (CN, RU)', '2', 'Block', '567'],
20
- ['SQL Injection', '3', 'Block', '89'],
21
- ['XSS Prevention', '4', 'Block', '23'],
22
- ],
23
- )
24
- })
25
-
26
- app
27
- .command('firewall:block <ip>', 'Block an IP address')
28
- .option('--reason <reason>', 'Reason for blocking')
29
- .action(async (ip: string, options?: { reason?: string }) => {
30
- cli.header(`Blocking IP Address`)
31
-
32
- const reason = options?.reason || 'Manual block'
33
-
34
- cli.info(`IP: ${ip}`)
35
- cli.info(`Reason: ${reason}`)
36
-
37
- const confirm = await cli.confirm('\nBlock this IP address?', true)
38
- if (!confirm) {
39
- cli.info('Operation cancelled')
40
- return
41
- }
42
-
43
- const spinner = new cli.Spinner('Adding IP to WAF block list...')
44
- spinner.start()
45
-
46
- // TODO: Add IP to WAF IP set
47
- await new Promise(resolve => setTimeout(resolve, 2000))
48
-
49
- spinner.succeed(`IP ${ip} blocked successfully`)
50
-
51
- cli.success('\nIP blocked!')
52
- cli.info('The IP address will be blocked within 60 seconds')
53
- })
54
-
55
- app
56
- .command('firewall:unblock <ip>', 'Unblock an IP address')
57
- .action(async (ip: string) => {
58
- cli.header(`Unblocking IP Address`)
59
-
60
- cli.info(`IP: ${ip}`)
61
-
62
- const confirm = await cli.confirm('\nUnblock this IP address?', true)
63
- if (!confirm) {
64
- cli.info('Operation cancelled')
65
- return
66
- }
67
-
68
- const spinner = new cli.Spinner('Removing IP from WAF block list...')
69
- spinner.start()
70
-
71
- // TODO: Remove IP from WAF IP set
72
- await new Promise(resolve => setTimeout(resolve, 2000))
73
-
74
- spinner.succeed(`IP ${ip} unblocked successfully`)
75
-
76
- cli.success('\nIP unblocked!')
77
- })
78
-
79
- app
80
- .command('firewall:countries', 'Manage geo-blocking')
81
- .option('--add <countries>', 'Comma-separated country codes to block (e.g., CN,RU)')
82
- .option('--remove <countries>', 'Comma-separated country codes to unblock')
83
- .option('--list', 'List currently blocked countries')
84
- .action(async (options?: { add?: string, remove?: string, list?: boolean }) => {
85
- cli.header('Geo-Blocking Management')
86
-
87
- if (options?.list) {
88
- cli.info('Currently blocked countries:\n')
89
- cli.table(
90
- ['Country Code', 'Country Name', 'Blocked Since'],
91
- [
92
- ['CN', 'China', '2024-01-15'],
93
- ['RU', 'Russia', '2024-01-15'],
94
- ['KP', 'North Korea', '2024-01-10'],
95
- ],
96
- )
97
- }
98
- else if (options?.add) {
99
- const countries = options.add.split(',').map(c => c.trim().toUpperCase())
100
-
101
- cli.info(`Countries to block: ${countries.join(', ')}`)
102
-
103
- const confirm = await cli.confirm('\nBlock these countries?', true)
104
- if (!confirm) {
105
- cli.info('Operation cancelled')
106
- return
107
- }
108
-
109
- const spinner = new cli.Spinner('Updating geo-blocking rules...')
110
- spinner.start()
111
-
112
- // TODO: Update WAF geo match statement
113
- await new Promise(resolve => setTimeout(resolve, 2000))
114
-
115
- spinner.succeed('Geo-blocking rules updated')
116
-
117
- cli.success('\nCountries blocked!')
118
- }
119
- else if (options?.remove) {
120
- const countries = options.remove.split(',').map(c => c.trim().toUpperCase())
121
-
122
- cli.info(`Countries to unblock: ${countries.join(', ')}`)
123
-
124
- const confirm = await cli.confirm('\nUnblock these countries?', true)
125
- if (!confirm) {
126
- cli.info('Operation cancelled')
127
- return
128
- }
129
-
130
- const spinner = new cli.Spinner('Updating geo-blocking rules...')
131
- spinner.start()
132
-
133
- // TODO: Update WAF geo match statement
134
- await new Promise(resolve => setTimeout(resolve, 2000))
135
-
136
- spinner.succeed('Geo-blocking rules updated')
137
-
138
- cli.success('\nCountries unblocked!')
139
- }
140
- else {
141
- cli.info('Use --list, --add, or --remove options')
142
- cli.info('Example: cloud firewall:countries --add CN,RU')
143
- }
144
- })
145
- }
@@ -1,116 +0,0 @@
1
- import type { CLI } from '@stacksjs/clapp'
2
- import * as cli from '../../src/utils/cli'
3
-
4
- export function registerFunctionCommands(app: CLI): void {
5
- app
6
- .command('function:list', 'List all Lambda functions')
7
- .action(async () => {
8
- cli.header('Listing Functions')
9
-
10
- const functions = [
11
- ['api-handler', '128 MB', '30s', '15', 'nodejs20.x'],
12
- ['worker', '512 MB', '60s', '3', 'nodejs20.x'],
13
- ]
14
-
15
- cli.table(
16
- ['Name', 'Memory', 'Timeout', 'Invocations (24h)', 'Runtime'],
17
- functions,
18
- )
19
- })
20
-
21
- app
22
- .command('function:logs <name>', 'View function logs')
23
- .option('--tail', 'Tail logs in real-time')
24
- .option('--filter <pattern>', 'Filter logs by pattern')
25
- .action(async (name: string) => {
26
- cli.header(`Logs for ${name}`)
27
- cli.info('Streaming logs...')
28
- // TODO: Implement log streaming
29
- })
30
-
31
- app
32
- .command('function:invoke <name>', 'Test function invocation')
33
- .option('--payload <json>', 'Event payload as JSON')
34
- .action(async (name: string, options?: { payload?: string }) => {
35
- cli.header(`Invoking ${name}`)
36
-
37
- const spinner = new cli.Spinner('Invoking function...')
38
- spinner.start()
39
-
40
- // TODO: Implement invocation
41
- await new Promise(resolve => setTimeout(resolve, 1000))
42
-
43
- spinner.succeed('Function invoked successfully')
44
- })
45
-
46
- app
47
- .command('function:create <name>', 'Create a new Lambda function')
48
- .option('--runtime <runtime>', 'Runtime (nodejs20.x, python3.12, etc.)', { default: 'nodejs20.x' })
49
- .option('--memory <mb>', 'Memory allocation in MB', { default: '128' })
50
- .option('--timeout <seconds>', 'Timeout in seconds', { default: '30' })
51
- .option('--handler <handler>', 'Function handler', { default: 'index.handler' })
52
- .action(async (name: string, options?: { runtime?: string, memory?: string, timeout?: string, handler?: string }) => {
53
- cli.header(`Creating Lambda Function: ${name}`)
54
-
55
- const runtime = options?.runtime || 'nodejs20.x'
56
- const memory = options?.memory || '128'
57
- const timeout = options?.timeout || '30'
58
- const handler = options?.handler || 'index.handler'
59
-
60
- cli.info(`Runtime: ${runtime}`)
61
- cli.info(`Memory: ${memory} MB`)
62
- cli.info(`Timeout: ${timeout}s`)
63
- cli.info(`Handler: ${handler}`)
64
-
65
- const spinner = new cli.Spinner('Creating function...')
66
- spinner.start()
67
-
68
- // TODO: Create function directory structure
69
- // TODO: Generate basic function code
70
- // TODO: Create IAM role for function
71
- // TODO: Package and upload to Lambda
72
-
73
- await new Promise(resolve => setTimeout(resolve, 2000))
74
-
75
- spinner.succeed(`Function ${name} created successfully`)
76
-
77
- cli.success('\nFunction created!')
78
- cli.info('\nNext steps:')
79
- cli.info(` - Edit the function code in functions/${name}/index.js`)
80
- cli.info(` - cloud function:deploy ${name} - Deploy the function`)
81
- cli.info(` - cloud function:invoke ${name} - Test the function`)
82
- })
83
-
84
- app
85
- .command('function:deploy <name>', 'Deploy specific Lambda function')
86
- .option('--env <environment>', 'Environment (production, staging, development)')
87
- .action(async (name: string, options?: { env?: string }) => {
88
- cli.header(`Deploying Function: ${name}`)
89
-
90
- const environment = options?.env || 'production'
91
-
92
- cli.info(`Environment: ${environment}`)
93
-
94
- const spinner = new cli.Spinner('Packaging function...')
95
- spinner.start()
96
-
97
- // TODO: Package function code
98
- // TODO: Upload to S3
99
- // TODO: Update Lambda function code
100
- // TODO: Publish new version
101
-
102
- spinner.text = 'Uploading to Lambda...'
103
- await new Promise(resolve => setTimeout(resolve, 1500))
104
-
105
- spinner.text = 'Updating function configuration...'
106
- await new Promise(resolve => setTimeout(resolve, 1000))
107
-
108
- spinner.succeed(`Function ${name} deployed successfully`)
109
-
110
- cli.success('\nDeployment complete!')
111
- cli.info('\nFunction details:')
112
- cli.info(` - ARN: arn:aws:lambda:us-east-1:123456789:function:${name}`)
113
- cli.info(` - Version: $LATEST`)
114
- cli.info(` - Last Modified: ${new Date().toISOString()}`)
115
- })
116
- }