@mtndev/cli 1.1.0 → 2.0.1

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 (260) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/cjs/__chunks/VH7oDXx4.cjs +28 -0
  3. package/cjs/commands/aws/ec2/allow-ip/handler.cjs +261 -0
  4. package/cjs/commands/aws/ec2/allow-ip/handler.d.ts +6 -0
  5. package/cjs/commands/aws/ec2/allow-ip/index.cjs +25 -0
  6. package/cjs/commands/aws/ec2/allow-ip/index.d.ts +3 -0
  7. package/cjs/commands/aws/ec2/allow-ip/schema.cjs +33 -0
  8. package/cjs/commands/aws/ec2/allow-ip/schema.d.ts +33 -0
  9. package/cjs/commands/aws/ec2/allow-ip/utils.cjs +379 -0
  10. package/cjs/commands/aws/ec2/allow-ip/utils.d.ts +189 -0
  11. package/cjs/commands/aws/iam/admin-group.cjs +111 -0
  12. package/cjs/commands/aws/iam/admin-group.d.ts +55 -0
  13. package/cjs/commands/aws/iam/break-glass/handler.cjs +127 -0
  14. package/cjs/commands/aws/iam/break-glass/handler.d.ts +7 -0
  15. package/cjs/commands/aws/iam/break-glass/index.cjs +7 -0
  16. package/cjs/commands/aws/iam/break-glass/index.d.ts +2 -0
  17. package/cjs/commands/aws/iam/break-glass/schema.cjs +21 -0
  18. package/cjs/commands/aws/iam/break-glass/schema.d.ts +25 -0
  19. package/cjs/commands/aws/iam/check-admin/handler.cjs +89 -0
  20. package/cjs/commands/aws/iam/check-admin/handler.d.ts +5 -0
  21. package/cjs/commands/aws/iam/check-admin/index.cjs +7 -0
  22. package/cjs/commands/aws/iam/check-admin/index.d.ts +2 -0
  23. package/cjs/commands/aws/iam/check-admin/schema.cjs +19 -0
  24. package/cjs/commands/aws/iam/check-admin/schema.d.ts +19 -0
  25. package/cjs/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
  26. package/cjs/commands/aws/iam/policies/sts-federation.json +11 -0
  27. package/cjs/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
  28. package/cjs/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
  29. package/cjs/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
  30. package/cjs/commands/aws/iam/policies/user-admins-write-list.json +117 -0
  31. package/cjs/commands/aws/iam/remove-admin/handler.cjs +120 -0
  32. package/cjs/commands/aws/iam/remove-admin/handler.d.ts +6 -0
  33. package/cjs/commands/aws/iam/remove-admin/index.cjs +7 -0
  34. package/cjs/commands/aws/iam/remove-admin/index.d.ts +2 -0
  35. package/cjs/commands/aws/iam/remove-admin/schema.cjs +22 -0
  36. package/cjs/commands/aws/iam/remove-admin/schema.d.ts +28 -0
  37. package/cjs/commands/aws/iam/setup-acl/handler.cjs +227 -0
  38. package/cjs/commands/aws/iam/setup-acl/handler.d.ts +6 -0
  39. package/cjs/commands/aws/iam/setup-acl/index.cjs +13 -0
  40. package/cjs/commands/aws/iam/setup-acl/index.d.ts +3 -0
  41. package/cjs/commands/aws/iam/setup-acl/schema.cjs +19 -0
  42. package/cjs/commands/aws/iam/setup-acl/schema.d.ts +24 -0
  43. package/cjs/commands/aws/iam/setup-acl/utils.cjs +305 -0
  44. package/cjs/commands/aws/iam/setup-acl/utils.d.ts +61 -0
  45. package/cjs/commands/aws/iam/users/handler.cjs +59 -0
  46. package/cjs/commands/aws/iam/users/handler.d.ts +5 -0
  47. package/cjs/commands/aws/iam/users/index.cjs +18 -0
  48. package/cjs/commands/aws/iam/users/index.d.ts +3 -0
  49. package/cjs/commands/aws/iam/users/schema.cjs +17 -0
  50. package/cjs/commands/aws/iam/users/schema.d.ts +18 -0
  51. package/cjs/commands/aws/iam/users/utils.cjs +454 -0
  52. package/cjs/commands/aws/iam/users/utils.d.ts +119 -0
  53. package/cjs/commands/aws/index.cjs +223 -0
  54. package/cjs/commands/aws/index.d.ts +14 -0
  55. package/cjs/commands/aws/route53/add-record/handler.cjs +264 -0
  56. package/cjs/commands/aws/route53/add-record/handler.d.ts +36 -0
  57. package/cjs/commands/aws/route53/add-record/index.cjs +26 -0
  58. package/cjs/commands/aws/route53/add-record/index.d.ts +3 -0
  59. package/cjs/commands/aws/route53/add-record/schema.cjs +43 -0
  60. package/cjs/commands/aws/route53/add-record/schema.d.ts +45 -0
  61. package/cjs/commands/aws/route53/add-record/utils.cjs +404 -0
  62. package/cjs/commands/aws/route53/add-record/utils.d.ts +216 -0
  63. package/cjs/commands/aws/route53/remove-record/handler.cjs +114 -0
  64. package/cjs/commands/aws/route53/remove-record/handler.d.ts +6 -0
  65. package/cjs/commands/aws/route53/remove-record/index.cjs +5 -0
  66. package/cjs/commands/aws/route53/remove-record/index.d.ts +2 -0
  67. package/cjs/commands/aws/route53/remove-record/schema.cjs +22 -0
  68. package/cjs/commands/aws/route53/remove-record/schema.d.ts +30 -0
  69. package/cjs/commands/aws/schema.cjs +19 -0
  70. package/cjs/commands/aws/schema.d.ts +13 -0
  71. package/cjs/commands/aws/ses/send-email/handler.cjs +73 -0
  72. package/cjs/commands/aws/ses/send-email/handler.d.ts +5 -0
  73. package/cjs/commands/aws/ses/send-email/index.cjs +9 -0
  74. package/cjs/commands/aws/ses/send-email/index.d.ts +3 -0
  75. package/cjs/commands/aws/ses/send-email/schema.cjs +24 -0
  76. package/cjs/commands/aws/ses/send-email/schema.d.ts +39 -0
  77. package/cjs/commands/aws/ses/send-email/utils.cjs +87 -0
  78. package/cjs/commands/aws/ses/send-email/utils.d.ts +47 -0
  79. package/cjs/commands/aws/ses/smtp-password.cjs +72 -0
  80. package/cjs/commands/aws/ses/smtp-password.d.ts +21 -0
  81. package/cjs/commands/aws/utils/exec-aws.cjs +145 -0
  82. package/cjs/commands/aws/utils/exec-aws.d.ts +79 -0
  83. package/cjs/commands/aws/utils/resolve-policy-path.cjs +15 -0
  84. package/cjs/commands/aws/utils/resolve-policy-path.d.ts +8 -0
  85. package/cjs/commands/aws/utils/resolve-profile.cjs +93 -0
  86. package/cjs/commands/aws/utils/resolve-profile.d.ts +28 -0
  87. package/cjs/commands/aws/utils/tty.cjs +54 -0
  88. package/cjs/commands/aws/utils/tty.d.ts +24 -0
  89. package/cjs/commands/db/create-readonly-user/handler.cjs +254 -0
  90. package/cjs/commands/db/create-readonly-user/handler.d.ts +5 -0
  91. package/cjs/commands/db/create-readonly-user/index.cjs +18 -0
  92. package/cjs/commands/db/create-readonly-user/index.d.ts +3 -0
  93. package/cjs/commands/db/create-readonly-user/mysql.cjs +102 -0
  94. package/cjs/commands/db/create-readonly-user/mysql.d.ts +33 -0
  95. package/cjs/commands/db/create-readonly-user/postgres.cjs +209 -0
  96. package/cjs/commands/db/create-readonly-user/postgres.d.ts +31 -0
  97. package/cjs/commands/db/create-readonly-user/schema.cjs +39 -0
  98. package/cjs/commands/db/create-readonly-user/schema.d.ts +55 -0
  99. package/cjs/commands/db/create-readonly-user/utils.cjs +160 -0
  100. package/cjs/commands/db/create-readonly-user/utils.d.ts +112 -0
  101. package/cjs/commands/db/index.cjs +46 -0
  102. package/cjs/commands/db/index.d.ts +6 -0
  103. package/cjs/commands/doppler/handler.cjs +95 -9
  104. package/cjs/commands/doppler/index.cjs +33 -41
  105. package/cjs/commands/doppler/index.d.ts +1 -0
  106. package/cjs/commands/doppler/schema.cjs +130 -6
  107. package/cjs/commands/doppler/schema.d.ts +233 -17
  108. package/cjs/commands/doppler/set-secret.cjs +378 -0
  109. package/cjs/commands/doppler/set-secret.d.ts +113 -0
  110. package/cjs/commands/doppler/utils/exec.cjs +106 -12
  111. package/cjs/commands/doppler/utils.cjs +412 -30
  112. package/cjs/commands/doppler/utils.d.ts +32 -8
  113. package/cjs/commands/icons/handler.cjs +82 -8
  114. package/cjs/commands/icons/index.cjs +15 -31
  115. package/cjs/commands/icons/schema.cjs +101 -13
  116. package/cjs/commands/icons/schema.d.ts +1 -1
  117. package/cjs/commands/icons/utils.cjs +131 -13
  118. package/cjs/commands/index.cjs +54 -82
  119. package/cjs/commands/schema.cjs +25 -8
  120. package/cjs/index.cjs +3 -4
  121. package/esm/commands/aws/ec2/allow-ip/handler.d.ts +6 -0
  122. package/esm/commands/aws/ec2/allow-ip/handler.js +258 -0
  123. package/esm/commands/aws/ec2/allow-ip/index.d.ts +3 -0
  124. package/esm/commands/aws/ec2/allow-ip/index.js +4 -0
  125. package/esm/commands/aws/ec2/allow-ip/schema.d.ts +33 -0
  126. package/esm/commands/aws/ec2/allow-ip/schema.js +29 -0
  127. package/esm/commands/aws/ec2/allow-ip/utils.d.ts +189 -0
  128. package/esm/commands/aws/ec2/allow-ip/utils.js +363 -0
  129. package/esm/commands/aws/iam/admin-group.d.ts +55 -0
  130. package/esm/commands/aws/iam/admin-group.js +104 -0
  131. package/esm/commands/aws/iam/break-glass/handler.d.ts +7 -0
  132. package/esm/commands/aws/iam/break-glass/handler.js +124 -0
  133. package/esm/commands/aws/iam/break-glass/index.d.ts +2 -0
  134. package/esm/commands/aws/iam/break-glass/index.js +4 -0
  135. package/esm/commands/aws/iam/break-glass/schema.d.ts +25 -0
  136. package/esm/commands/aws/iam/break-glass/schema.js +19 -0
  137. package/esm/commands/aws/iam/check-admin/handler.d.ts +5 -0
  138. package/esm/commands/aws/iam/check-admin/handler.js +86 -0
  139. package/esm/commands/aws/iam/check-admin/index.d.ts +2 -0
  140. package/esm/commands/aws/iam/check-admin/index.js +4 -0
  141. package/esm/commands/aws/iam/check-admin/schema.d.ts +19 -0
  142. package/esm/commands/aws/iam/check-admin/schema.js +17 -0
  143. package/esm/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
  144. package/esm/commands/aws/iam/policies/sts-federation.json +11 -0
  145. package/esm/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
  146. package/esm/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
  147. package/esm/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
  148. package/esm/commands/aws/iam/policies/user-admins-write-list.json +117 -0
  149. package/esm/commands/aws/iam/remove-admin/handler.d.ts +6 -0
  150. package/esm/commands/aws/iam/remove-admin/handler.js +117 -0
  151. package/esm/commands/aws/iam/remove-admin/index.d.ts +2 -0
  152. package/esm/commands/aws/iam/remove-admin/index.js +4 -0
  153. package/esm/commands/aws/iam/remove-admin/schema.d.ts +28 -0
  154. package/esm/commands/aws/iam/remove-admin/schema.js +20 -0
  155. package/esm/commands/aws/iam/setup-acl/handler.d.ts +6 -0
  156. package/esm/commands/aws/iam/setup-acl/handler.js +224 -0
  157. package/esm/commands/aws/iam/setup-acl/index.d.ts +3 -0
  158. package/esm/commands/aws/iam/setup-acl/index.js +4 -0
  159. package/esm/commands/aws/iam/setup-acl/schema.d.ts +24 -0
  160. package/esm/commands/aws/iam/setup-acl/schema.js +18 -0
  161. package/esm/commands/aws/iam/setup-acl/utils.d.ts +61 -0
  162. package/esm/commands/aws/iam/setup-acl/utils.js +298 -0
  163. package/esm/commands/aws/iam/users/handler.d.ts +5 -0
  164. package/esm/commands/aws/iam/users/handler.js +56 -0
  165. package/esm/commands/aws/iam/users/index.d.ts +3 -0
  166. package/esm/commands/aws/iam/users/index.js +4 -0
  167. package/esm/commands/aws/iam/users/schema.d.ts +18 -0
  168. package/esm/commands/aws/iam/users/schema.js +16 -0
  169. package/esm/commands/aws/iam/users/utils.d.ts +119 -0
  170. package/esm/commands/aws/iam/users/utils.js +440 -0
  171. package/esm/commands/aws/index.d.ts +14 -0
  172. package/esm/commands/aws/index.js +142 -0
  173. package/esm/commands/aws/route53/add-record/handler.d.ts +36 -0
  174. package/esm/commands/aws/route53/add-record/handler.js +258 -0
  175. package/esm/commands/aws/route53/add-record/index.d.ts +3 -0
  176. package/esm/commands/aws/route53/add-record/index.js +4 -0
  177. package/esm/commands/aws/route53/add-record/schema.d.ts +45 -0
  178. package/esm/commands/aws/route53/add-record/schema.js +40 -0
  179. package/esm/commands/aws/route53/add-record/utils.d.ts +216 -0
  180. package/esm/commands/aws/route53/add-record/utils.js +389 -0
  181. package/esm/commands/aws/route53/remove-record/handler.d.ts +6 -0
  182. package/esm/commands/aws/route53/remove-record/handler.js +111 -0
  183. package/esm/commands/aws/route53/remove-record/index.d.ts +2 -0
  184. package/esm/commands/aws/route53/remove-record/index.js +3 -0
  185. package/esm/commands/aws/route53/remove-record/schema.d.ts +30 -0
  186. package/esm/commands/aws/route53/remove-record/schema.js +21 -0
  187. package/esm/commands/aws/schema.d.ts +13 -0
  188. package/esm/commands/aws/schema.js +16 -0
  189. package/esm/commands/aws/ses/send-email/handler.d.ts +5 -0
  190. package/esm/commands/aws/ses/send-email/handler.js +70 -0
  191. package/esm/commands/aws/ses/send-email/index.d.ts +3 -0
  192. package/esm/commands/aws/ses/send-email/index.js +4 -0
  193. package/esm/commands/aws/ses/send-email/schema.d.ts +39 -0
  194. package/esm/commands/aws/ses/send-email/schema.js +23 -0
  195. package/esm/commands/aws/ses/send-email/utils.d.ts +47 -0
  196. package/esm/commands/aws/ses/send-email/utils.js +84 -0
  197. package/esm/commands/aws/ses/smtp-password.d.ts +21 -0
  198. package/esm/commands/aws/ses/smtp-password.js +69 -0
  199. package/esm/commands/aws/utils/exec-aws.d.ts +79 -0
  200. package/esm/commands/aws/utils/exec-aws.js +137 -0
  201. package/esm/commands/aws/utils/resolve-policy-path.d.ts +8 -0
  202. package/esm/commands/aws/utils/resolve-policy-path.js +14 -0
  203. package/esm/commands/aws/utils/resolve-profile.d.ts +28 -0
  204. package/esm/commands/aws/utils/resolve-profile.js +88 -0
  205. package/esm/commands/aws/utils/tty.d.ts +24 -0
  206. package/esm/commands/aws/utils/tty.js +51 -0
  207. package/esm/commands/db/create-readonly-user/handler.d.ts +5 -0
  208. package/esm/commands/db/create-readonly-user/handler.js +251 -0
  209. package/esm/commands/db/create-readonly-user/index.d.ts +3 -0
  210. package/esm/commands/db/create-readonly-user/index.js +4 -0
  211. package/esm/commands/db/create-readonly-user/mysql.d.ts +33 -0
  212. package/esm/commands/db/create-readonly-user/mysql.js +98 -0
  213. package/esm/commands/db/create-readonly-user/postgres.d.ts +31 -0
  214. package/esm/commands/db/create-readonly-user/postgres.js +205 -0
  215. package/esm/commands/db/create-readonly-user/schema.d.ts +55 -0
  216. package/esm/commands/db/create-readonly-user/schema.js +35 -0
  217. package/esm/commands/db/create-readonly-user/utils.d.ts +112 -0
  218. package/esm/commands/db/create-readonly-user/utils.js +151 -0
  219. package/esm/commands/db/index.d.ts +6 -0
  220. package/esm/commands/db/index.js +31 -0
  221. package/esm/commands/doppler/handler.js +92 -9
  222. package/esm/commands/doppler/index.d.ts +1 -0
  223. package/esm/commands/doppler/index.js +6 -41
  224. package/esm/commands/doppler/schema.d.ts +233 -17
  225. package/esm/commands/doppler/schema.js +125 -7
  226. package/esm/commands/doppler/set-secret.d.ts +113 -0
  227. package/esm/commands/doppler/set-secret.js +370 -0
  228. package/esm/commands/doppler/utils/exec.js +100 -12
  229. package/esm/commands/doppler/utils.d.ts +32 -8
  230. package/esm/commands/doppler/utils.js +396 -30
  231. package/esm/commands/icons/handler.js +79 -8
  232. package/esm/commands/icons/index.js +4 -31
  233. package/esm/commands/icons/schema.d.ts +1 -1
  234. package/esm/commands/icons/schema.js +97 -15
  235. package/esm/commands/icons/utils.js +125 -13
  236. package/esm/commands/index.js +49 -78
  237. package/esm/commands/schema.js +22 -7
  238. package/esm/index.js +3 -4
  239. package/package.json +12 -2
  240. package/vitest.config.ts +11 -0
  241. package/cjs/__chunks/4GFJUCSP.cjs +0 -52
  242. package/cjs/__chunks/4SFWHCB3.cjs +0 -133
  243. package/cjs/__chunks/B2KFW7T7.cjs +0 -1
  244. package/cjs/__chunks/EMMC33QA.cjs +0 -401
  245. package/cjs/__chunks/INFOPAHN.cjs +0 -117
  246. package/cjs/__chunks/J36P6UNE.cjs +0 -75
  247. package/cjs/__chunks/NIMXXHJQ.cjs +0 -92
  248. package/cjs/__chunks/NSRFG4DF.cjs +0 -100
  249. package/cjs/__chunks/WNJ3ZYLI.cjs +0 -1
  250. package/cjs/__chunks/ZMDIOZPT.cjs +0 -22
  251. package/esm/__chunks/46HGXFME.js +0 -0
  252. package/esm/__chunks/6G4PXXKF.js +0 -75
  253. package/esm/__chunks/6L5RNR7G.js +0 -100
  254. package/esm/__chunks/FL7AILGH.js +0 -133
  255. package/esm/__chunks/HJSXC6HP.js +0 -117
  256. package/esm/__chunks/O262GK4B.js +0 -401
  257. package/esm/__chunks/O3CCA76Q.js +0 -22
  258. package/esm/__chunks/SJXQJ7RS.js +0 -92
  259. package/esm/__chunks/SNCKIAOR.js +0 -0
  260. package/esm/__chunks/X3R5PSWH.js +0 -52
