@mtndev/cli 2.0.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 (264) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/cjs/__chunks/VH7oDXx4.cjs +28 -0
  3. package/cjs/commands/aws/ec2/allow-ip/handler.cjs +261 -12
  4. package/cjs/commands/aws/ec2/allow-ip/index.cjs +25 -55
  5. package/cjs/commands/aws/ec2/allow-ip/schema.cjs +33 -13
  6. package/cjs/commands/aws/ec2/allow-ip/utils.cjs +379 -39
  7. package/cjs/commands/aws/iam/admin-group.cjs +111 -15
  8. package/cjs/commands/aws/iam/break-glass/handler.cjs +127 -12
  9. package/cjs/commands/aws/iam/break-glass/index.cjs +7 -19
  10. package/cjs/commands/aws/iam/break-glass/schema.cjs +21 -12
  11. package/cjs/commands/aws/iam/check-admin/handler.cjs +89 -10
  12. package/cjs/commands/aws/iam/check-admin/index.cjs +7 -17
  13. package/cjs/commands/aws/iam/check-admin/schema.cjs +19 -12
  14. package/cjs/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
  15. package/cjs/commands/aws/iam/policies/sts-federation.json +11 -0
  16. package/cjs/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
  17. package/cjs/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
  18. package/cjs/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
  19. package/cjs/commands/aws/iam/policies/user-admins-write-list.json +117 -0
  20. package/cjs/commands/aws/iam/remove-admin/handler.cjs +120 -11
  21. package/cjs/commands/aws/iam/remove-admin/index.cjs +7 -18
  22. package/cjs/commands/aws/iam/remove-admin/schema.cjs +22 -12
  23. package/cjs/commands/aws/iam/setup-acl/handler.cjs +227 -14
  24. package/cjs/commands/aws/iam/setup-acl/index.cjs +13 -33
  25. package/cjs/commands/aws/iam/setup-acl/schema.cjs +19 -7
  26. package/cjs/commands/aws/iam/setup-acl/utils.cjs +305 -20
  27. package/cjs/commands/aws/iam/users/handler.cjs +59 -12
  28. package/cjs/commands/aws/iam/users/index.cjs +18 -41
  29. package/cjs/commands/aws/iam/users/schema.cjs +17 -7
  30. package/cjs/commands/aws/iam/users/utils.cjs +454 -30
  31. package/cjs/commands/aws/index.cjs +223 -229
  32. package/cjs/commands/aws/route53/add-record/handler.cjs +264 -18
  33. package/cjs/commands/aws/route53/add-record/index.cjs +26 -57
  34. package/cjs/commands/aws/route53/add-record/schema.cjs +43 -11
  35. package/cjs/commands/aws/route53/add-record/utils.cjs +404 -37
  36. package/cjs/commands/aws/route53/remove-record/handler.cjs +114 -14
  37. package/cjs/commands/aws/route53/remove-record/index.cjs +5 -18
  38. package/cjs/commands/aws/route53/remove-record/schema.cjs +22 -8
  39. package/cjs/commands/aws/schema.cjs +19 -10
  40. package/cjs/commands/aws/ses/send-email/handler.cjs +73 -12
  41. package/cjs/commands/aws/ses/send-email/index.cjs +9 -23
  42. package/cjs/commands/aws/ses/send-email/schema.cjs +24 -7
  43. package/cjs/commands/aws/ses/send-email/utils.cjs +87 -11
  44. package/cjs/commands/aws/ses/smtp-password.cjs +72 -10
  45. package/cjs/commands/aws/utils/exec-aws.cjs +145 -16
  46. package/cjs/commands/aws/utils/resolve-policy-path.cjs +15 -6
  47. package/cjs/commands/aws/utils/resolve-profile.cjs +93 -11
  48. package/cjs/commands/aws/utils/tty.cjs +54 -10
  49. package/cjs/commands/db/create-readonly-user/handler.cjs +254 -11
  50. package/cjs/commands/db/create-readonly-user/index.cjs +18 -40
  51. package/cjs/commands/db/create-readonly-user/mysql.cjs +102 -9
  52. package/cjs/commands/db/create-readonly-user/postgres.cjs +209 -9
  53. package/cjs/commands/db/create-readonly-user/schema.cjs +39 -12
  54. package/cjs/commands/db/create-readonly-user/utils.cjs +160 -22
  55. package/cjs/commands/db/index.cjs +46 -44
  56. package/cjs/commands/doppler/handler.cjs +95 -11
  57. package/cjs/commands/doppler/index.cjs +33 -68
  58. package/cjs/commands/doppler/schema.cjs +130 -14
  59. package/cjs/commands/doppler/set-secret.cjs +378 -19
  60. package/cjs/commands/doppler/utils/exec.cjs +106 -12
  61. package/cjs/commands/doppler/utils.cjs +412 -34
  62. package/cjs/commands/icons/handler.cjs +82 -8
  63. package/cjs/commands/icons/index.cjs +15 -31
  64. package/cjs/commands/icons/schema.cjs +101 -13
  65. package/cjs/commands/icons/utils.cjs +131 -13
  66. package/cjs/commands/index.cjs +54 -161
  67. package/cjs/commands/schema.cjs +25 -8
  68. package/cjs/index.cjs +3 -4
  69. package/esm/commands/aws/ec2/allow-ip/handler.js +258 -12
  70. package/esm/commands/aws/ec2/allow-ip/index.js +4 -55
  71. package/esm/commands/aws/ec2/allow-ip/schema.js +29 -13
  72. package/esm/commands/aws/ec2/allow-ip/utils.js +363 -39
  73. package/esm/commands/aws/iam/admin-group.js +104 -15
  74. package/esm/commands/aws/iam/break-glass/handler.js +124 -12
  75. package/esm/commands/aws/iam/break-glass/index.js +4 -19
  76. package/esm/commands/aws/iam/break-glass/schema.js +19 -12
  77. package/esm/commands/aws/iam/check-admin/handler.js +86 -10
  78. package/esm/commands/aws/iam/check-admin/index.js +4 -17
  79. package/esm/commands/aws/iam/check-admin/schema.js +17 -12
  80. package/esm/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
  81. package/esm/commands/aws/iam/policies/sts-federation.json +11 -0
  82. package/esm/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
  83. package/esm/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
  84. package/esm/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
  85. package/esm/commands/aws/iam/policies/user-admins-write-list.json +117 -0
  86. package/esm/commands/aws/iam/remove-admin/handler.js +117 -11
  87. package/esm/commands/aws/iam/remove-admin/index.js +4 -18
  88. package/esm/commands/aws/iam/remove-admin/schema.js +20 -12
  89. package/esm/commands/aws/iam/setup-acl/handler.js +224 -14
  90. package/esm/commands/aws/iam/setup-acl/index.js +4 -33
  91. package/esm/commands/aws/iam/setup-acl/schema.js +18 -7
  92. package/esm/commands/aws/iam/setup-acl/utils.js +298 -20
  93. package/esm/commands/aws/iam/users/handler.js +56 -12
  94. package/esm/commands/aws/iam/users/index.js +4 -41
  95. package/esm/commands/aws/iam/users/schema.js +16 -7
  96. package/esm/commands/aws/iam/users/utils.js +440 -30
  97. package/esm/commands/aws/index.js +142 -229
  98. package/esm/commands/aws/route53/add-record/handler.js +258 -18
  99. package/esm/commands/aws/route53/add-record/index.js +4 -57
  100. package/esm/commands/aws/route53/add-record/schema.js +40 -11
  101. package/esm/commands/aws/route53/add-record/utils.js +389 -37
  102. package/esm/commands/aws/route53/remove-record/handler.js +111 -14
  103. package/esm/commands/aws/route53/remove-record/index.js +3 -18
  104. package/esm/commands/aws/route53/remove-record/schema.js +21 -8
  105. package/esm/commands/aws/schema.js +16 -10
  106. package/esm/commands/aws/ses/send-email/handler.js +70 -12
  107. package/esm/commands/aws/ses/send-email/index.js +4 -23
  108. package/esm/commands/aws/ses/send-email/schema.js +23 -7
  109. package/esm/commands/aws/ses/send-email/utils.js +84 -11
  110. package/esm/commands/aws/ses/smtp-password.js +69 -10
  111. package/esm/commands/aws/utils/exec-aws.js +136 -15
  112. package/esm/commands/aws/utils/resolve-policy-path.js +14 -6
  113. package/esm/commands/aws/utils/resolve-profile.js +88 -11
  114. package/esm/commands/aws/utils/tty.js +51 -10
  115. package/esm/commands/db/create-readonly-user/handler.js +251 -11
  116. package/esm/commands/db/create-readonly-user/index.js +4 -40
  117. package/esm/commands/db/create-readonly-user/mysql.js +98 -9
  118. package/esm/commands/db/create-readonly-user/postgres.js +205 -9
  119. package/esm/commands/db/create-readonly-user/schema.js +35 -12
  120. package/esm/commands/db/create-readonly-user/utils.js +151 -22
  121. package/esm/commands/db/index.js +31 -44
  122. package/esm/commands/doppler/handler.js +92 -11
  123. package/esm/commands/doppler/index.js +6 -68
  124. package/esm/commands/doppler/schema.js +125 -15
  125. package/esm/commands/doppler/set-secret.js +370 -19
  126. package/esm/commands/doppler/utils/exec.js +100 -12
  127. package/esm/commands/doppler/utils.js +396 -34
  128. package/esm/commands/icons/handler.js +79 -8
  129. package/esm/commands/icons/index.js +4 -31
  130. package/esm/commands/icons/schema.js +97 -15
  131. package/esm/commands/icons/utils.js +125 -13
  132. package/esm/commands/index.js +47 -155
  133. package/esm/commands/schema.js +22 -7
  134. package/esm/index.js +3 -4
  135. package/package.json +5 -2
  136. package/vitest.config.ts +11 -0
  137. package/cjs/__chunks/2FSYDFUV.cjs +0 -146
  138. package/cjs/__chunks/3A5ZYU5M.cjs +0 -105
  139. package/cjs/__chunks/3BY5Y4W7.cjs +0 -1
  140. package/cjs/__chunks/3NOHGUCF.cjs +0 -9
  141. package/cjs/__chunks/3T2LXW7J.cjs +0 -387
  142. package/cjs/__chunks/4SFWHCB3.cjs +0 -133
  143. package/cjs/__chunks/4XT5JEAS.cjs +0 -1
  144. package/cjs/__chunks/AZEB4H4I.cjs +0 -208
  145. package/cjs/__chunks/B2KFW7T7.cjs +0 -1
  146. package/cjs/__chunks/B5ENMOCD.cjs +0 -288
  147. package/cjs/__chunks/B6XM5KSF.cjs +0 -338
  148. package/cjs/__chunks/BDU2UCE5.cjs +0 -1
  149. package/cjs/__chunks/BLMSMR5E.cjs +0 -46
  150. package/cjs/__chunks/CMUD7LLN.cjs +0 -47
  151. package/cjs/__chunks/DTQ2LB3I.cjs +0 -49
  152. package/cjs/__chunks/FM5MVRQF.cjs +0 -23
  153. package/cjs/__chunks/FRHST54J.cjs +0 -135
  154. package/cjs/__chunks/FU4VP2LN.cjs +0 -1
  155. package/cjs/__chunks/G5K4PVIL.cjs +0 -26
  156. package/cjs/__chunks/GU3R54MK.cjs +0 -127
  157. package/cjs/__chunks/GUL36IFZ.cjs +0 -61
  158. package/cjs/__chunks/GZMTNK5N.cjs +0 -1
  159. package/cjs/__chunks/H74JSDBU.cjs +0 -30
  160. package/cjs/__chunks/INFOPAHN.cjs +0 -117
  161. package/cjs/__chunks/J36P6UNE.cjs +0 -75
  162. package/cjs/__chunks/JB7T7PKQ.cjs +0 -538
  163. package/cjs/__chunks/JSL2JDMW.cjs +0 -1
  164. package/cjs/__chunks/K4QNHRTP.cjs +0 -163
  165. package/cjs/__chunks/KU76LC42.cjs +0 -192
  166. package/cjs/__chunks/LFDSHANP.cjs +0 -34
  167. package/cjs/__chunks/LHE24ECK.cjs +0 -192
  168. package/cjs/__chunks/LIKQ3SI4.cjs +0 -1
  169. package/cjs/__chunks/LXDF5QVZ.cjs +0 -313
  170. package/cjs/__chunks/LXOOJR2R.cjs +0 -74
  171. package/cjs/__chunks/N5MXFOQZ.cjs +0 -167
  172. package/cjs/__chunks/N7D56LPP.cjs +0 -25
  173. package/cjs/__chunks/NFXQNOQH.cjs +0 -393
  174. package/cjs/__chunks/NIMXXHJQ.cjs +0 -92
  175. package/cjs/__chunks/NLKJIUEX.cjs +0 -126
  176. package/cjs/__chunks/NT2XXAI6.cjs +0 -89
  177. package/cjs/__chunks/NWZGFHKH.cjs +0 -121
  178. package/cjs/__chunks/R3GUC7O7.cjs +0 -110
  179. package/cjs/__chunks/RPVAXPJ4.cjs +0 -1
  180. package/cjs/__chunks/S3LVCWPN.cjs +0 -23
  181. package/cjs/__chunks/SBBNW2BF.cjs +0 -249
  182. package/cjs/__chunks/T2A7TN4F.cjs +0 -81
  183. package/cjs/__chunks/TKNNDDIB.cjs +0 -97
  184. package/cjs/__chunks/TNSRDJPR.cjs +0 -1
  185. package/cjs/__chunks/UWHPE2GI.cjs +0 -20
  186. package/cjs/__chunks/W6K7BV74.cjs +0 -1
  187. package/cjs/__chunks/WBOQ6AUN.cjs +0 -320
  188. package/cjs/__chunks/WHGN5PZI.cjs +0 -299
  189. package/cjs/__chunks/WOYF2L6T.cjs +0 -11
  190. package/cjs/__chunks/X26XY2N6.cjs +0 -18
  191. package/cjs/__chunks/XMKOKRXZ.cjs +0 -16
  192. package/cjs/__chunks/XTJPQ3EX.cjs +0 -1
  193. package/cjs/__chunks/YRHFKTW2.cjs +0 -63
  194. package/cjs/__chunks/ZMDIOZPT.cjs +0 -22
  195. package/cjs/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.cjs +0 -28
  196. package/cjs/commands/aws/iam/policies/sts-federation.cjs +0 -19
  197. package/cjs/commands/aws/iam/policies/user-admins-deny-list.cjs +0 -183
  198. package/cjs/commands/aws/iam/policies/user-admins-deny-regions-list.cjs +0 -49
  199. package/cjs/commands/aws/iam/policies/user-admins-self-service-iam.cjs +0 -64
  200. package/cjs/commands/aws/iam/policies/user-admins-write-list.cjs +0 -125
  201. package/esm/__chunks/2FTTEFEK.js +0 -97
  202. package/esm/__chunks/33UYMUQD.js +0 -338
  203. package/esm/__chunks/3BKWTHLJ.js +0 -25
  204. package/esm/__chunks/3HE4BEJX.js +0 -105
  205. package/esm/__chunks/3QLI5BDL.js +0 -387
  206. package/esm/__chunks/5GIUAFXL.js +0 -89
  207. package/esm/__chunks/5ZBVGSOK.js +0 -0
  208. package/esm/__chunks/6G4PXXKF.js +0 -75
  209. package/esm/__chunks/73BJG53F.js +0 -11
  210. package/esm/__chunks/7VF4Q43Q.js +0 -0
  211. package/esm/__chunks/AEDEAYF5.js +0 -0
  212. package/esm/__chunks/AZCP3SFJ.js +0 -0
  213. package/esm/__chunks/B2DVQ2UL.js +0 -61
  214. package/esm/__chunks/CVQVHLW5.js +0 -0
  215. package/esm/__chunks/D62SPZXC.js +0 -0
  216. package/esm/__chunks/DLEJ25GZ.js +0 -121
  217. package/esm/__chunks/DMYFNF54.js +0 -192
  218. package/esm/__chunks/DNFTUMGD.js +0 -23
  219. package/esm/__chunks/DVKD6YSR.js +0 -49
  220. package/esm/__chunks/EMSH4P76.js +0 -20
  221. package/esm/__chunks/FFKFVMIE.js +0 -167
  222. package/esm/__chunks/FL7AILGH.js +0 -133
  223. package/esm/__chunks/FNXUONAV.js +0 -110
  224. package/esm/__chunks/G4NJHFFU.js +0 -320
  225. package/esm/__chunks/HJSXC6HP.js +0 -117
  226. package/esm/__chunks/IEOGAQYI.js +0 -46
  227. package/esm/__chunks/IZFGBYGE.js +0 -34
  228. package/esm/__chunks/J34UVKLA.js +0 -26
  229. package/esm/__chunks/JZPBBBIG.js +0 -74
  230. package/esm/__chunks/KWUJP5MG.js +0 -135
  231. package/esm/__chunks/M35URMT4.js +0 -313
  232. package/esm/__chunks/NF3M2L6C.js +0 -81
  233. package/esm/__chunks/O3CCA76Q.js +0 -22
  234. package/esm/__chunks/PNPPDYKC.js +0 -299
  235. package/esm/__chunks/QFXN4EHM.js +0 -393
  236. package/esm/__chunks/QKDDLIWD.js +0 -146
  237. package/esm/__chunks/QSE66AKY.js +0 -208
  238. package/esm/__chunks/QUF7PS4R.js +0 -18
  239. package/esm/__chunks/S7IJPJ4R.js +0 -126
  240. package/esm/__chunks/SD3E3EPH.js +0 -163
  241. package/esm/__chunks/SJXQJ7RS.js +0 -92
  242. package/esm/__chunks/SNCKIAOR.js +0 -0
  243. package/esm/__chunks/T3TTUHTW.js +0 -30
  244. package/esm/__chunks/TIOVE6HR.js +0 -0
  245. package/esm/__chunks/TXKMEIDQ.js +0 -0
  246. package/esm/__chunks/U7HAE2RF.js +0 -288
  247. package/esm/__chunks/UXWY7BYE.js +0 -63
  248. package/esm/__chunks/VKAKISRG.js +0 -192
  249. package/esm/__chunks/WD2YR6I7.js +0 -0
  250. package/esm/__chunks/WOZFZKFY.js +0 -0
  251. package/esm/__chunks/XI7GZDE2.js +0 -0
  252. package/esm/__chunks/XOUWDB3T.js +0 -249
  253. package/esm/__chunks/XQN2TA4S.js +0 -23
  254. package/esm/__chunks/XXK32TIM.js +0 -16
  255. package/esm/__chunks/YGWTVPZE.js +0 -538
  256. package/esm/__chunks/YRG7PT33.js +0 -127
  257. package/esm/__chunks/ZHKVJO2U.js +0 -47
  258. package/esm/__chunks/ZO55YUSY.js +0 -9
  259. package/esm/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.js +0 -28
  260. package/esm/commands/aws/iam/policies/sts-federation.js +0 -19
  261. package/esm/commands/aws/iam/policies/user-admins-deny-list.js +0 -183
  262. package/esm/commands/aws/iam/policies/user-admins-deny-regions-list.js +0 -49
  263. package/esm/commands/aws/iam/policies/user-admins-self-service-iam.js +0 -64
  264. package/esm/commands/aws/iam/policies/user-admins-write-list.js +0 -125
