@stacksjs/ts-cloud 0.1.2 → 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.
- package/README.md +98 -13
- package/dist/aws/acm.d.ts +129 -0
- package/dist/aws/application-autoscaling.d.ts +282 -0
- package/dist/aws/bedrock.d.ts +2292 -0
- package/dist/aws/client.d.ts +79 -0
- package/dist/aws/cloudformation.d.ts +105 -0
- package/dist/aws/cloudfront.d.ts +265 -0
- package/dist/aws/cloudwatch-logs.d.ts +48 -0
- package/dist/aws/comprehend.d.ts +505 -0
- package/dist/aws/connect.d.ts +377 -0
- package/dist/aws/deploy-imap.d.ts +14 -0
- package/dist/aws/dynamodb.d.ts +176 -0
- package/dist/aws/ec2.d.ts +272 -0
- package/dist/aws/ecr.d.ts +149 -0
- package/dist/aws/ecs.d.ts +162 -0
- package/dist/aws/elasticache.d.ts +71 -0
- package/dist/aws/elbv2.d.ts +248 -0
- package/dist/aws/email.d.ts +175 -0
- package/dist/aws/eventbridge.d.ts +142 -0
- package/dist/aws/iam.d.ts +638 -0
- package/dist/aws/imap-server.d.ts +119 -0
- package/{src/aws/index.ts → dist/aws/index.d.ts} +62 -83
- package/{src/aws/kendra.ts → dist/aws/kendra.d.ts} +71 -386
- package/dist/aws/lambda.d.ts +232 -0
- package/dist/aws/opensearch.d.ts +87 -0
- package/dist/aws/personalize.d.ts +516 -0
- package/dist/aws/polly.d.ts +214 -0
- package/dist/aws/rds.d.ts +240 -0
- package/dist/aws/rekognition.d.ts +543 -0
- package/dist/aws/route53-domains.d.ts +113 -0
- package/dist/aws/route53.d.ts +215 -0
- package/dist/aws/s3.d.ts +212 -0
- package/dist/aws/scheduler.d.ts +140 -0
- package/dist/aws/secrets-manager.d.ts +170 -0
- package/dist/aws/ses.d.ts +288 -0
- package/dist/aws/setup-phone.d.ts +0 -0
- package/dist/aws/setup-sms.d.ts +115 -0
- package/dist/aws/sms.d.ts +304 -0
- package/dist/aws/smtp-server.d.ts +61 -0
- package/dist/aws/sns.d.ts +117 -0
- package/dist/aws/sqs.d.ts +65 -0
- package/dist/aws/ssm.d.ts +179 -0
- package/dist/aws/sts.d.ts +15 -0
- package/dist/aws/support.d.ts +104 -0
- package/dist/aws/test-imap.d.ts +0 -0
- package/dist/aws/textract.d.ts +403 -0
- package/dist/aws/transcribe.d.ts +60 -0
- package/dist/aws/translate.d.ts +358 -0
- package/dist/aws/voice.d.ts +219 -0
- package/dist/bin/cli.js +1724 -0
- package/dist/config.d.ts +7 -0
- package/dist/deploy/index.d.ts +2 -0
- package/dist/deploy/static-site-external-dns.d.ts +51 -0
- package/dist/deploy/static-site.d.ts +71 -0
- package/dist/dns/cloudflare.d.ts +52 -0
- package/dist/dns/godaddy.d.ts +38 -0
- package/dist/dns/index.d.ts +45 -0
- package/dist/dns/porkbun.d.ts +18 -0
- package/dist/dns/route53-adapter.d.ts +38 -0
- package/{src/dns/types.ts → dist/dns/types.d.ts} +26 -63
- package/dist/dns/validator.d.ts +78 -0
- package/dist/generators/index.d.ts +1 -0
- package/dist/generators/infrastructure.d.ts +30 -0
- package/{src/index.ts → dist/index.d.ts} +70 -93
- package/dist/index.js +7881 -0
- package/dist/push/apns.d.ts +60 -0
- package/dist/push/fcm.d.ts +117 -0
- package/dist/push/index.d.ts +14 -0
- package/dist/security/pre-deploy-scanner.d.ts +69 -0
- package/dist/ssl/acme-client.d.ts +67 -0
- package/dist/ssl/index.d.ts +2 -0
- package/dist/ssl/letsencrypt.d.ts +48 -0
- package/dist/types.d.ts +1 -0
- package/dist/utils/cli.d.ts +123 -0
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/template.d.ts +23 -0
- package/package.json +8 -8
- package/bin/cli.ts +0 -133
- package/bin/commands/analytics.ts +0 -328
- package/bin/commands/api.ts +0 -379
- package/bin/commands/assets.ts +0 -221
- package/bin/commands/audit.ts +0 -501
- package/bin/commands/backup.ts +0 -682
- package/bin/commands/cache.ts +0 -294
- package/bin/commands/cdn.ts +0 -281
- package/bin/commands/config.ts +0 -202
- package/bin/commands/container.ts +0 -105
- package/bin/commands/cost.ts +0 -208
- package/bin/commands/database.ts +0 -401
- package/bin/commands/deploy.ts +0 -674
- package/bin/commands/domain.ts +0 -397
- package/bin/commands/email.ts +0 -423
- package/bin/commands/environment.ts +0 -285
- package/bin/commands/events.ts +0 -424
- package/bin/commands/firewall.ts +0 -145
- package/bin/commands/function.ts +0 -116
- package/bin/commands/generate.ts +0 -280
- package/bin/commands/git.ts +0 -139
- package/bin/commands/iam.ts +0 -464
- package/bin/commands/index.ts +0 -48
- package/bin/commands/init.ts +0 -120
- package/bin/commands/logs.ts +0 -148
- package/bin/commands/network.ts +0 -579
- package/bin/commands/notify.ts +0 -489
- package/bin/commands/queue.ts +0 -407
- package/bin/commands/scheduler.ts +0 -370
- package/bin/commands/secrets.ts +0 -54
- package/bin/commands/server.ts +0 -629
- package/bin/commands/shared.ts +0 -97
- package/bin/commands/ssl.ts +0 -138
- package/bin/commands/stack.ts +0 -325
- package/bin/commands/status.ts +0 -385
- package/bin/commands/storage.ts +0 -450
- package/bin/commands/team.ts +0 -96
- package/bin/commands/tunnel.ts +0 -489
- package/bin/commands/utils.ts +0 -202
- package/build.ts +0 -15
- package/cloud +0 -2
- package/src/aws/acm.ts +0 -768
- package/src/aws/application-autoscaling.ts +0 -845
- package/src/aws/bedrock.ts +0 -4074
- package/src/aws/client.ts +0 -878
- package/src/aws/cloudformation.ts +0 -896
- package/src/aws/cloudfront.ts +0 -1531
- package/src/aws/cloudwatch-logs.ts +0 -154
- package/src/aws/comprehend.ts +0 -839
- package/src/aws/connect.ts +0 -1056
- package/src/aws/deploy-imap.ts +0 -384
- package/src/aws/dynamodb.ts +0 -340
- package/src/aws/ec2.ts +0 -1385
- package/src/aws/ecr.ts +0 -621
- package/src/aws/ecs.ts +0 -615
- package/src/aws/elasticache.ts +0 -301
- package/src/aws/elbv2.ts +0 -942
- package/src/aws/email.ts +0 -928
- package/src/aws/eventbridge.ts +0 -248
- package/src/aws/iam.ts +0 -1689
- package/src/aws/imap-server.ts +0 -2100
- package/src/aws/lambda.ts +0 -786
- package/src/aws/opensearch.ts +0 -158
- package/src/aws/personalize.ts +0 -977
- package/src/aws/polly.ts +0 -559
- package/src/aws/rds.ts +0 -888
- package/src/aws/rekognition.ts +0 -846
- package/src/aws/route53-domains.ts +0 -359
- package/src/aws/route53.ts +0 -1046
- package/src/aws/s3.ts +0 -2318
- package/src/aws/scheduler.ts +0 -571
- package/src/aws/secrets-manager.ts +0 -769
- package/src/aws/ses.ts +0 -1081
- package/src/aws/setup-phone.ts +0 -104
- package/src/aws/setup-sms.ts +0 -580
- package/src/aws/sms.ts +0 -1735
- package/src/aws/smtp-server.ts +0 -531
- package/src/aws/sns.ts +0 -758
- package/src/aws/sqs.ts +0 -382
- package/src/aws/ssm.ts +0 -807
- package/src/aws/sts.ts +0 -92
- package/src/aws/support.ts +0 -391
- package/src/aws/test-imap.ts +0 -86
- package/src/aws/textract.ts +0 -780
- package/src/aws/transcribe.ts +0 -108
- package/src/aws/translate.ts +0 -641
- package/src/aws/voice.ts +0 -1379
- package/src/config.ts +0 -35
- package/src/deploy/index.ts +0 -7
- package/src/deploy/static-site-external-dns.ts +0 -906
- package/src/deploy/static-site.ts +0 -1125
- package/src/dns/godaddy.ts +0 -412
- package/src/dns/index.ts +0 -183
- package/src/dns/porkbun.ts +0 -362
- package/src/dns/route53-adapter.ts +0 -414
- package/src/dns/validator.ts +0 -369
- package/src/generators/index.ts +0 -5
- package/src/generators/infrastructure.ts +0 -1660
- package/src/push/apns.ts +0 -452
- package/src/push/fcm.ts +0 -506
- package/src/push/index.ts +0 -58
- package/src/ssl/acme-client.ts +0 -478
- package/src/ssl/index.ts +0 -7
- package/src/ssl/letsencrypt.ts +0 -747
- package/src/types.ts +0 -2
- package/src/utils/cli.ts +0 -398
- package/src/validation/index.ts +0 -5
- package/src/validation/template.ts +0 -405
- package/test/index.test.ts +0 -128
- package/tsconfig.json +0 -18
package/bin/commands/cache.ts
DELETED
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import type { CLI } from '@stacksjs/clapp'
|
|
2
|
-
import * as cli from '../../src/utils/cli'
|
|
3
|
-
import { ElastiCacheClient } from '../../src/aws/elasticache'
|
|
4
|
-
import { loadValidatedConfig } from './shared'
|
|
5
|
-
|
|
6
|
-
export function registerCacheCommands(app: CLI): void {
|
|
7
|
-
app
|
|
8
|
-
.command('cache:list', 'List all ElastiCache clusters')
|
|
9
|
-
.option('--region <region>', 'AWS region')
|
|
10
|
-
.action(async (options: { region?: string }) => {
|
|
11
|
-
cli.header('ElastiCache Clusters')
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const config = await loadValidatedConfig()
|
|
15
|
-
const region = options.region || config.project.region || 'us-east-1'
|
|
16
|
-
const elasticache = new ElastiCacheClient(region)
|
|
17
|
-
|
|
18
|
-
const spinner = new cli.Spinner('Fetching clusters...')
|
|
19
|
-
spinner.start()
|
|
20
|
-
|
|
21
|
-
const result = await elasticache.describeCacheClusters()
|
|
22
|
-
const clusters = result.CacheClusters || []
|
|
23
|
-
|
|
24
|
-
spinner.succeed(`Found ${clusters.length} cluster(s)`)
|
|
25
|
-
|
|
26
|
-
if (clusters.length === 0) {
|
|
27
|
-
cli.info('No ElastiCache clusters found')
|
|
28
|
-
cli.info('Use `cloud cache:create` to create a new cluster')
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
cli.table(
|
|
33
|
-
['Cluster ID', 'Engine', 'Node Type', 'Nodes', 'Status'],
|
|
34
|
-
clusters.map(cluster => [
|
|
35
|
-
cluster.CacheClusterId || 'N/A',
|
|
36
|
-
`${cluster.Engine || 'N/A'} ${cluster.EngineVersion || ''}`,
|
|
37
|
-
cluster.CacheNodeType || 'N/A',
|
|
38
|
-
(cluster.NumCacheNodes || 0).toString(),
|
|
39
|
-
cluster.CacheClusterStatus || 'N/A',
|
|
40
|
-
]),
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
catch (error: any) {
|
|
44
|
-
cli.error(`Failed to list clusters: ${error.message}`)
|
|
45
|
-
process.exit(1)
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
app
|
|
50
|
-
.command('cache:create <name>', 'Create a new ElastiCache cluster')
|
|
51
|
-
.option('--engine <engine>', 'Cache engine (redis or memcached)', { default: 'redis' })
|
|
52
|
-
.option('--node-type <type>', 'Node instance type', { default: 'cache.t3.micro' })
|
|
53
|
-
.option('--nodes <number>', 'Number of cache nodes', { default: '1' })
|
|
54
|
-
.option('--region <region>', 'AWS region', { default: 'us-east-1' })
|
|
55
|
-
.option('--version <version>', 'Engine version')
|
|
56
|
-
.action(async (name: string, options: { engine: string; nodeType: string; nodes: string; region: string; version?: string }) => {
|
|
57
|
-
cli.header('Create ElastiCache Cluster')
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
const elasticache = new ElastiCacheClient(options.region)
|
|
61
|
-
|
|
62
|
-
cli.info(`Cluster ID: ${name}`)
|
|
63
|
-
cli.info(`Engine: ${options.engine}`)
|
|
64
|
-
cli.info(`Node Type: ${options.nodeType}`)
|
|
65
|
-
cli.info(`Number of Nodes: ${options.nodes}`)
|
|
66
|
-
cli.info(`Region: ${options.region}`)
|
|
67
|
-
|
|
68
|
-
const confirmed = await cli.confirm('\nCreate this cluster?', true)
|
|
69
|
-
if (!confirmed) {
|
|
70
|
-
cli.info('Operation cancelled')
|
|
71
|
-
return
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const spinner = new cli.Spinner('Creating cluster...')
|
|
75
|
-
spinner.start()
|
|
76
|
-
|
|
77
|
-
await elasticache.createCacheCluster({
|
|
78
|
-
cacheClusterId: name,
|
|
79
|
-
engine: options.engine as 'redis' | 'memcached',
|
|
80
|
-
cacheNodeType: options.nodeType,
|
|
81
|
-
numCacheNodes: Number.parseInt(options.nodes),
|
|
82
|
-
engineVersion: options.version,
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
spinner.succeed('Cluster creation initiated')
|
|
86
|
-
|
|
87
|
-
cli.success(`\nCluster: ${name}`)
|
|
88
|
-
cli.info('Status: creating')
|
|
89
|
-
cli.info('\nNote: Cluster creation may take several minutes.')
|
|
90
|
-
cli.info('Use `cloud cache:list` to check status.')
|
|
91
|
-
}
|
|
92
|
-
catch (error: any) {
|
|
93
|
-
cli.error(`Failed to create cluster: ${error.message}`)
|
|
94
|
-
process.exit(1)
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
app
|
|
99
|
-
.command('cache:delete <clusterId>', 'Delete an ElastiCache cluster')
|
|
100
|
-
.option('--region <region>', 'AWS region', { default: 'us-east-1' })
|
|
101
|
-
.action(async (clusterId: string, options: { region: string }) => {
|
|
102
|
-
cli.header('Delete ElastiCache Cluster')
|
|
103
|
-
|
|
104
|
-
try {
|
|
105
|
-
const elasticache = new ElastiCacheClient(options.region)
|
|
106
|
-
|
|
107
|
-
cli.warn(`This will permanently delete cluster: ${clusterId}`)
|
|
108
|
-
cli.warn('All data in the cluster will be lost!')
|
|
109
|
-
|
|
110
|
-
const confirmed = await cli.confirm('\nDelete this cluster?', false)
|
|
111
|
-
if (!confirmed) {
|
|
112
|
-
cli.info('Operation cancelled')
|
|
113
|
-
return
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const spinner = new cli.Spinner('Deleting cluster...')
|
|
117
|
-
spinner.start()
|
|
118
|
-
|
|
119
|
-
await elasticache.deleteCacheCluster(clusterId)
|
|
120
|
-
|
|
121
|
-
spinner.succeed('Cluster deletion initiated')
|
|
122
|
-
|
|
123
|
-
cli.info('\nNote: Cluster deletion may take several minutes.')
|
|
124
|
-
}
|
|
125
|
-
catch (error: any) {
|
|
126
|
-
cli.error(`Failed to delete cluster: ${error.message}`)
|
|
127
|
-
process.exit(1)
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
app
|
|
132
|
-
.command('cache:stats <clusterId>', 'Show ElastiCache cluster statistics')
|
|
133
|
-
.option('--region <region>', 'AWS region', { default: 'us-east-1' })
|
|
134
|
-
.action(async (clusterId: string, options: { region: string }) => {
|
|
135
|
-
cli.header(`ElastiCache Stats: ${clusterId}`)
|
|
136
|
-
|
|
137
|
-
try {
|
|
138
|
-
const elasticache = new ElastiCacheClient(options.region)
|
|
139
|
-
|
|
140
|
-
const spinner = new cli.Spinner('Fetching cluster details...')
|
|
141
|
-
spinner.start()
|
|
142
|
-
|
|
143
|
-
const result = await elasticache.describeCacheClusters(clusterId)
|
|
144
|
-
|
|
145
|
-
const cluster = result.CacheClusters?.[0]
|
|
146
|
-
|
|
147
|
-
if (!cluster) {
|
|
148
|
-
spinner.fail('Cluster not found')
|
|
149
|
-
return
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
spinner.succeed('Cluster details loaded')
|
|
153
|
-
|
|
154
|
-
cli.info('\nCluster Information:')
|
|
155
|
-
cli.info(` Cluster ID: ${cluster.CacheClusterId}`)
|
|
156
|
-
cli.info(` Engine: ${cluster.Engine} ${cluster.EngineVersion}`)
|
|
157
|
-
cli.info(` Node Type: ${cluster.CacheNodeType}`)
|
|
158
|
-
cli.info(` Status: ${cluster.CacheClusterStatus}`)
|
|
159
|
-
cli.info(` Nodes: ${cluster.NumCacheNodes}`)
|
|
160
|
-
cli.info(` Availability Zone: ${cluster.PreferredAvailabilityZone || 'Not set'}`)
|
|
161
|
-
|
|
162
|
-
if (cluster.CacheNodes && cluster.CacheNodes.length > 0) {
|
|
163
|
-
cli.info('\nCache Nodes:')
|
|
164
|
-
for (const node of cluster.CacheNodes) {
|
|
165
|
-
cli.info(` - ${node.CacheNodeId}: ${node.CacheNodeStatus}`)
|
|
166
|
-
if (node.Endpoint) {
|
|
167
|
-
cli.info(` Endpoint: ${node.Endpoint.Address}:${node.Endpoint.Port}`)
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
catch (error: any) {
|
|
173
|
-
cli.error(`Failed to get cluster stats: ${error.message}`)
|
|
174
|
-
process.exit(1)
|
|
175
|
-
}
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
app
|
|
179
|
-
.command('cache:flush <clusterId>', 'Flush all data from a Redis cluster')
|
|
180
|
-
.option('--region <region>', 'AWS region', { default: 'us-east-1' })
|
|
181
|
-
.action(async (clusterId: string, options: { region: string }) => {
|
|
182
|
-
cli.header('Flush ElastiCache Cluster')
|
|
183
|
-
|
|
184
|
-
try {
|
|
185
|
-
const elasticache = new ElastiCacheClient(options.region)
|
|
186
|
-
|
|
187
|
-
// First get cluster info to get the endpoint
|
|
188
|
-
const spinner = new cli.Spinner('Getting cluster endpoint...')
|
|
189
|
-
spinner.start()
|
|
190
|
-
|
|
191
|
-
const result = await elasticache.describeCacheClusters(clusterId)
|
|
192
|
-
|
|
193
|
-
const cluster = result.CacheClusters?.[0]
|
|
194
|
-
|
|
195
|
-
if (!cluster) {
|
|
196
|
-
spinner.fail('Cluster not found')
|
|
197
|
-
return
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (cluster.Engine !== 'redis') {
|
|
201
|
-
spinner.fail('Flush is only supported for Redis clusters')
|
|
202
|
-
cli.info('For Memcached, items expire automatically based on TTL.')
|
|
203
|
-
return
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
spinner.stop()
|
|
207
|
-
|
|
208
|
-
const endpoint = cluster.CacheNodes?.[0]?.Endpoint
|
|
209
|
-
|
|
210
|
-
if (!endpoint) {
|
|
211
|
-
cli.error('Could not determine cluster endpoint')
|
|
212
|
-
return
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
cli.warn(`This will delete ALL data in cluster: ${clusterId}`)
|
|
216
|
-
cli.warn(`Endpoint: ${endpoint.Address}:${endpoint.Port}`)
|
|
217
|
-
cli.warn('This action cannot be undone!')
|
|
218
|
-
|
|
219
|
-
const confirmed = await cli.confirm('\nFlush all data?', false)
|
|
220
|
-
if (!confirmed) {
|
|
221
|
-
cli.info('Operation cancelled')
|
|
222
|
-
return
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
cli.info('\nTo flush the Redis cluster, connect and run FLUSHALL:')
|
|
226
|
-
cli.info(` redis-cli -h ${endpoint.Address} -p ${endpoint.Port} FLUSHALL`)
|
|
227
|
-
cli.info('\nNote: Direct FLUSHALL via AWS API is not supported.')
|
|
228
|
-
cli.info('You must connect to the cluster directly to execute this command.')
|
|
229
|
-
}
|
|
230
|
-
catch (error: any) {
|
|
231
|
-
cli.error(`Failed to get cluster info: ${error.message}`)
|
|
232
|
-
process.exit(1)
|
|
233
|
-
}
|
|
234
|
-
})
|
|
235
|
-
|
|
236
|
-
app
|
|
237
|
-
.command('cache:reboot <clusterId>', 'Reboot cache cluster nodes')
|
|
238
|
-
.option('--region <region>', 'AWS region', { default: 'us-east-1' })
|
|
239
|
-
.option('--node <nodeId>', 'Specific node ID to reboot')
|
|
240
|
-
.action(async (clusterId: string, options: { region: string; node?: string }) => {
|
|
241
|
-
cli.header('Reboot ElastiCache Cluster')
|
|
242
|
-
|
|
243
|
-
try {
|
|
244
|
-
const elasticache = new ElastiCacheClient(options.region)
|
|
245
|
-
|
|
246
|
-
// Get cluster info first
|
|
247
|
-
const spinner = new cli.Spinner('Getting cluster info...')
|
|
248
|
-
spinner.start()
|
|
249
|
-
|
|
250
|
-
const result = await elasticache.describeCacheClusters(clusterId)
|
|
251
|
-
|
|
252
|
-
const cluster = result.CacheClusters?.[0]
|
|
253
|
-
|
|
254
|
-
if (!cluster) {
|
|
255
|
-
spinner.fail('Cluster not found')
|
|
256
|
-
return
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
spinner.stop()
|
|
260
|
-
|
|
261
|
-
const nodeIds = options.node
|
|
262
|
-
? [options.node]
|
|
263
|
-
: cluster.CacheNodes?.map(n => n.CacheNodeId).filter(Boolean) || []
|
|
264
|
-
|
|
265
|
-
if (nodeIds.length === 0) {
|
|
266
|
-
cli.error('No nodes found to reboot')
|
|
267
|
-
return
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
cli.warn(`This will reboot the following nodes: ${nodeIds.join(', ')}`)
|
|
271
|
-
cli.warn('The cluster may be temporarily unavailable during reboot.')
|
|
272
|
-
|
|
273
|
-
const confirmed = await cli.confirm('\nReboot these nodes?', false)
|
|
274
|
-
if (!confirmed) {
|
|
275
|
-
cli.info('Operation cancelled')
|
|
276
|
-
return
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const rebootSpinner = new cli.Spinner('Rebooting nodes...')
|
|
280
|
-
rebootSpinner.start()
|
|
281
|
-
|
|
282
|
-
await elasticache.rebootCacheCluster(clusterId, nodeIds)
|
|
283
|
-
|
|
284
|
-
rebootSpinner.succeed('Reboot initiated')
|
|
285
|
-
|
|
286
|
-
cli.info('\nNote: Reboot may take several minutes to complete.')
|
|
287
|
-
cli.info('Use `cloud cache:stats` to check status.')
|
|
288
|
-
}
|
|
289
|
-
catch (error: any) {
|
|
290
|
-
cli.error(`Failed to reboot cluster: ${error.message}`)
|
|
291
|
-
process.exit(1)
|
|
292
|
-
}
|
|
293
|
-
})
|
|
294
|
-
}
|
package/bin/commands/cdn.ts
DELETED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import type { CLI } from '@stacksjs/clapp'
|
|
2
|
-
import * as cli from '../../src/utils/cli'
|
|
3
|
-
import type { Distribution } from '../../src/aws/cloudfront'
|
|
4
|
-
import { CloudFrontClient } from '../../src/aws/cloudfront'
|
|
5
|
-
import { loadValidatedConfig } from './shared'
|
|
6
|
-
|
|
7
|
-
export function registerCdnCommands(app: CLI): void {
|
|
8
|
-
app
|
|
9
|
-
.command('cdn:list', 'List all CloudFront distributions')
|
|
10
|
-
.action(async () => {
|
|
11
|
-
cli.header('CloudFront Distributions')
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const config = await loadValidatedConfig()
|
|
15
|
-
const cloudfront = new CloudFrontClient()
|
|
16
|
-
|
|
17
|
-
const spinner = new cli.Spinner('Fetching distributions...')
|
|
18
|
-
spinner.start()
|
|
19
|
-
|
|
20
|
-
const distributions = await cloudfront.listDistributions()
|
|
21
|
-
|
|
22
|
-
spinner.succeed(`Found ${distributions.length} distribution(s)`)
|
|
23
|
-
|
|
24
|
-
if (distributions.length === 0) {
|
|
25
|
-
cli.info('No CloudFront distributions found')
|
|
26
|
-
cli.info('Use `cloud cdn:create` to create a new distribution')
|
|
27
|
-
return
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
cli.table(
|
|
31
|
-
['ID', 'Domain', 'Status', 'Enabled', 'Aliases'],
|
|
32
|
-
distributions.map((dist: Distribution) => [
|
|
33
|
-
dist.Id || 'N/A',
|
|
34
|
-
dist.DomainName || 'N/A',
|
|
35
|
-
dist.Status || 'N/A',
|
|
36
|
-
dist.Enabled ? 'Yes' : 'No',
|
|
37
|
-
(dist.Aliases?.Items?.length || 0).toString(),
|
|
38
|
-
]),
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
catch (error: any) {
|
|
42
|
-
cli.error(`Failed to list distributions: ${error.message}`)
|
|
43
|
-
process.exit(1)
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
app
|
|
48
|
-
.command('cdn:status <distributionId>', 'Get CloudFront distribution status')
|
|
49
|
-
.action(async (distributionId: string) => {
|
|
50
|
-
cli.header(`CloudFront Distribution: ${distributionId}`)
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
const cloudfront = new CloudFrontClient()
|
|
54
|
-
|
|
55
|
-
const spinner = new cli.Spinner('Fetching distribution details...')
|
|
56
|
-
spinner.start()
|
|
57
|
-
|
|
58
|
-
const dist = await cloudfront.getDistribution(distributionId)
|
|
59
|
-
|
|
60
|
-
spinner.succeed('Distribution details loaded')
|
|
61
|
-
|
|
62
|
-
cli.info('\nDistribution Information:')
|
|
63
|
-
cli.info(` ID: ${dist.Id}`)
|
|
64
|
-
cli.info(` Domain: ${dist.DomainName}`)
|
|
65
|
-
cli.info(` Status: ${dist.Status}`)
|
|
66
|
-
cli.info(` ARN: ${dist.ARN}`)
|
|
67
|
-
cli.info(` Enabled: ${dist.Enabled ? 'Yes' : 'No'}`)
|
|
68
|
-
|
|
69
|
-
if (dist.Aliases?.Items?.length) {
|
|
70
|
-
cli.info(` Aliases: ${dist.Aliases.Items.join(', ')}`)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Fetch full config for origin and cache behavior details
|
|
74
|
-
const config = await cloudfront.getDistributionConfig(distributionId)
|
|
75
|
-
|
|
76
|
-
cli.info('\nOrigins:')
|
|
77
|
-
const origins = config.DistributionConfig?.Origins?.Items || []
|
|
78
|
-
if (Array.isArray(origins)) {
|
|
79
|
-
for (const origin of origins) {
|
|
80
|
-
cli.info(` - ${origin.Id}: ${origin.DomainName}`)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (config.DistributionConfig?.DefaultCacheBehavior) {
|
|
85
|
-
const behavior = config.DistributionConfig.DefaultCacheBehavior
|
|
86
|
-
cli.info('\nDefault Cache Behavior:')
|
|
87
|
-
cli.info(` Target Origin: ${behavior.TargetOriginId}`)
|
|
88
|
-
cli.info(` Viewer Protocol: ${behavior.ViewerProtocolPolicy}`)
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
catch (error: any) {
|
|
92
|
-
cli.error(`Failed to get distribution: ${error.message}`)
|
|
93
|
-
process.exit(1)
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
app
|
|
98
|
-
.command('cdn:create', 'Create a new CloudFront distribution for an S3 bucket')
|
|
99
|
-
.option('--bucket <name>', 'S3 bucket name')
|
|
100
|
-
.option('--region <region>', 'S3 bucket region', { default: 'us-east-1' })
|
|
101
|
-
.option('--alias <domain>', 'Custom domain alias (CNAME)')
|
|
102
|
-
.option('--certificate <arn>', 'ACM certificate ARN for custom domain')
|
|
103
|
-
.option('--comment <text>', 'Distribution comment/description')
|
|
104
|
-
.action(async (options: { bucket?: string; region: string; alias?: string; certificate?: string; comment?: string }) => {
|
|
105
|
-
cli.header('Create CloudFront Distribution')
|
|
106
|
-
|
|
107
|
-
try {
|
|
108
|
-
if (!options.bucket) {
|
|
109
|
-
cli.error('--bucket is required')
|
|
110
|
-
cli.info('Example: cloud cdn:create --bucket my-bucket --region us-east-1')
|
|
111
|
-
process.exit(1)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const cloudfront = new CloudFrontClient()
|
|
115
|
-
|
|
116
|
-
cli.info(`Bucket: ${options.bucket}`)
|
|
117
|
-
cli.info(`Region: ${options.region}`)
|
|
118
|
-
if (options.alias) {
|
|
119
|
-
cli.info(`Alias: ${options.alias}`)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const confirmed = await cli.confirm('\nCreate this distribution?', true)
|
|
123
|
-
if (!confirmed) {
|
|
124
|
-
cli.info('Operation cancelled')
|
|
125
|
-
return
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const spinner = new cli.Spinner('Setting up Origin Access Control...')
|
|
129
|
-
spinner.start()
|
|
130
|
-
|
|
131
|
-
// Find or create an OAC for S3
|
|
132
|
-
const oac = await cloudfront.findOrCreateOriginAccessControl(`OAC-${options.bucket}`)
|
|
133
|
-
if (oac.isNew) {
|
|
134
|
-
spinner.text = 'Created new Origin Access Control'
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
spinner.text = 'Creating distribution...'
|
|
138
|
-
|
|
139
|
-
const aliases = options.alias ? [options.alias] : []
|
|
140
|
-
|
|
141
|
-
const result = await cloudfront.createDistributionForS3({
|
|
142
|
-
bucketName: options.bucket,
|
|
143
|
-
bucketRegion: options.region,
|
|
144
|
-
originAccessControlId: oac.Id,
|
|
145
|
-
aliases,
|
|
146
|
-
certificateArn: options.certificate,
|
|
147
|
-
comment: options.comment || `Created by ts-cloud CLI`,
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
spinner.succeed('Distribution created')
|
|
151
|
-
|
|
152
|
-
cli.success(`\nDistribution ID: ${result.Id}`)
|
|
153
|
-
cli.info(`Domain: ${result.DomainName}`)
|
|
154
|
-
cli.info(`Status: ${result.Status}`)
|
|
155
|
-
cli.info('\nNote: Distribution deployment may take 15-30 minutes.')
|
|
156
|
-
|
|
157
|
-
// Show the S3 bucket policy that needs to be applied
|
|
158
|
-
cli.info('\nIMPORTANT: Update your S3 bucket policy to allow CloudFront access:')
|
|
159
|
-
const policy = CloudFrontClient.getS3BucketPolicyForCloudFront(options.bucket, result.ARN)
|
|
160
|
-
cli.info(JSON.stringify(policy, null, 2))
|
|
161
|
-
}
|
|
162
|
-
catch (error: any) {
|
|
163
|
-
cli.error(`Failed to create distribution: ${error.message}`)
|
|
164
|
-
process.exit(1)
|
|
165
|
-
}
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
app
|
|
169
|
-
.command('cdn:invalidate <distributionId>', 'Invalidate CloudFront cache')
|
|
170
|
-
.option('--paths <paths>', 'Paths to invalidate (comma-separated)', { default: '/*' })
|
|
171
|
-
.action(async (distributionId: string, options: { paths: string }) => {
|
|
172
|
-
cli.header('Invalidate CloudFront Cache')
|
|
173
|
-
|
|
174
|
-
try {
|
|
175
|
-
const cloudfront = new CloudFrontClient()
|
|
176
|
-
|
|
177
|
-
const paths = options.paths.split(',').map(p => p.trim())
|
|
178
|
-
|
|
179
|
-
cli.info(`Distribution: ${distributionId}`)
|
|
180
|
-
cli.info(`Paths: ${paths.join(', ')}`)
|
|
181
|
-
|
|
182
|
-
const confirmed = await cli.confirm('\nCreate invalidation?', true)
|
|
183
|
-
if (!confirmed) {
|
|
184
|
-
cli.info('Operation cancelled')
|
|
185
|
-
return
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const spinner = new cli.Spinner('Creating invalidation...')
|
|
189
|
-
spinner.start()
|
|
190
|
-
|
|
191
|
-
const result = await cloudfront.createInvalidation({
|
|
192
|
-
distributionId,
|
|
193
|
-
paths,
|
|
194
|
-
callerReference: `cli-${Date.now()}`,
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
spinner.succeed('Invalidation created')
|
|
198
|
-
|
|
199
|
-
cli.success(`\nInvalidation ID: ${result.Id}`)
|
|
200
|
-
cli.info(`Status: ${result.Status}`)
|
|
201
|
-
cli.info('\nNote: Invalidation typically completes in 5-10 minutes.')
|
|
202
|
-
}
|
|
203
|
-
catch (error: any) {
|
|
204
|
-
cli.error(`Failed to create invalidation: ${error.message}`)
|
|
205
|
-
process.exit(1)
|
|
206
|
-
}
|
|
207
|
-
})
|
|
208
|
-
|
|
209
|
-
app
|
|
210
|
-
.command('cdn:disable <distributionId>', 'Disable a CloudFront distribution')
|
|
211
|
-
.action(async (distributionId: string) => {
|
|
212
|
-
cli.header('Disable CloudFront Distribution')
|
|
213
|
-
|
|
214
|
-
try {
|
|
215
|
-
const cloudfront = new CloudFrontClient()
|
|
216
|
-
|
|
217
|
-
cli.warn(`This will disable distribution: ${distributionId}`)
|
|
218
|
-
cli.info('The distribution will stop serving content.')
|
|
219
|
-
|
|
220
|
-
const confirmed = await cli.confirm('\nDisable this distribution?', false)
|
|
221
|
-
if (!confirmed) {
|
|
222
|
-
cli.info('Operation cancelled')
|
|
223
|
-
return
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const spinner = new cli.Spinner('Disabling distribution...')
|
|
227
|
-
spinner.start()
|
|
228
|
-
|
|
229
|
-
await cloudfront.disableDistribution(distributionId)
|
|
230
|
-
|
|
231
|
-
spinner.succeed('Distribution disabled')
|
|
232
|
-
|
|
233
|
-
cli.info('\nNote: Changes may take 15-30 minutes to propagate.')
|
|
234
|
-
cli.info('To delete the distribution, wait for it to be fully disabled first.')
|
|
235
|
-
}
|
|
236
|
-
catch (error: any) {
|
|
237
|
-
cli.error(`Failed to disable distribution: ${error.message}`)
|
|
238
|
-
process.exit(1)
|
|
239
|
-
}
|
|
240
|
-
})
|
|
241
|
-
|
|
242
|
-
app
|
|
243
|
-
.command('cdn:delete <distributionId>', 'Delete a CloudFront distribution')
|
|
244
|
-
.action(async (distributionId: string) => {
|
|
245
|
-
cli.header('Delete CloudFront Distribution')
|
|
246
|
-
|
|
247
|
-
try {
|
|
248
|
-
const cloudfront = new CloudFrontClient()
|
|
249
|
-
|
|
250
|
-
cli.warn(`This will permanently delete distribution: ${distributionId}`)
|
|
251
|
-
cli.warn('The distribution must be disabled first.')
|
|
252
|
-
|
|
253
|
-
const confirmed = await cli.confirm('\nDelete this distribution?', false)
|
|
254
|
-
if (!confirmed) {
|
|
255
|
-
cli.info('Operation cancelled')
|
|
256
|
-
return
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
const spinner = new cli.Spinner('Checking distribution status...')
|
|
260
|
-
spinner.start()
|
|
261
|
-
|
|
262
|
-
// Get distribution to check status
|
|
263
|
-
const dist = await cloudfront.getDistribution(distributionId)
|
|
264
|
-
if (dist.Status !== 'Deployed' || dist.Enabled) {
|
|
265
|
-
spinner.fail('Distribution must be disabled and deployed before deletion')
|
|
266
|
-
cli.info('\nRun `cloud cdn:disable` first and wait for status to be "Deployed"')
|
|
267
|
-
return
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
spinner.text = 'Deleting distribution...'
|
|
271
|
-
|
|
272
|
-
await cloudfront.deleteDistribution(distributionId)
|
|
273
|
-
|
|
274
|
-
spinner.succeed('Distribution deleted')
|
|
275
|
-
}
|
|
276
|
-
catch (error: any) {
|
|
277
|
-
cli.error(`Failed to delete distribution: ${error.message}`)
|
|
278
|
-
process.exit(1)
|
|
279
|
-
}
|
|
280
|
-
})
|
|
281
|
-
}
|