@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.
- 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/iam.ts
DELETED
|
@@ -1,464 +0,0 @@
|
|
|
1
|
-
import type { CLI } from '@stacksjs/clapp'
|
|
2
|
-
import * as cli from '../../src/utils/cli'
|
|
3
|
-
import { IAMClient } from '../../src/aws/iam'
|
|
4
|
-
import { loadValidatedConfig } from './shared'
|
|
5
|
-
|
|
6
|
-
export function registerIamCommands(app: CLI): void {
|
|
7
|
-
app
|
|
8
|
-
.command('iam:roles', 'List IAM roles')
|
|
9
|
-
.option('--prefix <prefix>', 'Filter by role name prefix')
|
|
10
|
-
.option('--path <path>', 'Filter by path prefix', { default: '/' })
|
|
11
|
-
.action(async (options: { prefix?: string; path: string }) => {
|
|
12
|
-
cli.header('IAM Roles')
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
const iam = new IAMClient()
|
|
16
|
-
|
|
17
|
-
const spinner = new cli.Spinner('Fetching roles...')
|
|
18
|
-
spinner.start()
|
|
19
|
-
|
|
20
|
-
const result = await iam.listRoles({ PathPrefix: options.path })
|
|
21
|
-
let roles = result.Roles || []
|
|
22
|
-
|
|
23
|
-
if (options.prefix) {
|
|
24
|
-
roles = roles.filter(r => r.RoleName?.startsWith(options.prefix!))
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
spinner.succeed(`Found ${roles.length} role(s)`)
|
|
28
|
-
|
|
29
|
-
if (roles.length === 0) {
|
|
30
|
-
cli.info('No IAM roles found')
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
cli.table(
|
|
35
|
-
['Role Name', 'Path', 'Created', 'Description'],
|
|
36
|
-
roles.map(role => [
|
|
37
|
-
role.RoleName || 'N/A',
|
|
38
|
-
role.Path || '/',
|
|
39
|
-
role.CreateDate ? new Date(role.CreateDate).toLocaleDateString() : 'N/A',
|
|
40
|
-
(role.Description || '').substring(0, 40),
|
|
41
|
-
]),
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
catch (error: any) {
|
|
45
|
-
cli.error(`Failed to list roles: ${error.message}`)
|
|
46
|
-
process.exit(1)
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
app
|
|
51
|
-
.command('iam:role <roleName>', 'Show IAM role details')
|
|
52
|
-
.action(async (roleName: string) => {
|
|
53
|
-
cli.header(`IAM Role: ${roleName}`)
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
const iam = new IAMClient()
|
|
57
|
-
|
|
58
|
-
const spinner = new cli.Spinner('Fetching role details...')
|
|
59
|
-
spinner.start()
|
|
60
|
-
|
|
61
|
-
const role = await iam.getRole({ RoleName: roleName })
|
|
62
|
-
|
|
63
|
-
// Get attached policies
|
|
64
|
-
const attachedPolicies = await iam.listAttachedRolePolicies({ RoleName: roleName })
|
|
65
|
-
const inlinePolicies = await iam.listRolePolicies({ RoleName: roleName })
|
|
66
|
-
|
|
67
|
-
spinner.succeed('Role details loaded')
|
|
68
|
-
|
|
69
|
-
cli.info('\nRole Information:')
|
|
70
|
-
cli.info(` Name: ${role.RoleName}`)
|
|
71
|
-
cli.info(` ARN: ${role.Arn}`)
|
|
72
|
-
cli.info(` Path: ${role.Path}`)
|
|
73
|
-
cli.info(` Created: ${role.CreateDate ? new Date(role.CreateDate).toLocaleString() : 'N/A'}`)
|
|
74
|
-
|
|
75
|
-
if (role.Description) {
|
|
76
|
-
cli.info(` Description: ${role.Description}`)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (role.MaxSessionDuration) {
|
|
80
|
-
cli.info(` Max Session: ${role.MaxSessionDuration / 3600} hours`)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (role.AssumeRolePolicyDocument) {
|
|
84
|
-
cli.info('\nTrust Policy:')
|
|
85
|
-
const trustPolicy = JSON.parse(decodeURIComponent(role.AssumeRolePolicyDocument))
|
|
86
|
-
console.log(JSON.stringify(trustPolicy, null, 2))
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (attachedPolicies.AttachedPolicies && attachedPolicies.AttachedPolicies.length > 0) {
|
|
90
|
-
cli.info('\nAttached Managed Policies:')
|
|
91
|
-
for (const policy of attachedPolicies.AttachedPolicies) {
|
|
92
|
-
cli.info(` - ${policy.PolicyName}`)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (inlinePolicies.PolicyNames && inlinePolicies.PolicyNames.length > 0) {
|
|
97
|
-
cli.info('\nInline Policies:')
|
|
98
|
-
for (const policyName of inlinePolicies.PolicyNames) {
|
|
99
|
-
cli.info(` - ${policyName}`)
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (role.Tags && role.Tags.length > 0) {
|
|
104
|
-
cli.info('\nTags:')
|
|
105
|
-
for (const tag of role.Tags) {
|
|
106
|
-
cli.info(` ${tag.Key}: ${tag.Value}`)
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
catch (error: any) {
|
|
111
|
-
cli.error(`Failed to get role: ${error.message}`)
|
|
112
|
-
process.exit(1)
|
|
113
|
-
}
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
app
|
|
117
|
-
.command('iam:policies', 'List IAM policies')
|
|
118
|
-
.option('--scope <scope>', 'Filter by scope (All, AWS, Local)', { default: 'Local' })
|
|
119
|
-
.option('--prefix <prefix>', 'Filter by policy name prefix')
|
|
120
|
-
.option('--path <path>', 'Filter by path prefix', { default: '/' })
|
|
121
|
-
.action(async (options: { scope: 'All' | 'AWS' | 'Local'; prefix?: string; path: string }) => {
|
|
122
|
-
cli.header('IAM Policies')
|
|
123
|
-
|
|
124
|
-
try {
|
|
125
|
-
const iam = new IAMClient()
|
|
126
|
-
|
|
127
|
-
const spinner = new cli.Spinner('Fetching policies...')
|
|
128
|
-
spinner.start()
|
|
129
|
-
|
|
130
|
-
const result = await iam.listPolicies({
|
|
131
|
-
Scope: options.scope,
|
|
132
|
-
PathPrefix: options.path,
|
|
133
|
-
OnlyAttached: false,
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
let policies = result.Policies || []
|
|
137
|
-
|
|
138
|
-
if (options.prefix) {
|
|
139
|
-
policies = policies.filter(p => p.PolicyName?.startsWith(options.prefix!))
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
spinner.succeed(`Found ${policies.length} policy(s)`)
|
|
143
|
-
|
|
144
|
-
if (policies.length === 0) {
|
|
145
|
-
cli.info('No IAM policies found')
|
|
146
|
-
return
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
cli.table(
|
|
150
|
-
['Policy Name', 'ARN', 'Attachments', 'Created'],
|
|
151
|
-
policies.slice(0, 50).map(policy => [
|
|
152
|
-
policy.PolicyName || 'N/A',
|
|
153
|
-
(policy.Arn || 'N/A').substring(0, 50),
|
|
154
|
-
(policy.AttachmentCount || 0).toString(),
|
|
155
|
-
policy.CreateDate ? new Date(policy.CreateDate).toLocaleDateString() : 'N/A',
|
|
156
|
-
]),
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
if (policies.length > 50) {
|
|
160
|
-
cli.info(`\n... and ${policies.length - 50} more policies`)
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
catch (error: any) {
|
|
164
|
-
cli.error(`Failed to list policies: ${error.message}`)
|
|
165
|
-
process.exit(1)
|
|
166
|
-
}
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
app
|
|
170
|
-
.command('iam:policy <policyArn>', 'Show IAM policy details')
|
|
171
|
-
.option('--version <version>', 'Policy version ID')
|
|
172
|
-
.action(async (policyArn: string, options: { version?: string }) => {
|
|
173
|
-
cli.header('IAM Policy Details')
|
|
174
|
-
|
|
175
|
-
try {
|
|
176
|
-
const iam = new IAMClient()
|
|
177
|
-
|
|
178
|
-
const spinner = new cli.Spinner('Fetching policy...')
|
|
179
|
-
spinner.start()
|
|
180
|
-
|
|
181
|
-
const policy = await iam.getPolicy({ PolicyArn: policyArn })
|
|
182
|
-
|
|
183
|
-
// Get the policy document
|
|
184
|
-
const versionId = options.version || policy.DefaultVersionId || 'v1'
|
|
185
|
-
const versionResult = await iam.getPolicyVersion({
|
|
186
|
-
PolicyArn: policyArn,
|
|
187
|
-
VersionId: versionId,
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
spinner.succeed('Policy loaded')
|
|
191
|
-
|
|
192
|
-
cli.info('\nPolicy Information:')
|
|
193
|
-
cli.info(` Name: ${policy.PolicyName}`)
|
|
194
|
-
cli.info(` ARN: ${policy.Arn}`)
|
|
195
|
-
cli.info(` Path: ${policy.Path}`)
|
|
196
|
-
cli.info(` Created: ${policy.CreateDate ? new Date(policy.CreateDate).toLocaleString() : 'N/A'}`)
|
|
197
|
-
cli.info(` Updated: ${policy.UpdateDate ? new Date(policy.UpdateDate).toLocaleString() : 'N/A'}`)
|
|
198
|
-
cli.info(` Attachment Count: ${policy.AttachmentCount || 0}`)
|
|
199
|
-
cli.info(` Version: ${versionId}`)
|
|
200
|
-
|
|
201
|
-
if (policy.Description) {
|
|
202
|
-
cli.info(` Description: ${policy.Description}`)
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (versionResult.Document) {
|
|
206
|
-
cli.info('\nPolicy Document:')
|
|
207
|
-
const document = JSON.parse(decodeURIComponent(versionResult.Document))
|
|
208
|
-
console.log(JSON.stringify(document, null, 2))
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
catch (error: any) {
|
|
212
|
-
cli.error(`Failed to get policy: ${error.message}`)
|
|
213
|
-
process.exit(1)
|
|
214
|
-
}
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
app
|
|
218
|
-
.command('iam:users', 'List IAM users')
|
|
219
|
-
.option('--path <path>', 'Filter by path prefix', { default: '/' })
|
|
220
|
-
.action(async (options: { path: string }) => {
|
|
221
|
-
cli.header('IAM Users')
|
|
222
|
-
|
|
223
|
-
try {
|
|
224
|
-
const iam = new IAMClient()
|
|
225
|
-
|
|
226
|
-
const spinner = new cli.Spinner('Fetching users...')
|
|
227
|
-
spinner.start()
|
|
228
|
-
|
|
229
|
-
const result = await iam.listUsers({ PathPrefix: options.path })
|
|
230
|
-
const users = result.Users || []
|
|
231
|
-
|
|
232
|
-
spinner.succeed(`Found ${users.length} user(s)`)
|
|
233
|
-
|
|
234
|
-
if (users.length === 0) {
|
|
235
|
-
cli.info('No IAM users found')
|
|
236
|
-
return
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
cli.table(
|
|
240
|
-
['User Name', 'User ID', 'Path', 'Created', 'Password Last Used'],
|
|
241
|
-
users.map(user => [
|
|
242
|
-
user.UserName || 'N/A',
|
|
243
|
-
user.UserId || 'N/A',
|
|
244
|
-
user.Path || '/',
|
|
245
|
-
user.CreateDate ? new Date(user.CreateDate).toLocaleDateString() : 'N/A',
|
|
246
|
-
user.PasswordLastUsed ? new Date(user.PasswordLastUsed).toLocaleDateString() : 'Never',
|
|
247
|
-
]),
|
|
248
|
-
)
|
|
249
|
-
}
|
|
250
|
-
catch (error: any) {
|
|
251
|
-
cli.error(`Failed to list users: ${error.message}`)
|
|
252
|
-
process.exit(1)
|
|
253
|
-
}
|
|
254
|
-
})
|
|
255
|
-
|
|
256
|
-
app
|
|
257
|
-
.command('iam:user <userName>', 'Show IAM user details')
|
|
258
|
-
.action(async (userName: string) => {
|
|
259
|
-
cli.header(`IAM User: ${userName}`)
|
|
260
|
-
|
|
261
|
-
try {
|
|
262
|
-
const iam = new IAMClient()
|
|
263
|
-
|
|
264
|
-
const spinner = new cli.Spinner('Fetching user details...')
|
|
265
|
-
spinner.start()
|
|
266
|
-
|
|
267
|
-
const user = await iam.getUser({ UserName: userName })
|
|
268
|
-
|
|
269
|
-
// Get additional info
|
|
270
|
-
const [groups, policies, accessKeys] = await Promise.all([
|
|
271
|
-
iam.listGroupsForUser({ UserName: userName }),
|
|
272
|
-
iam.listAttachedUserPolicies({ UserName: userName }),
|
|
273
|
-
iam.listAccessKeys({ UserName: userName }),
|
|
274
|
-
])
|
|
275
|
-
|
|
276
|
-
spinner.succeed('User details loaded')
|
|
277
|
-
|
|
278
|
-
cli.info('\nUser Information:')
|
|
279
|
-
cli.info(` Name: ${user.UserName}`)
|
|
280
|
-
cli.info(` ARN: ${user.Arn}`)
|
|
281
|
-
cli.info(` User ID: ${user.UserId}`)
|
|
282
|
-
cli.info(` Path: ${user.Path}`)
|
|
283
|
-
cli.info(` Created: ${user.CreateDate ? new Date(user.CreateDate).toLocaleString() : 'N/A'}`)
|
|
284
|
-
|
|
285
|
-
if (user.PasswordLastUsed) {
|
|
286
|
-
cli.info(` Password Last Used: ${new Date(user.PasswordLastUsed).toLocaleString()}`)
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (groups.Groups && groups.Groups.length > 0) {
|
|
290
|
-
cli.info('\nGroups:')
|
|
291
|
-
for (const group of groups.Groups) {
|
|
292
|
-
cli.info(` - ${group.GroupName}`)
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (policies.AttachedPolicies && policies.AttachedPolicies.length > 0) {
|
|
297
|
-
cli.info('\nAttached Policies:')
|
|
298
|
-
for (const policy of policies.AttachedPolicies) {
|
|
299
|
-
cli.info(` - ${policy.PolicyName}`)
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
if (accessKeys.AccessKeyMetadata && accessKeys.AccessKeyMetadata.length > 0) {
|
|
304
|
-
cli.info('\nAccess Keys:')
|
|
305
|
-
for (const key of accessKeys.AccessKeyMetadata) {
|
|
306
|
-
cli.info(` - ${key.AccessKeyId}: ${key.Status}`)
|
|
307
|
-
if (key.CreateDate) {
|
|
308
|
-
cli.info(` Created: ${new Date(key.CreateDate).toLocaleString()}`)
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if (user.Tags && user.Tags.length > 0) {
|
|
314
|
-
cli.info('\nTags:')
|
|
315
|
-
for (const tag of user.Tags) {
|
|
316
|
-
cli.info(` ${tag.Key}: ${tag.Value}`)
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
catch (error: any) {
|
|
321
|
-
cli.error(`Failed to get user: ${error.message}`)
|
|
322
|
-
process.exit(1)
|
|
323
|
-
}
|
|
324
|
-
})
|
|
325
|
-
|
|
326
|
-
app
|
|
327
|
-
.command('iam:groups', 'List IAM groups')
|
|
328
|
-
.option('--path <path>', 'Filter by path prefix', { default: '/' })
|
|
329
|
-
.action(async (options: { path: string }) => {
|
|
330
|
-
cli.header('IAM Groups')
|
|
331
|
-
|
|
332
|
-
try {
|
|
333
|
-
const iam = new IAMClient()
|
|
334
|
-
|
|
335
|
-
const spinner = new cli.Spinner('Fetching groups...')
|
|
336
|
-
spinner.start()
|
|
337
|
-
|
|
338
|
-
const result = await iam.listGroups({ PathPrefix: options.path })
|
|
339
|
-
const groups = result.Groups || []
|
|
340
|
-
|
|
341
|
-
spinner.succeed(`Found ${groups.length} group(s)`)
|
|
342
|
-
|
|
343
|
-
if (groups.length === 0) {
|
|
344
|
-
cli.info('No IAM groups found')
|
|
345
|
-
return
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
cli.table(
|
|
349
|
-
['Group Name', 'Group ID', 'Path', 'Created'],
|
|
350
|
-
groups.map(group => [
|
|
351
|
-
group.GroupName || 'N/A',
|
|
352
|
-
group.GroupId || 'N/A',
|
|
353
|
-
group.Path || '/',
|
|
354
|
-
group.CreateDate ? new Date(group.CreateDate).toLocaleDateString() : 'N/A',
|
|
355
|
-
]),
|
|
356
|
-
)
|
|
357
|
-
}
|
|
358
|
-
catch (error: any) {
|
|
359
|
-
cli.error(`Failed to list groups: ${error.message}`)
|
|
360
|
-
process.exit(1)
|
|
361
|
-
}
|
|
362
|
-
})
|
|
363
|
-
|
|
364
|
-
app
|
|
365
|
-
.command('iam:simulate <policyArn>', 'Simulate IAM policy')
|
|
366
|
-
.option('--action <action>', 'Action to simulate (e.g., s3:GetObject)')
|
|
367
|
-
.option('--resource <arn>', 'Resource ARN to test against')
|
|
368
|
-
.action(async (policyArn: string, options: { action?: string; resource?: string }) => {
|
|
369
|
-
cli.header('Simulate IAM Policy')
|
|
370
|
-
|
|
371
|
-
try {
|
|
372
|
-
const iam = new IAMClient()
|
|
373
|
-
|
|
374
|
-
const action = options.action || await cli.prompt('Action to simulate', 's3:GetObject')
|
|
375
|
-
const resource = options.resource || await cli.prompt('Resource ARN', '*')
|
|
376
|
-
|
|
377
|
-
cli.info(`\nPolicy: ${policyArn}`)
|
|
378
|
-
cli.info(`Action: ${action}`)
|
|
379
|
-
cli.info(`Resource: ${resource}`)
|
|
380
|
-
|
|
381
|
-
const spinner = new cli.Spinner('Running simulation...')
|
|
382
|
-
spinner.start()
|
|
383
|
-
|
|
384
|
-
const result = await iam.simulatePrincipalPolicy({
|
|
385
|
-
PolicySourceArn: policyArn,
|
|
386
|
-
ActionNames: [action],
|
|
387
|
-
ResourceArns: [resource],
|
|
388
|
-
})
|
|
389
|
-
|
|
390
|
-
spinner.succeed('Simulation complete')
|
|
391
|
-
|
|
392
|
-
if (result.EvaluationResults && result.EvaluationResults.length > 0) {
|
|
393
|
-
for (const evalResult of result.EvaluationResults) {
|
|
394
|
-
const decision = evalResult.EvalDecision
|
|
395
|
-
|
|
396
|
-
cli.info(`\nResult for ${evalResult.EvalActionName}:`)
|
|
397
|
-
|
|
398
|
-
if (decision === 'allowed') {
|
|
399
|
-
cli.success(` Decision: ALLOWED`)
|
|
400
|
-
}
|
|
401
|
-
else if (decision === 'implicitDeny') {
|
|
402
|
-
cli.warn(` Decision: IMPLICIT DENY (no matching allow statement)`)
|
|
403
|
-
}
|
|
404
|
-
else {
|
|
405
|
-
cli.error(` Decision: EXPLICIT DENY`)
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if (evalResult.MatchedStatements && evalResult.MatchedStatements.length > 0) {
|
|
409
|
-
cli.info(' Matched Statements:')
|
|
410
|
-
for (const statement of evalResult.MatchedStatements) {
|
|
411
|
-
cli.info(` - ${statement.SourcePolicyId}: ${statement.SourcePolicyType}`)
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
catch (error: any) {
|
|
418
|
-
cli.error(`Failed to simulate policy: ${error.message}`)
|
|
419
|
-
process.exit(1)
|
|
420
|
-
}
|
|
421
|
-
})
|
|
422
|
-
|
|
423
|
-
app
|
|
424
|
-
.command('iam:whoami', 'Show current IAM identity')
|
|
425
|
-
.action(async () => {
|
|
426
|
-
cli.header('Current IAM Identity')
|
|
427
|
-
|
|
428
|
-
try {
|
|
429
|
-
const iam = new IAMClient()
|
|
430
|
-
|
|
431
|
-
const spinner = new cli.Spinner('Fetching identity...')
|
|
432
|
-
spinner.start()
|
|
433
|
-
|
|
434
|
-
// Use STS to get caller identity
|
|
435
|
-
const { STSClient } = await import('../../src/aws/sts')
|
|
436
|
-
const sts = new STSClient('us-east-1')
|
|
437
|
-
const identity = await sts.getCallerIdentity()
|
|
438
|
-
|
|
439
|
-
spinner.succeed('Identity loaded')
|
|
440
|
-
|
|
441
|
-
cli.info('\nCaller Identity:')
|
|
442
|
-
cli.info(` Account: ${identity.Account}`)
|
|
443
|
-
cli.info(` ARN: ${identity.Arn}`)
|
|
444
|
-
cli.info(` User ID: ${identity.UserId}`)
|
|
445
|
-
|
|
446
|
-
// Determine identity type
|
|
447
|
-
const arn = identity.Arn || ''
|
|
448
|
-
if (arn.includes(':user/')) {
|
|
449
|
-
cli.info(` Type: IAM User`)
|
|
450
|
-
}
|
|
451
|
-
else if (arn.includes(':assumed-role/')) {
|
|
452
|
-
cli.info(` Type: Assumed Role`)
|
|
453
|
-
}
|
|
454
|
-
else if (arn.includes(':root')) {
|
|
455
|
-
cli.warn(` Type: Root Account`)
|
|
456
|
-
cli.warn('\n Warning: Using root credentials is not recommended!')
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
catch (error: any) {
|
|
460
|
-
cli.error(`Failed to get identity: ${error.message}`)
|
|
461
|
-
process.exit(1)
|
|
462
|
-
}
|
|
463
|
-
})
|
|
464
|
-
}
|
package/bin/commands/index.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export { registerInitCommands } from './init'
|
|
2
|
-
export { registerConfigCommands } from './config'
|
|
3
|
-
export { registerGenerateCommands } from './generate'
|
|
4
|
-
export { registerServerCommands } from './server'
|
|
5
|
-
export { registerFunctionCommands } from './function'
|
|
6
|
-
export { registerContainerCommands } from './container'
|
|
7
|
-
export { registerDomainCommands } from './domain'
|
|
8
|
-
export { registerDatabaseCommands } from './database'
|
|
9
|
-
export { registerLogsCommands } from './logs'
|
|
10
|
-
export { registerSecretsCommands } from './secrets'
|
|
11
|
-
export { registerFirewallCommands } from './firewall'
|
|
12
|
-
export { registerSslCommands } from './ssl'
|
|
13
|
-
export { registerCostCommands } from './cost'
|
|
14
|
-
export { registerGitCommands } from './git'
|
|
15
|
-
export { registerEnvironmentCommands } from './environment'
|
|
16
|
-
export { registerAssetsCommands } from './assets'
|
|
17
|
-
export { registerTeamCommands } from './team'
|
|
18
|
-
export { registerDeployCommands } from './deploy'
|
|
19
|
-
export { registerStackCommands } from './stack'
|
|
20
|
-
export { registerUtilsCommands } from './utils'
|
|
21
|
-
export { registerAnalyticsCommands } from './analytics'
|
|
22
|
-
|
|
23
|
-
// New infrastructure commands
|
|
24
|
-
export { registerCdnCommands } from './cdn'
|
|
25
|
-
export { registerStorageCommands } from './storage'
|
|
26
|
-
export { registerCacheCommands } from './cache'
|
|
27
|
-
export { registerQueueCommands } from './queue'
|
|
28
|
-
export { registerNetworkCommands } from './network'
|
|
29
|
-
|
|
30
|
-
// Scheduling & Events
|
|
31
|
-
export { registerSchedulerCommands } from './scheduler'
|
|
32
|
-
export { registerEventsCommands } from './events'
|
|
33
|
-
|
|
34
|
-
// Communication
|
|
35
|
-
export { registerEmailCommands } from './email'
|
|
36
|
-
export { registerNotifyCommands } from './notify'
|
|
37
|
-
|
|
38
|
-
// Security & Access
|
|
39
|
-
export { registerIamCommands } from './iam'
|
|
40
|
-
export { registerAuditCommands } from './audit'
|
|
41
|
-
|
|
42
|
-
// Operations
|
|
43
|
-
export { registerStatusCommands } from './status'
|
|
44
|
-
export { registerBackupCommands } from './backup'
|
|
45
|
-
export { registerApiCommands } from './api'
|
|
46
|
-
export { registerTunnelCommands } from './tunnel'
|
|
47
|
-
|
|
48
|
-
export { loadValidatedConfig, resolveDnsProviderConfig, getDnsProvider } from './shared'
|
package/bin/commands/init.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import type { CLI } from '@stacksjs/clapp'
|
|
2
|
-
import { existsSync } from 'node:fs'
|
|
3
|
-
import { mkdir, writeFile } from 'node:fs/promises'
|
|
4
|
-
import * as cli from '../../src/utils/cli'
|
|
5
|
-
|
|
6
|
-
export function registerInitCommands(app: CLI): void {
|
|
7
|
-
app
|
|
8
|
-
.command('init', 'Initialize a new ts-cloud project')
|
|
9
|
-
.option('--mode <mode>', 'Deployment mode: server, serverless, or hybrid')
|
|
10
|
-
.option('--name <name>', 'Project name')
|
|
11
|
-
.option('--region <region>', 'AWS Region')
|
|
12
|
-
.action(async (options?: { mode?: string, name?: string, region?: string }) => {
|
|
13
|
-
cli.header('Initializing ts-cloud Project')
|
|
14
|
-
|
|
15
|
-
// Check if already initialized
|
|
16
|
-
if (existsSync('cloud.config.ts')) {
|
|
17
|
-
const overwrite = await cli.confirm('cloud.config.ts already exists. Overwrite?', false)
|
|
18
|
-
if (!overwrite) {
|
|
19
|
-
cli.info('Initialization cancelled')
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Get project name
|
|
25
|
-
const projectName = options?.name || await cli.prompt('Project name', 'my-app')
|
|
26
|
-
|
|
27
|
-
// Get deployment mode
|
|
28
|
-
const mode = options?.mode || await cli.select(
|
|
29
|
-
'Select deployment mode',
|
|
30
|
-
['serverless', 'server', 'hybrid'],
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
// Get AWS region
|
|
34
|
-
const region = options?.region || await cli.select(
|
|
35
|
-
'Select AWS region',
|
|
36
|
-
['us-east-1', 'us-west-2', 'eu-west-1', 'eu-central-1', 'ap-southeast-1'],
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
// Create cloud.config.ts
|
|
40
|
-
const spinner = new cli.Spinner('Creating configuration file...')
|
|
41
|
-
spinner.start()
|
|
42
|
-
|
|
43
|
-
const configContent = `import { defineConfig } from '@stacksjs/ts-cloud-types'
|
|
44
|
-
|
|
45
|
-
export default defineConfig({
|
|
46
|
-
project: {
|
|
47
|
-
name: '${projectName}',
|
|
48
|
-
slug: '${projectName.toLowerCase().replace(/[^a-z0-9-]/g, '-')}',
|
|
49
|
-
region: '${region}',
|
|
50
|
-
},
|
|
51
|
-
mode: '${mode}',
|
|
52
|
-
environments: {
|
|
53
|
-
production: {
|
|
54
|
-
enabled: true,
|
|
55
|
-
},
|
|
56
|
-
staging: {
|
|
57
|
-
enabled: true,
|
|
58
|
-
},
|
|
59
|
-
development: {
|
|
60
|
-
enabled: true,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
infrastructure: {
|
|
64
|
-
// Add your infrastructure configuration here
|
|
65
|
-
},
|
|
66
|
-
})
|
|
67
|
-
`
|
|
68
|
-
|
|
69
|
-
await writeFile('cloud.config.ts', configContent)
|
|
70
|
-
spinner.succeed('Created cloud.config.ts')
|
|
71
|
-
|
|
72
|
-
// Create .gitignore
|
|
73
|
-
if (!existsSync('.gitignore')) {
|
|
74
|
-
await writeFile('.gitignore', `.env
|
|
75
|
-
.env.*
|
|
76
|
-
node_modules/
|
|
77
|
-
dist/
|
|
78
|
-
cloudformation/
|
|
79
|
-
*.log
|
|
80
|
-
.DS_Store
|
|
81
|
-
`)
|
|
82
|
-
cli.success('Created .gitignore')
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Create cloudformation directory
|
|
86
|
-
if (!existsSync('cloudformation')) {
|
|
87
|
-
await mkdir('cloudformation', { recursive: true })
|
|
88
|
-
cli.success('Created cloudformation/ directory')
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
cli.box(`ts-cloud project initialized!
|
|
92
|
-
|
|
93
|
-
Next steps:
|
|
94
|
-
1. Edit cloud.config.ts to configure your infrastructure
|
|
95
|
-
2. Run 'cloud generate' to create CloudFormation templates
|
|
96
|
-
3. Run 'cloud deploy' to deploy your infrastructure`, 'green')
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
app
|
|
100
|
-
.command('init:server', 'Initialize server-based (EC2) project')
|
|
101
|
-
.action(async () => {
|
|
102
|
-
cli.header('Initializing Server-Based Project')
|
|
103
|
-
// Delegate to init with mode
|
|
104
|
-
await app.parse(['init', '--mode', 'server'])
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
app
|
|
108
|
-
.command('init:serverless', 'Initialize serverless (Fargate/Lambda) project')
|
|
109
|
-
.action(async () => {
|
|
110
|
-
cli.header('Initializing Serverless Project')
|
|
111
|
-
await app.parse(['init', '--mode', 'serverless'])
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
app
|
|
115
|
-
.command('init:hybrid', 'Initialize hybrid project')
|
|
116
|
-
.action(async () => {
|
|
117
|
-
cli.header('Initializing Hybrid Project')
|
|
118
|
-
await app.parse(['init', '--mode', 'hybrid'])
|
|
119
|
-
})
|
|
120
|
-
}
|