@@ -0,0 +1,19 @@
1
+ import { profileField, verboseField } from "../../schema.js";
2
+ import { ADMIN_GROUP_NAME } from "../admin-group.js";
3
+ import { z } from "zod";
4
+ //#region src/commands/aws/iam/break-glass/schema.js
5
+ /**
6
+ * Zod schema for `aws iam break-glass` options.
7
+ */
8
+ const breakGlassOptionsSchema = z.object({
9
+ profile: profileField,
10
+ user: z.array(z.string()).optional().default([]).describe("Grant break-glass to this user (repeatable). Default: your own IAM user"),
11
+ yes: z.boolean().optional().default(false).describe("Skip the confirmation prompt"),
12
+ dryRun: z.boolean().optional().default(false).describe("Preview the grant without changing anything"),
13
+ verbose: verboseField
14
+ });
15
+ /**
16
+ * @typedef {z.infer<typeof breakGlassOptionsSchema>} BreakGlassOptions
17
+ */
18
+ //#endregion
19
+ export { ADMIN_GROUP_NAME, breakGlassOptionsSchema };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * `aws iam check-admin` handler: alert if anyone is a member of acl-admin-do-not-use.
3
+ * @param {unknown} options
4
+ */
5
+ export function checkAdminCommand(options: unknown): Promise<void>;
@@ -0,0 +1,86 @@
1
+ import { requireCommands } from "../../utils/exec-aws.js";
2
+ import { ADMIN_GROUP_NAME, resolveAdminScanProfiles, resolveProfileScan } from "../admin-group.js";
3
+ import { checkAdminOptionsSchema } from "./schema.js";
4
+ import chalk from "chalk";
5
+ import { ZodError } from "zod";
6
+ //#region src/commands/aws/iam/check-admin/handler.js
7
+ /**
8
+ * `aws iam check-admin` handler: alert if anyone is a member of acl-admin-do-not-use.
9
+ * @param {unknown} options
10
+ */
11
+ async function checkAdminCommand(options) {
12
+ try {
13
+ const { profile, all, verbose } = checkAdminOptionsSchema.parse(options);
14
+ requireCommands(["aws"]);
15
+ if (all || !(profile ?? process.env.AWS_PROFILE)) requireCommands(["aws-vault"]);
16
+ /** @type {string[]} */
17
+ let profiles;
18
+ try {
19
+ profiles = resolveAdminScanProfiles({
20
+ profile,
21
+ all
22
+ });
23
+ } catch (resolveError) {
24
+ if (resolveError instanceof Error && resolveError.message === "No aws-vault profiles with credentials found.") {
25
+ console.error(chalk.red(resolveError.message));
26
+ process.exit(1);
27
+ }
28
+ throw resolveError;
29
+ }
30
+ console.log(chalk.blue(`\n==> Checking ${profiles.length} profile(s) for ${ADMIN_GROUP_NAME}\n`));
31
+ let ok = 0;
32
+ let alert = 0;
33
+ let skip = 0;
34
+ for (const candidate of profiles) {
35
+ const scan = resolveProfileScan({
36
+ profile: candidate,
37
+ verbose
38
+ });
39
+ if (!scan) {
40
+ skip += 1;
41
+ continue;
42
+ }
43
+ if (scan.users.length === 0) {
44
+ console.log(chalk.green(`OK ${candidate} (${scan.accountId}) — ${ADMIN_GROUP_NAME}: 0 users`));
45
+ ok += 1;
46
+ } else {
47
+ console.log(chalk.red(`ALERT ${candidate} (${scan.accountId}) — ${ADMIN_GROUP_NAME}: ${scan.users.length} user(s): ${scan.users.join(", ")}`));
48
+ alert += 1;
49
+ }
50
+ }
51
+ console.log(chalk.blue("\n==> Summary"));
52
+ console.log(` Profiles scanned: ${profiles.length}`);
53
+ console.log(` OK (empty group): ${ok}`);
54
+ console.log(` ALERT (has users): ${alert}`);
55
+ console.log(` Skipped (silent): ${skip}`);
56
+ if (alert > 0) {
57
+ console.log(chalk.red(`\nRemove users from ${ADMIN_GROUP_NAME} when break-glass access is no longer needed.`));
58
+ process.exit(1);
59
+ }
60
+ if (ok === 0) {
61
+ console.log(chalk.yellow(`\nNo profiles returned IAM access for ${ADMIN_GROUP_NAME}.`));
62
+ console.log(chalk.yellow(" Use a profile with iam:GetGroup (e.g. md-*-iam-admin) or run with --verbose."));
63
+ }
64
+ } catch (error) {
65
+ if (error instanceof ZodError) {
66
+ console.error(chalk.red("\n❌ Invalid command options:"));
67
+ error.errors.forEach((err) => {
68
+ console.error(chalk.red(` ${err.path.join(".")}: ${err.message}`));
69
+ });
70
+ process.exit(1);
71
+ }
72
+ const verbose = options?.verbose || false;
73
+ console.error(chalk.red("\n❌ check-admin failed:"));
74
+ if (error instanceof Error) {
75
+ console.error(chalk.red(` ${error.message}`));
76
+ if (verbose && error.stack) {
77
+ console.error(chalk.gray("\nStack trace:"));
78
+ console.error(chalk.gray(error.stack));
79
+ }
80
+ } else console.error(chalk.red(` ${String(error)}`));
81
+ console.error(chalk.yellow("\n💡 Requires the AWS CLI, and aws-vault when scanning multiple profiles.\n"));
82
+ process.exit(1);
83
+ }
84
+ }
85
+ //#endregion
86
+ export { checkAdminCommand };
@@ -0,0 +1,2 @@
1
+ export * from "./handler.js";
2
+ export * from "./schema.js";
@@ -0,0 +1,4 @@
1
+ import { ADMIN_GROUP_NAME } from "../admin-group.js";
2
+ import { checkAdminOptionsSchema } from "./schema.js";
3
+ import { checkAdminCommand } from "./handler.js";
4
+ export { ADMIN_GROUP_NAME, checkAdminCommand, checkAdminOptionsSchema };
@@ -0,0 +1,19 @@
1
+ export { ADMIN_GROUP_NAME } from "../admin-group.js";
2
+ /**
3
+ * Zod schema for `aws iam check-admin` options.
4
+ */
5
+ export const checkAdminOptionsSchema: z.ZodObject<{
6
+ profile: z.ZodOptional<z.ZodString>;
7
+ all: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
8
+ verbose: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ verbose: boolean;
11
+ all: boolean;
12
+ profile?: string | undefined;
13
+ }, {
14
+ profile?: string | undefined;
15
+ verbose?: boolean | undefined;
16
+ all?: boolean | undefined;
17
+ }>;
18
+ export type CheckAdminOptions = z.infer<typeof checkAdminOptionsSchema>;
19
+ import { z } from "zod";
@@ -0,0 +1,17 @@
1
+ import { profileField, verboseField } from "../../schema.js";
2
+ import { ADMIN_GROUP_NAME } from "../admin-group.js";
3
+ import { z } from "zod";
4
+ //#region src/commands/aws/iam/check-admin/schema.js
5
+ /**
6
+ * Zod schema for `aws iam check-admin` options.
7
+ */
8
+ const checkAdminOptionsSchema = z.object({
9
+ profile: profileField,
10
+ all: z.boolean().optional().default(false).describe("Scan every aws-vault profile (default only when --profile and AWS_PROFILE are unset)"),
11
+ verbose: verboseField
12
+ });
13
+ /**
14
+ * @typedef {z.infer<typeof checkAdminOptionsSchema>} CheckAdminOptions
15
+ */
16
+ //#endregion
17
+ export { ADMIN_GROUP_NAME, checkAdminOptionsSchema };
@@ -0,0 +1,20 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Sid": "DenyNonS3Services",
6
+ "Effect": "Deny",
7
+ "NotAction": [
8
+ "s3:*",
9
+ "logs:*",
10
+ "sts:AssumeRole",
11
+ "iam:PassRole",
12
+ "kms:Decrypt",
13
+ "kms:GenerateDataKey",
14
+ "kms:DescribeKey",
15
+ "lambda:InvokeFunction"
16
+ ],
17
+ "Resource": "*"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Sid": "StsFederation",
6
+ "Effect": "Allow",
7
+ "Action": ["sts:GetFederationToken", "sts:GetCallerIdentity"],
8
+ "Resource": "*"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,175 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Sid": "DenyAIServices",
6
+ "Effect": "Deny",
7
+ "Action": [
8
+ "bedrock:*",
9
+ "sagemaker:*",
10
+ "comprehend:*",
11
+ "comprehendmedical:*",
12
+ "rekognition:*",
13
+ "textract:*",
14
+ "personalize:*",
15
+ "forecast:*",
16
+ "lex:*",
17
+ "polly:*",
18
+ "translate:*",
19
+ "transcribe:*",
20
+ "kendra:*",
21
+ "q:*"
22
+ ],
23
+ "Resource": "*"
24
+ },
25
+ {
26
+ "Sid": "DenyOrgAndAccountWrites",
27
+ "Effect": "Deny",
28
+ "Action": [
29
+ "organizations:*",
30
+ "account:CloseAccount",
31
+ "account:DeleteAlternateContact",
32
+ "account:PutAlternateContact",
33
+ "account:PutChallengeQuestions",
34
+ "account:EnableRegion",
35
+ "account:DisableRegion",
36
+ "account:PutAccountName"
37
+ ],
38
+ "Resource": "*"
39
+ },
40
+ {
41
+ "Sid": "DenyBillingMutations",
42
+ "Effect": "Deny",
43
+ "Action": [
44
+ "aws-portal:Modify*",
45
+ "billing:Update*",
46
+ "billing:Put*",
47
+ "billing:Delete*",
48
+ "budgets:Modify*",
49
+ "budgets:Create*",
50
+ "budgets:Delete*",
51
+ "savingsplans:Create*",
52
+ "savingsplans:Delete*",
53
+ "supportplans:Create*",
54
+ "supportplans:Delete*",
55
+ "purchase-orders:Modify*",
56
+ "purchase-orders:Create*",
57
+ "cur:Put*",
58
+ "cur:Delete*"
59
+ ],
60
+ "Resource": "*"
61
+ },
62
+ {
63
+ "Sid": "DenyCloudTrailTampering",
64
+ "Effect": "Deny",
65
+ "Action": [
66
+ "cloudtrail:StopLogging",
67
+ "cloudtrail:DeleteTrail",
68
+ "cloudtrail:UpdateTrail",
69
+ "cloudtrail:PutEventSelectors",
70
+ "cloudtrail:DeleteEventDataStore"
71
+ ],
72
+ "Resource": "*"
73
+ },
74
+ {
75
+ "Sid": "DenyExpensiveServices",
76
+ "Effect": "Deny",
77
+ "Action": [
78
+ "airflow:CreateEnvironment",
79
+ "airflow:UpdateEnvironment",
80
+ "mwaa:*",
81
+ "transfer:CreateServer",
82
+ "transfer:UpdateServer",
83
+ "transfer:StartServer",
84
+ "shield:CreateSubscription",
85
+ "shield:CreateProtection",
86
+ "shield:CreateProtectionGroup"
87
+ ],
88
+ "Resource": "*"
89
+ },
90
+ {
91
+ "Sid": "DenyKMSDestruction",
92
+ "Effect": "Deny",
93
+ "Action": [
94
+ "kms:ScheduleKeyDeletion",
95
+ "kms:DisableKey",
96
+ "kms:DisableKeyRotation"
97
+ ],
98
+ "Resource": "*"
99
+ },
100
+ {
101
+ "Sid": "DenyNeptuneViaRds",
102
+ "Effect": "Deny",
103
+ "Action": [
104
+ "rds:CreateDBCluster",
105
+ "rds:CreateDBInstance",
106
+ "rds:ModifyDBCluster",
107
+ "rds:ModifyDBInstance",
108
+ "rds:RestoreDBClusterFromSnapshot",
109
+ "rds:RestoreDBInstanceFromDBSnapshot"
110
+ ],
111
+ "Resource": "*",
112
+ "Condition": {
113
+ "StringEquals": {
114
+ "rds:DatabaseEngine": "neptune"
115
+ }
116
+ }
117
+ },
118
+ {
119
+ "Sid": "DenyExpensiveGpuEc2",
120
+ "Effect": "Deny",
121
+ "Action": [
122
+ "ec2:RunInstances",
123
+ "ec2:RequestSpotInstances",
124
+ "ec2:RequestSpotFleet",
125
+ "ec2:ModifyInstanceAttribute"
126
+ ],
127
+ "Resource": "*",
128
+ "Condition": {
129
+ "StringLike": {
130
+ "ec2:InstanceType": [
131
+ "p2.*",
132
+ "p3.*",
133
+ "p4d.*",
134
+ "p4de.*",
135
+ "p5.*",
136
+ "p5d.*",
137
+ "p5e.*",
138
+ "p5en.*",
139
+ "p6*",
140
+ "g3.*",
141
+ "g3s.*",
142
+ "g4dn.*",
143
+ "g4ad.*",
144
+ "g5.*",
145
+ "g5g.*",
146
+ "g6.*",
147
+ "g6e.*",
148
+ "g6f.*",
149
+ "inf1.*",
150
+ "inf2.*",
151
+ "trn1.*",
152
+ "trn1n.*",
153
+ "trn2.*",
154
+ "trn2a.*",
155
+ "trn2i.*",
156
+ "dl1.*",
157
+ "dl2q.*",
158
+ "f1.*",
159
+ "f2.*",
160
+ "vt1.*",
161
+ "hpc6id.*",
162
+ "u-12tb1.metal",
163
+ "u-18tb1.metal",
164
+ "u-24tb1.metal",
165
+ "u-6tb1.56xlarge",
166
+ "u-9tb1.112xlarge",
167
+ "x2iedn.*",
168
+ "x2idn.*",
169
+ "x2iezn.*"
170
+ ]
171
+ }
172
+ }
173
+ }
174
+ ]
175
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Sid": "DenyNonApprovedRegions",
6
+ "Effect": "Deny",
7
+ "NotAction": [
8
+ "iam:*",
9
+ "organizations:*",
10
+ "route53:*",
11
+ "route53domains:*",
12
+ "cloudfront:*",
13
+ "waf:*",
14
+ "wafv2:*",
15
+ "shield:*",
16
+ "globalaccelerator:*",
17
+ "sts:*",
18
+ "support:*",
19
+ "supportplans:*",
20
+ "trustedadvisor:*",
21
+ "health:*",
22
+ "budgets:*",
23
+ "ce:*",
24
+ "cur:*",
25
+ "account:*",
26
+ "billing:*",
27
+ "aws-portal:*",
28
+ "tag:*",
29
+ "resource-groups:*",
30
+ "ram:*",
31
+ "cloudshell:*"
32
+ ],
33
+ "Resource": "*",
34
+ "Condition": {
35
+ "StringNotEquals": {
36
+ "aws:RequestedRegion": ["us-east-1", "us-east-2", "us-west-2"]
37
+ }
38
+ }
39
+ }
40
+ ]
41
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Sid": "ViewAccountInfo",
6
+ "Effect": "Allow",
7
+ "Action": ["iam:GetAccountPasswordPolicy", "iam:ListVirtualMFADevices"],
8
+ "Resource": "*"
9
+ },
10
+ {
11
+ "Sid": "ManageOwnPassword",
12
+ "Effect": "Allow",
13
+ "Action": ["iam:ChangePassword", "iam:GetUser"],
14
+ "Resource": "arn:aws:iam::*:user/${aws:username}"
15
+ },
16
+ {
17
+ "Sid": "ManageOwnAccessKeys",
18
+ "Effect": "Allow",
19
+ "Action": [
20
+ "iam:CreateAccessKey",
21
+ "iam:DeleteAccessKey",
22
+ "iam:ListAccessKeys",
23
+ "iam:UpdateAccessKey",
24
+ "iam:GetAccessKeyLastUsed"
25
+ ],
26
+ "Resource": "arn:aws:iam::*:user/${aws:username}"
27
+ },
28
+ {
29
+ "Sid": "ManageOwnMFA",
30
+ "Effect": "Allow",
31
+ "Action": [
32
+ "iam:CreateVirtualMFADevice",
33
+ "iam:DeleteVirtualMFADevice",
34
+ "iam:EnableMFADevice",
35
+ "iam:ListMFADevices",
36
+ "iam:ResyncMFADevice",
37
+ "iam:DeactivateMFADevice"
38
+ ],
39
+ "Resource": [
40
+ "arn:aws:iam::*:mfa/${aws:username}",
41
+ "arn:aws:iam::*:user/${aws:username}"
42
+ ]
43
+ },
44
+ {
45
+ "Sid": "ValidateIAMPolicies",
46
+ "Effect": "Allow",
47
+ "Action": [
48
+ "access-analyzer:ValidatePolicy",
49
+ "access-analyzer:CheckAccessNotGranted",
50
+ "access-analyzer:CheckNoNewAccess",
51
+ "access-analyzer:CheckNoPublicAccess"
52
+ ],
53
+ "Resource": "*"
54
+ }
55
+ ]
56
+ }
@@ -0,0 +1,117 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Sid": "WriteComputeAndNetwork",
6
+ "Effect": "Allow",
7
+ "Action": [
8
+ "ec2:*",
9
+ "elasticloadbalancing:*",
10
+ "autoscaling:*",
11
+ "application-autoscaling:*",
12
+ "lambda:*",
13
+ "ecs:*",
14
+ "ecr:*",
15
+ "elasticfilesystem:*",
16
+ "route53:*",
17
+ "route53domains:*",
18
+ "cloudfront:*",
19
+ "apigateway:*",
20
+ "servicediscovery:*"
21
+ ],
22
+ "Resource": "*"
23
+ },
24
+ {
25
+ "Sid": "WriteDataAndStorage",
26
+ "Effect": "Allow",
27
+ "Action": ["s3:*", "rds:*", "pi:*", "dynamodb:*", "backup:*"],
28
+ "Resource": "*"
29
+ },
30
+ {
31
+ "Sid": "WriteDeploymentAndOps",
32
+ "Effect": "Allow",
33
+ "Action": [
34
+ "cloudformation:*",
35
+ "cloudwatch:*",
36
+ "logs:*",
37
+ "events:*",
38
+ "scheduler:*",
39
+ "ssm:*",
40
+ "cloudtrail:*",
41
+ "xray:*",
42
+ "states:*",
43
+ "cloudshell:*"
44
+ ],
45
+ "Resource": "*"
46
+ },
47
+ {
48
+ "Sid": "WriteSecurityAndMessaging",
49
+ "Effect": "Allow",
50
+ "Action": [
51
+ "acm:*",
52
+ "secretsmanager:*",
53
+ "kms:*",
54
+ "sns:*",
55
+ "sqs:*",
56
+ "ses:*"
57
+ ],
58
+ "Resource": "*"
59
+ },
60
+ {
61
+ "Sid": "WriteResourceOrganization",
62
+ "Effect": "Allow",
63
+ "Action": ["resource-groups:*", "tag:*", "ram:*"],
64
+ "Resource": "*"
65
+ },
66
+ {
67
+ "Sid": "SupportAndHealth",
68
+ "Effect": "Allow",
69
+ "Action": [
70
+ "support:*",
71
+ "supportplans:Get*",
72
+ "supportplans:List*",
73
+ "health:*",
74
+ "trustedadvisor:*"
75
+ ],
76
+ "Resource": "*"
77
+ },
78
+ {
79
+ "Sid": "Sts",
80
+ "Effect": "Allow",
81
+ "Action": [
82
+ "sts:GetCallerIdentity",
83
+ "sts:GetFederationToken",
84
+ "sts:GetSessionToken"
85
+ ],
86
+ "Resource": "*"
87
+ },
88
+ {
89
+ "Sid": "IamPassRoleForServices",
90
+ "Effect": "Allow",
91
+ "Action": "iam:PassRole",
92
+ "Resource": "arn:aws:iam::*:role/*",
93
+ "Condition": {
94
+ "StringEquals": {
95
+ "iam:PassedToService": [
96
+ "ec2.amazonaws.com",
97
+ "lambda.amazonaws.com",
98
+ "ecs.amazonaws.com",
99
+ "ecs-tasks.amazonaws.com",
100
+ "elasticloadbalancing.amazonaws.com",
101
+ "events.amazonaws.com",
102
+ "apigateway.amazonaws.com",
103
+ "rds.amazonaws.com",
104
+ "backup.amazonaws.com",
105
+ "cloudformation.amazonaws.com"
106
+ ]
107
+ }
108
+ }
109
+ },
110
+ {
111
+ "Sid": "ServiceLinkedRoles",
112
+ "Effect": "Allow",
113
+ "Action": ["iam:CreateServiceLinkedRole", "iam:DeleteServiceLinkedRole"],
114
+ "Resource": "*"
115
+ }
116
+ ]
117
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * `aws iam remove-admin` handler: remove users from the break-glass
3
+ * acl-admin-do-not-use group, either for one profile or every aws-vault profile.
4
+ * @param {unknown} options
5
+ */
6
+ export function removeAdminCommand(options: unknown): Promise<void>;