@@ -1,39 +1,379 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
- var _B5ENMOCDcjs = require('../../../../__chunks/B5ENMOCD.cjs');
19
- require('../../../../__chunks/G5K4PVIL.cjs');
20
- require('../../../../__chunks/R3GUC7O7.cjs');
21
- require('../../../../__chunks/WOYF2L6T.cjs');
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
- exports.authorizeRule = _B5ENMOCDcjs.authorizeRule; exports.describeSecurityGroups = _B5ENMOCDcjs.describeSecurityGroups; exports.extractRoamingFirstName = _B5ENMOCDcjs.extractRoamingFirstName; exports.getCurrentPublicIp = _B5ENMOCDcjs.getCurrentPublicIp; exports.getSecurityGroupDetails = _B5ENMOCDcjs.getSecurityGroupDetails; exports.instanceLabel = _B5ENMOCDcjs.instanceLabel; exports.listEnabledRegions = _B5ENMOCDcjs.listEnabledRegions; exports.listInstances = _B5ENMOCDcjs.listInstances; exports.listSshIngressRules = _B5ENMOCDcjs.listSshIngressRules; exports.printSshRules = _B5ENMOCDcjs.printSshRules; exports.resolveRoamingRule = _B5ENMOCDcjs.resolveRoamingRule; exports.revokeRule = _B5ENMOCDcjs.revokeRule; exports.roamingRuleDescription = _B5ENMOCDcjs.roamingRuleDescription; exports.ruleAlreadyAllowsIp = _B5ENMOCDcjs.ruleAlreadyAllowsIp; exports.securityGroupLabel = _B5ENMOCDcjs.securityGroupLabel; exports.sshRuleLabel = _B5ENMOCDcjs.sshRuleLabel;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_commands_aws_utils_exec_aws = require("../../utils/exec-aws.cjs");
3
+ const require_commands_aws_ec2_allow_ip_schema = require("./schema.cjs");
4
+ //#region src/commands/aws/ec2/allow-ip/utils.js
5
+ /**
6
+ * @typedef {Object} Ec2Instance
7
+ * @property {string} instanceId
8
+ * @property {string} name
9
+ * @property {string} state
10
+ * @property {string} instanceType
11
+ * @property {string | null} publicIp
12
+ * @property {string[]} securityGroupIds
13
+ */
14
+ /**
15
+ * @typedef {Object} SecurityGroup
16
+ * @property {string} groupId
17
+ * @property {string} groupName
18
+ * @property {string} description
19
+ */
20
+ /**
21
+ * @typedef {Object} SshIngressRule
22
+ * @property {string} cidrIp
23
+ * @property {string} description
24
+ * @property {number} fromPort
25
+ * @property {number} toPort
26
+ * @property {string} ipProtocol
27
+ */
28
+ /**
29
+ * Determine the caller's current public IPv4 address.
30
+ * @returns {Promise<string>}
31
+ */
32
+ async function getCurrentPublicIp() {
33
+ for (const url of ["https://checkip.amazonaws.com", "https://api.ipify.org"]) try {
34
+ const controller = new AbortController();
35
+ const timeout = setTimeout(() => controller.abort(), 8e3);
36
+ const response = await fetch(url, { signal: controller.signal });
37
+ clearTimeout(timeout);
38
+ if (!response.ok) continue;
39
+ const ip = (await response.text()).trim();
40
+ if (ip && ip.includes(".")) return ip;
41
+ } catch {
42
+ continue;
43
+ }
44
+ throw new Error("Could not determine your current public IP address");
45
+ }
46
+ /**
47
+ * List regions that are opted-in / enabled for the profile.
48
+ * @param {{ profile?: string; region: string; verbose?: boolean }} params
49
+ * @returns {string[]}
50
+ */
51
+ function listEnabledRegions(params) {
52
+ const { profile, region, verbose } = params;
53
+ const data = require_commands_aws_utils_exec_aws.runAws({
54
+ profile,
55
+ region,
56
+ args: [
57
+ "ec2",
58
+ "describe-regions",
59
+ "--query",
60
+ "Regions[?OptInStatus!=`not-opted-in`].RegionName"
61
+ ],
62
+ verbose
63
+ });
64
+ return (Array.isArray(data) ? data : []).map((value) => String(value)).sort();
65
+ }
66
+ /**
67
+ * List non-terminated EC2 instances in a region.
68
+ * @param {{ profile?: string; region: string; verbose?: boolean }} params
69
+ * @returns {Ec2Instance[]}
70
+ */
71
+ function listInstances(params) {
72
+ const { profile, region, verbose } = params;
73
+ const data = require_commands_aws_utils_exec_aws.runAws({
74
+ profile,
75
+ region,
76
+ args: ["ec2", "describe-instances"],
77
+ verbose
78
+ });
79
+ /** @type {Ec2Instance[]} */
80
+ const instances = [];
81
+ for (const reservation of data.Reservations ?? []) for (const raw of reservation.Instances ?? []) {
82
+ const state = raw.State?.Name ?? "unknown";
83
+ if (state === "terminated" || state === "shutting-down") continue;
84
+ let name = "";
85
+ for (const tag of raw.Tags ?? []) if (tag.Key === "Name") {
86
+ name = tag.Value ?? "";
87
+ break;
88
+ }
89
+ const securityGroupIds = (raw.SecurityGroups ?? []).map((group) => group.GroupId).filter((id) => Boolean(id));
90
+ instances.push({
91
+ instanceId: raw.InstanceId,
92
+ name,
93
+ state,
94
+ instanceType: raw.InstanceType ?? "unknown",
95
+ publicIp: raw.PublicIpAddress ?? null,
96
+ securityGroupIds
97
+ });
98
+ }
99
+ instances.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()) || a.instanceId.localeCompare(b.instanceId));
100
+ return instances;
101
+ }
102
+ /**
103
+ * Describe security groups by id.
104
+ * @param {{ profile?: string; region: string; groupIds: string[]; verbose?: boolean }} params
105
+ * @returns {SecurityGroup[]}
106
+ */
107
+ function describeSecurityGroups(params) {
108
+ const { profile, region, groupIds, verbose } = params;
109
+ if (groupIds.length === 0) return [];
110
+ /** @type {SecurityGroup[]} */
111
+ const groups = (require_commands_aws_utils_exec_aws.runAws({
112
+ profile,
113
+ region,
114
+ args: [
115
+ "ec2",
116
+ "describe-security-groups",
117
+ "--group-ids",
118
+ ...groupIds
119
+ ],
120
+ verbose
121
+ }).SecurityGroups ?? []).map((raw) => ({
122
+ groupId: raw.GroupId,
123
+ groupName: raw.GroupName ?? "",
124
+ description: raw.Description ?? ""
125
+ }));
126
+ groups.sort((a, b) => a.groupName.localeCompare(b.groupName));
127
+ return groups;
128
+ }
129
+ /**
130
+ * Load full details for a single security group.
131
+ * @param {{ profile?: string; region: string; groupId: string; verbose?: boolean }} params
132
+ * @returns {any | null}
133
+ */
134
+ function getSecurityGroupDetails(params) {
135
+ const { profile, region, groupId, verbose } = params;
136
+ const securityGroups = require_commands_aws_utils_exec_aws.runAws({
137
+ profile,
138
+ region,
139
+ args: [
140
+ "ec2",
141
+ "describe-security-groups",
142
+ "--group-ids",
143
+ groupId
144
+ ],
145
+ verbose
146
+ }).SecurityGroups ?? [];
147
+ if (securityGroups.length === 0) return null;
148
+ return securityGroups[0];
149
+ }
150
+ /**
151
+ * @param {string} cidrIp
152
+ * @returns {boolean}
153
+ */
154
+ function isSingleHostCidr(cidrIp) {
155
+ return cidrIp.endsWith("/32") && cidrIp !== "0.0.0.0/0";
156
+ }
157
+ /**
158
+ * @param {any} permission
159
+ * @returns {boolean}
160
+ */
161
+ function portAllowsSsh(permission) {
162
+ const protocol = permission.IpProtocol;
163
+ if (protocol !== "tcp" && protocol !== "6") return false;
164
+ const fromPort = permission.FromPort;
165
+ const toPort = permission.ToPort;
166
+ if (fromPort === void 0 && toPort === void 0) return true;
167
+ if (fromPort === void 0 || toPort === void 0) return false;
168
+ return fromPort <= 22 && 22 <= toPort;
169
+ }
170
+ /**
171
+ * Extract single-host SSH ingress rules (port 22, /32) from a security group.
172
+ * @param {any} securityGroup
173
+ * @returns {SshIngressRule[]}
174
+ */
175
+ function listSshIngressRules(securityGroup) {
176
+ /** @type {SshIngressRule[]} */
177
+ const rules = [];
178
+ for (const permission of securityGroup.IpPermissions ?? []) {
179
+ if (!portAllowsSsh(permission)) continue;
180
+ const fromPort = permission.FromPort ?? 22;
181
+ const toPort = permission.ToPort ?? 22;
182
+ const ipProtocol = permission.IpProtocol ?? "tcp";
183
+ for (const ipRange of permission.IpRanges ?? []) {
184
+ const cidrIp = ipRange.CidrIp;
185
+ if (!cidrIp || !isSingleHostCidr(cidrIp)) continue;
186
+ rules.push({
187
+ cidrIp,
188
+ description: ipRange.Description ?? "",
189
+ fromPort,
190
+ toPort,
191
+ ipProtocol
192
+ });
193
+ }
194
+ }
195
+ return rules;
196
+ }
197
+ /**
198
+ * Derive a first name from the IAM ARN or profile (md-{name}-...).
199
+ * @param {{ profile?: string; identity: { Arn?: string } }} params
200
+ * @returns {string}
201
+ */
202
+ function extractRoamingFirstName(params) {
203
+ const { profile, identity } = params;
204
+ const arn = identity.Arn ?? "";
205
+ const username = arn.includes("/") ? arn.split("/").pop() ?? "" : "";
206
+ for (const candidate of [username, profile ?? ""]) {
207
+ if (!candidate) continue;
208
+ const match = /^md-([^-]+)-/.exec(candidate);
209
+ if (match && match[1]) return match[1].charAt(0).toUpperCase() + match[1].slice(1).toLowerCase();
210
+ }
211
+ return require_commands_aws_ec2_allow_ip_schema.DEFAULT_ROAMING_NAME;
212
+ }
213
+ /**
214
+ * @param {string} firstName
215
+ * @returns {string}
216
+ */
217
+ function roamingRuleDescription(firstName) {
218
+ return `${firstName} Roaming`;
219
+ }
220
+ /**
221
+ * Find an existing rule whose description matches the roaming rule name.
222
+ * @param {SshIngressRule[]} sshRules
223
+ * @param {string} ruleDescription
224
+ * @returns {SshIngressRule | null}
225
+ */
226
+ function resolveRoamingRule(sshRules, ruleDescription) {
227
+ const target = ruleDescription.toLowerCase();
228
+ for (const rule of sshRules) if (rule.description.trim().toLowerCase() === target) return rule;
229
+ return null;
230
+ }
231
+ /**
232
+ * Find an existing rule that already allows the given CIDR.
233
+ * @param {SshIngressRule[]} sshRules
234
+ * @param {string} newCidr
235
+ * @returns {SshIngressRule | null}
236
+ */
237
+ function ruleAlreadyAllowsIp(sshRules, newCidr) {
238
+ for (const rule of sshRules) if (rule.cidrIp === newCidr) return rule;
239
+ return null;
240
+ }
241
+ /**
242
+ * @param {{
243
+ * cidrIp: string;
244
+ * description: string;
245
+ * fromPort?: number;
246
+ * toPort?: number;
247
+ * ipProtocol?: string;
248
+ * }} params
249
+ * @returns {string} JSON string for the --ip-permissions argument
250
+ */
251
+ function buildIpPermissions(params) {
252
+ const { cidrIp, description, fromPort = 22, toPort = 22, ipProtocol = "tcp" } = params;
253
+ return JSON.stringify([{
254
+ IpProtocol: ipProtocol,
255
+ FromPort: fromPort,
256
+ ToPort: toPort,
257
+ IpRanges: [{
258
+ CidrIp: cidrIp,
259
+ Description: description
260
+ }]
261
+ }]);
262
+ }
263
+ /**
264
+ * Authorize a new SSH ingress rule.
265
+ * @param {{
266
+ * profile?: string;
267
+ * region: string;
268
+ * groupId: string;
269
+ * cidrIp: string;
270
+ * description: string;
271
+ * fromPort?: number;
272
+ * toPort?: number;
273
+ * ipProtocol?: string;
274
+ * verbose?: boolean;
275
+ * }} params
276
+ */
277
+ function authorizeRule(params) {
278
+ const { profile, region, groupId, verbose, ...rule } = params;
279
+ require_commands_aws_utils_exec_aws.runAws({
280
+ profile,
281
+ region,
282
+ args: [
283
+ "ec2",
284
+ "authorize-security-group-ingress",
285
+ "--group-id",
286
+ groupId,
287
+ "--ip-permissions",
288
+ buildIpPermissions(rule)
289
+ ],
290
+ expectJson: false,
291
+ verbose
292
+ });
293
+ }
294
+ /**
295
+ * Revoke an existing SSH ingress rule.
296
+ * @param {{
297
+ * profile?: string;
298
+ * region: string;
299
+ * groupId: string;
300
+ * rule: SshIngressRule;
301
+ * verbose?: boolean;
302
+ * }} params
303
+ */
304
+ function revokeRule(params) {
305
+ const { profile, region, groupId, rule, verbose } = params;
306
+ require_commands_aws_utils_exec_aws.runAws({
307
+ profile,
308
+ region,
309
+ args: [
310
+ "ec2",
311
+ "revoke-security-group-ingress",
312
+ "--group-id",
313
+ groupId,
314
+ "--ip-permissions",
315
+ buildIpPermissions({
316
+ cidrIp: rule.cidrIp,
317
+ description: rule.description,
318
+ fromPort: rule.fromPort,
319
+ toPort: rule.toPort,
320
+ ipProtocol: rule.ipProtocol
321
+ })
322
+ ],
323
+ expectJson: false,
324
+ verbose
325
+ });
326
+ }
327
+ /**
328
+ * @param {Ec2Instance} instance
329
+ * @returns {string}
330
+ */
331
+ function instanceLabel(instance) {
332
+ const publicIp = instance.publicIp || "no public IP";
333
+ const name = instance.name || "(no name)";
334
+ return `${instance.instanceId} ${name} ${instance.state} ${instance.instanceType} ${publicIp}`;
335
+ }
336
+ /**
337
+ * @param {SecurityGroup} group
338
+ * @returns {string}
339
+ */
340
+ function securityGroupLabel(group) {
341
+ return `${group.groupId} ${group.groupName} ${group.description}`;
342
+ }
343
+ /**
344
+ * @param {SshIngressRule} rule
345
+ * @returns {string}
346
+ */
347
+ function sshRuleLabel(rule) {
348
+ const description = rule.description || "(no description)";
349
+ return `${rule.cidrIp} ${description}`;
350
+ }
351
+ /**
352
+ * Print single-host SSH rules using the given logger.
353
+ * @param {SshIngressRule[]} sshRules
354
+ * @param {(message: string) => void} [log]
355
+ */
356
+ function printSshRules(sshRules, log = console.log) {
357
+ if (sshRules.length === 0) {
358
+ log(" (no single-host SSH rules on port 22)");
359
+ return;
360
+ }
361
+ for (const rule of sshRules) log(` - ${sshRuleLabel(rule)}`);
362
+ }
363
+ //#endregion
364
+ exports.authorizeRule = authorizeRule;
365
+ exports.describeSecurityGroups = describeSecurityGroups;
366
+ exports.extractRoamingFirstName = extractRoamingFirstName;
367
+ exports.getCurrentPublicIp = getCurrentPublicIp;
368
+ exports.getSecurityGroupDetails = getSecurityGroupDetails;
369
+ exports.instanceLabel = instanceLabel;
370
+ exports.listEnabledRegions = listEnabledRegions;
371
+ exports.listInstances = listInstances;
372
+ exports.listSshIngressRules = listSshIngressRules;
373
+ exports.printSshRules = printSshRules;
374
+ exports.resolveRoamingRule = resolveRoamingRule;
375
+ exports.revokeRule = revokeRule;
376
+ exports.roamingRuleDescription = roamingRuleDescription;
377
+ exports.ruleAlreadyAllowsIp = ruleAlreadyAllowsIp;
378
+ exports.securityGroupLabel = securityGroupLabel;
379
+ exports.sshRuleLabel = sshRuleLabel;
@@ -1,15 +1,111 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
-
7
- var _T2A7TN4Fcjs = require('../../../__chunks/T2A7TN4F.cjs');
8
- require('../../../__chunks/R3GUC7O7.cjs');
9
-
10
-
11
-
12
-
13
-
14
-
15
- exports.ADMIN_GROUP_NAME = _T2A7TN4Fcjs.ADMIN_GROUP_NAME; exports.groupUserNames = _T2A7TN4Fcjs.groupUserNames; exports.listVaultProfiles = _T2A7TN4Fcjs.listVaultProfiles; exports.resolveAdminScanProfiles = _T2A7TN4Fcjs.resolveAdminScanProfiles; exports.resolveProfileScan = _T2A7TN4Fcjs.resolveProfileScan;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_rolldown_runtime = require("../../../__chunks/VH7oDXx4.cjs");
3
+ const require_commands_aws_utils_exec_aws = require("../utils/exec-aws.cjs");
4
+ let chalk = require("chalk");
5
+ chalk = require_rolldown_runtime.__toESM(chalk, 1);
6
+ let child_process = require("child_process");
7
+ //#region src/commands/aws/iam/admin-group.js
8
+ /**
9
+ * The IAM group that grants break-glass admin access and should normally be empty.
10
+ */
11
+ const ADMIN_GROUP_NAME = "acl-admin-do-not-use";
12
+ const VAULT_DURATION = process.env.AWS_VAULT_DURATION ?? "15m";
13
+ /**
14
+ * A function bound to a profile's working credential mode (direct or aws-vault).
15
+ * @typedef {(args: string[], options?: { expectJson?: boolean }) => any} ProfileRunner
16
+ */
17
+ /**
18
+ * List aws-vault profiles that have stored credentials.
19
+ * @returns {string[]}
20
+ */
21
+ function listVaultProfiles() {
22
+ const result = (0, child_process.spawnSync)("aws-vault", ["list", "--credentials"], { encoding: "utf-8" });
23
+ if (result.status !== 0) return [];
24
+ return (result.stdout ?? "").split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
25
+ }
26
+ /**
27
+ * Resolve which profiles to scan for admin-group commands.
28
+ * Uses `--profile`, then `AWS_PROFILE`, for a single profile unless `--all` is set.
29
+ * @param {{ profile?: string; all?: boolean }} params
30
+ * @returns {string[]}
31
+ */
32
+ function resolveAdminScanProfiles({ profile, all = false }) {
33
+ const targetProfile = profile ?? process.env.AWS_PROFILE;
34
+ if (!all && targetProfile) return [targetProfile];
35
+ const profiles = listVaultProfiles();
36
+ if (profiles.length === 0) throw new Error("No aws-vault profiles with credentials found.");
37
+ return profiles;
38
+ }
39
+ /**
40
+ * @param {{ Users?: Array<{ UserName: string }> }} group
41
+ * @returns {string[]}
42
+ */
43
+ function groupUserNames(group) {
44
+ return (group.Users ?? []).map((user) => user.UserName);
45
+ }
46
+ /**
47
+ * Resolve a working credential runner for a profile and read the admin group.
48
+ * Tries stored credentials first, then falls back to `aws-vault exec`.
49
+ * The returned `run` reuses whichever mode worked, so callers can perform
50
+ * follow-up mutations (e.g. remove-user-from-group) with the same credentials.
51
+ * @param {{ profile: string; verbose?: boolean }} params
52
+ * @returns {{ accountId: string; arn: string; users: string[]; run: ProfileRunner } | null} Null when the profile is skipped
53
+ */
54
+ function resolveProfileScan(params) {
55
+ const { profile, verbose = false } = params;
56
+ const idArgs = ["sts", "get-caller-identity"];
57
+ const groupArgs = [
58
+ "iam",
59
+ "get-group",
60
+ "--group-name",
61
+ ADMIN_GROUP_NAME
62
+ ];
63
+ /** @type {ProfileRunner} */
64
+ const directRun = (args, options = {}) => require_commands_aws_utils_exec_aws.runAws({
65
+ profile,
66
+ args,
67
+ expectJson: options.expectJson ?? true,
68
+ verbose
69
+ });
70
+ /** @type {ProfileRunner} */
71
+ const vaultRun = (args, options = {}) => require_commands_aws_utils_exec_aws.runAwsVault({
72
+ profile,
73
+ args,
74
+ duration: VAULT_DURATION,
75
+ expectJson: options.expectJson ?? true,
76
+ verbose
77
+ });
78
+ try {
79
+ const identity = directRun(idArgs);
80
+ const group = directRun(groupArgs);
81
+ return {
82
+ accountId: identity.Account,
83
+ arn: identity.Arn,
84
+ users: groupUserNames(group),
85
+ run: directRun
86
+ };
87
+ } catch (directError) {
88
+ try {
89
+ const identity = vaultRun(idArgs);
90
+ const group = vaultRun(groupArgs);
91
+ return {
92
+ accountId: identity.Account,
93
+ arn: identity.Arn,
94
+ users: groupUserNames(group),
95
+ run: vaultRun
96
+ };
97
+ } catch {
98
+ if (verbose) {
99
+ const reason = directError instanceof Error ? directError.message.split("\n")[0] ?? "" : String(directError);
100
+ console.log(chalk.default.dim(`skip ${profile} — ${reason}`));
101
+ }
102
+ return null;
103
+ }
104
+ }
105
+ }
106
+ //#endregion
107
+ exports.ADMIN_GROUP_NAME = ADMIN_GROUP_NAME;
108
+ exports.groupUserNames = groupUserNames;
109
+ exports.listVaultProfiles = listVaultProfiles;
110
+ exports.resolveAdminScanProfiles = resolveAdminScanProfiles;
111
+ exports.resolveProfileScan = resolveProfileScan;
@@ -1,12 +1,127 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _KU76LC42cjs = require('../../../../__chunks/KU76LC42.cjs');
4
- require('../../../../__chunks/UWHPE2GI.cjs');
5
- require('../../../../__chunks/T2A7TN4F.cjs');
6
- require('../../../../__chunks/R3GUC7O7.cjs');
7
- require('../../../../__chunks/NT2XXAI6.cjs');
8
- require('../../../../__chunks/WOYF2L6T.cjs');
9
- require('../../../../__chunks/CMUD7LLN.cjs');
10
-
11
-
12
- exports.breakGlassCommand = _KU76LC42cjs.breakGlassCommand;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_rolldown_runtime = require("../../../../__chunks/VH7oDXx4.cjs");
3
+ const require_commands_aws_utils_tty = require("../../utils/tty.cjs");
4
+ const require_commands_aws_utils_exec_aws = require("../../utils/exec-aws.cjs");
5
+ const require_commands_aws_utils_resolve_profile = require("../../utils/resolve-profile.cjs");
6
+ const require_commands_aws_iam_admin_group = require("../admin-group.cjs");
7
+ const require_commands_aws_iam_break_glass_schema = require("./schema.cjs");
8
+ let chalk = require("chalk");
9
+ chalk = require_rolldown_runtime.__toESM(chalk, 1);
10
+ let zod = require("zod");
11
+ //#region src/commands/aws/iam/break-glass/handler.js
12
+ /**
13
+ * Derive an IAM user name from a caller-identity ARN.
14
+ * Returns null for non-user ARNs (assumed roles, root, etc.).
15
+ * @param {string} arn
16
+ * @returns {string | null}
17
+ */
18
+ function userNameFromArn(arn) {
19
+ const index = arn.indexOf(":user/");
20
+ if (index === -1) return null;
21
+ const name = arn.slice(index + 6).split("/").pop();
22
+ return name && name.length > 0 ? name : null;
23
+ }
24
+ /**
25
+ * `aws iam break-glass` handler: grant break-glass admin access by adding a user
26
+ * to the acl-admin-do-not-use group for a single profile. Defaults to the
27
+ * caller's own IAM user when no --user is given.
28
+ * @param {unknown} options
29
+ */
30
+ async function breakGlassCommand(options) {
31
+ try {
32
+ const { profile, user, yes, dryRun, verbose } = require_commands_aws_iam_break_glass_schema.breakGlassOptionsSchema.parse(options);
33
+ require_commands_aws_utils_exec_aws.requireCommands(["aws"]);
34
+ const targetProfile = await require_commands_aws_utils_resolve_profile.resolveProfile({ profile });
35
+ if (!targetProfile) {
36
+ console.error(chalk.default.red("No profile specified. Pass --profile <name> or set AWS_PROFILE."));
37
+ process.exit(1);
38
+ }
39
+ const scan = require_commands_aws_iam_admin_group.resolveProfileScan({
40
+ profile: targetProfile,
41
+ verbose
42
+ });
43
+ if (!scan) {
44
+ console.error(chalk.default.red(`\n❌ Could not read ${require_commands_aws_iam_admin_group.ADMIN_GROUP_NAME} for profile "${targetProfile}".`));
45
+ console.error(chalk.default.yellow(" Check your credentials, and run `mtn aws iam setup-acl` first if the group does not exist yet.\n"));
46
+ process.exit(1);
47
+ }
48
+ /** @type {string[]} */
49
+ let targets = user;
50
+ if (targets.length === 0) {
51
+ const derived = userNameFromArn(scan.arn);
52
+ if (!derived) {
53
+ console.error(chalk.default.red(`\n❌ Could not determine your IAM user from the caller identity:\n ${scan.arn}`));
54
+ console.error(chalk.default.yellow(" Pass --user <name> to choose who to grant.\n"));
55
+ process.exit(1);
56
+ }
57
+ targets = [derived];
58
+ }
59
+ const alreadyMembers = new Set(scan.users);
60
+ const toGrant = targets.filter((name) => !alreadyMembers.has(name));
61
+ const existing = targets.filter((name) => alreadyMembers.has(name));
62
+ console.log(chalk.default.blue(`\n==> Break-glass admin (${require_commands_aws_iam_admin_group.ADMIN_GROUP_NAME}) — profile ${targetProfile} (${scan.accountId})\n`));
63
+ for (const name of existing) console.log(chalk.default.dim(`-- ${name} already has break-glass access`));
64
+ if (toGrant.length === 0) {
65
+ console.log(chalk.default.green("\nNothing to do — all target user(s) already have break-glass access.\n"));
66
+ return;
67
+ }
68
+ console.log(chalk.default.red.bold(`⚠ This grants AdministratorAccess to ${toGrant.length} user(s): ${toGrant.join(", ")}`));
69
+ if (dryRun) {
70
+ for (const name of toGrant) console.log(chalk.default.yellow(` [dry-run] would add ${name} to ${require_commands_aws_iam_admin_group.ADMIN_GROUP_NAME}`));
71
+ console.log(chalk.default.yellow("\n[dry-run] Re-run without --dry-run to apply.\n"));
72
+ return;
73
+ }
74
+ let confirmed = yes;
75
+ if (!confirmed) confirmed = await require_commands_aws_utils_tty.promptYesNo({
76
+ message: ` Grant break-glass admin to ${toGrant.length} user(s) in ${targetProfile}?`,
77
+ defaultYes: false
78
+ });
79
+ if (!confirmed) {
80
+ console.log(chalk.default.dim(" aborted (not confirmed)\n"));
81
+ return;
82
+ }
83
+ let granted = 0;
84
+ for (const name of toGrant) try {
85
+ scan.run([
86
+ "iam",
87
+ "add-user-to-group",
88
+ "--group-name",
89
+ require_commands_aws_iam_admin_group.ADMIN_GROUP_NAME,
90
+ "--user-name",
91
+ name
92
+ ], { expectJson: false });
93
+ console.log(chalk.default.green(` granted ${name}`));
94
+ granted += 1;
95
+ } catch (grantError) {
96
+ const reason = grantError instanceof Error ? grantError.message.split("\n")[0] ?? "" : String(grantError);
97
+ console.log(chalk.default.red(` failed to grant ${name}: ${reason}`));
98
+ }
99
+ console.log(chalk.default.blue("\n==> Summary"));
100
+ console.log(` Profile: ${targetProfile} (${scan.accountId})`);
101
+ console.log(` Users granted: ${granted}`);
102
+ console.log(` Already had it: ${existing.length}`);
103
+ console.log(chalk.default.yellow("\n💡 Revoke with `mtn aws iam remove-admin` when you are done."));
104
+ console.log(chalk.default.dim(" You may need a fresh session (e.g. clear the aws-vault cache) before the new permissions apply.\n"));
105
+ } catch (error) {
106
+ if (error instanceof zod.ZodError) {
107
+ console.error(chalk.default.red("\n❌ Invalid command options:"));
108
+ error.errors.forEach((err) => {
109
+ console.error(chalk.default.red(` ${err.path.join(".")}: ${err.message}`));
110
+ });
111
+ process.exit(1);
112
+ }
113
+ const verbose = options?.verbose || false;
114
+ console.error(chalk.default.red("\n❌ break-glass failed:"));
115
+ if (error instanceof Error) {
116
+ console.error(chalk.default.red(` ${error.message}`));
117
+ if (verbose && error.stack) {
118
+ console.error(chalk.default.gray("\nStack trace:"));
119
+ console.error(chalk.default.gray(error.stack));
120
+ }
121
+ } else console.error(chalk.default.red(` ${String(error)}`));
122
+ console.error(chalk.default.yellow("\n💡 Requires the AWS CLI and iam:AddUserToGroup on the target profile.\n"));
123
+ process.exit(1);
124
+ }
125
+ }
126
+ //#endregion
127
+ exports.breakGlassCommand = breakGlassCommand;