@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,229 +1,142 @@
1
- import {
2
- registerAwsCommands
3
- } from "../../__chunks/QSE66AKY.js";
4
- import "../../__chunks/AEDEAYF5.js";
5
- import {
6
- allowIpCommand
7
- } from "../../__chunks/PNPPDYKC.js";
8
- import {
9
- authorizeRule,
10
- describeSecurityGroups,
11
- extractRoamingFirstName,
12
- getCurrentPublicIp,
13
- getSecurityGroupDetails,
14
- instanceLabel,
15
- listEnabledRegions,
16
- listInstances,
17
- listSshIngressRules,
18
- printSshRules,
19
- resolveRoamingRule,
20
- revokeRule,
21
- roamingRuleDescription,
22
- ruleAlreadyAllowsIp,
23
- securityGroupLabel,
24
- sshRuleLabel
25
- } from "../../__chunks/U7HAE2RF.js";
26
- import {
27
- DEFAULT_REGION,
28
- DEFAULT_ROAMING_NAME,
29
- SSH_PORT,
30
- allowIpOptionsSchema
31
- } from "../../__chunks/J34UVKLA.js";
32
- import "../../__chunks/5ZBVGSOK.js";
33
- import {
34
- checkAdminCommand
35
- } from "../../__chunks/S7IJPJ4R.js";
36
- import {
37
- checkAdminOptionsSchema
38
- } from "../../__chunks/QUF7PS4R.js";
39
- import "../../__chunks/TIOVE6HR.js";
40
- import {
41
- breakGlassCommand
42
- } from "../../__chunks/VKAKISRG.js";
43
- import {
44
- breakGlassOptionsSchema
45
- } from "../../__chunks/EMSH4P76.js";
46
- import "../../__chunks/D62SPZXC.js";
47
- import {
48
- removeAdminCommand
49
- } from "../../__chunks/FFKFVMIE.js";
50
- import {
51
- removeAdminOptionsSchema
52
- } from "../../__chunks/DNFTUMGD.js";
53
- import {
54
- ADMIN_GROUP_NAME
55
- } from "../../__chunks/NF3M2L6C.js";
56
- import "../../__chunks/CVQVHLW5.js";
57
- import {
58
- usersCommand
59
- } from "../../__chunks/JZPBBBIG.js";
60
- import {
61
- usersOptionsSchema
62
- } from "../../__chunks/XXK32TIM.js";
63
- import "../../__chunks/WOZFZKFY.js";
64
- import {
65
- setupAclCommand
66
- } from "../../__chunks/DMYFNF54.js";
67
- import {
68
- ACL_GROUPS,
69
- CUSTOM_POLICIES,
70
- attach,
71
- detach,
72
- ensureGroup,
73
- printFinalState,
74
- publishPolicy
75
- } from "../../__chunks/XOUWDB3T.js";
76
- import {
77
- buildUsername,
78
- createCliAccessKey,
79
- createUsersInteractive,
80
- ensureAclGroupsExist,
81
- ensureUser,
82
- ensureUserInGroup,
83
- inferAccountName,
84
- isValidSlug,
85
- normalizeIdentifier,
86
- normalizeSlug,
87
- parseMdUsername,
88
- roleToGroup
89
- } from "../../__chunks/3QLI5BDL.js";
90
- import {
91
- setupAclOptionsSchema
92
- } from "../../__chunks/XQN2TA4S.js";
93
- import "../../__chunks/7VF4Q43Q.js";
94
- import {
95
- removeRecordCommand
96
- } from "../../__chunks/QKDDLIWD.js";
97
- import {
98
- removeRecordOptionsSchema
99
- } from "../../__chunks/IZFGBYGE.js";
100
- import "../../__chunks/XI7GZDE2.js";
101
- import {
102
- addRecordCommand,
103
- resolveHostedZone,
104
- resolveName,
105
- resolveRecordType
106
- } from "../../__chunks/G4NJHFFU.js";
107
- import {
108
- bareHostedZoneId,
109
- deleteResourceRecordSet,
110
- findCnameConflicts,
111
- findHostedZone,
112
- formatValues,
113
- getRecordSetsAtName,
114
- getResourceRecordSet,
115
- hostedZoneLabel,
116
- listHostedZones,
117
- normalizeRecordValue,
118
- planRecordChange,
119
- resolveRecordName,
120
- upsertResourceRecordSet,
121
- withTrailingDot,
122
- withoutTrailingDot
123
- } from "../../__chunks/33UYMUQD.js";
124
- import {
125
- DEFAULT_TTL,
126
- RECORD_TYPES,
127
- addRecordOptionsSchema
128
- } from "../../__chunks/IEOGAQYI.js";
129
- import "../../__chunks/FNXUONAV.js";
130
- import "../../__chunks/ZO55YUSY.js";
131
- import "../../__chunks/TXKMEIDQ.js";
132
- import {
133
- sendEmailCommand
134
- } from "../../__chunks/2FTTEFEK.js";
135
- import {
136
- defaultBody,
137
- sendViaApi,
138
- sendViaSmtp
139
- } from "../../__chunks/UXWY7BYE.js";
140
- import "../../__chunks/B2DVQ2UL.js";
141
- import "../../__chunks/5GIUAFXL.js";
142
- import {
143
- sendEmailOptionsSchema
144
- } from "../../__chunks/3BKWTHLJ.js";
145
- import "../../__chunks/73BJG53F.js";
146
- import "../../__chunks/ZHKVJO2U.js";
147
- export {
148
- ACL_GROUPS,
149
- ADMIN_GROUP_NAME,
150
- CUSTOM_POLICIES,
151
- DEFAULT_REGION,
152
- DEFAULT_ROAMING_NAME,
153
- DEFAULT_TTL,
154
- RECORD_TYPES,
155
- SSH_PORT,
156
- addRecordCommand,
157
- addRecordOptionsSchema,
158
- allowIpCommand,
159
- allowIpOptionsSchema,
160
- attach,
161
- authorizeRule,
162
- bareHostedZoneId,
163
- breakGlassCommand,
164
- breakGlassOptionsSchema,
165
- buildUsername,
166
- checkAdminCommand,
167
- checkAdminOptionsSchema,
168
- createCliAccessKey,
169
- createUsersInteractive,
170
- defaultBody,
171
- deleteResourceRecordSet,
172
- describeSecurityGroups,
173
- detach,
174
- ensureAclGroupsExist,
175
- ensureGroup,
176
- ensureUser,
177
- ensureUserInGroup,
178
- extractRoamingFirstName,
179
- findCnameConflicts,
180
- findHostedZone,
181
- formatValues,
182
- getCurrentPublicIp,
183
- getRecordSetsAtName,
184
- getResourceRecordSet,
185
- getSecurityGroupDetails,
186
- hostedZoneLabel,
187
- inferAccountName,
188
- instanceLabel,
189
- isValidSlug,
190
- listEnabledRegions,
191
- listHostedZones,
192
- listInstances,
193
- listSshIngressRules,
194
- normalizeIdentifier,
195
- normalizeRecordValue,
196
- normalizeSlug,
197
- parseMdUsername,
198
- planRecordChange,
199
- printFinalState,
200
- printSshRules,
201
- publishPolicy,
202
- registerAwsCommands,
203
- removeAdminCommand,
204
- removeAdminOptionsSchema,
205
- removeRecordCommand,
206
- removeRecordOptionsSchema,
207
- resolveHostedZone,
208
- resolveName,
209
- resolveRecordName,
210
- resolveRecordType,
211
- resolveRoamingRule,
212
- revokeRule,
213
- roamingRuleDescription,
214
- roleToGroup,
215
- ruleAlreadyAllowsIp,
216
- securityGroupLabel,
217
- sendEmailCommand,
218
- sendEmailOptionsSchema,
219
- sendViaApi,
220
- sendViaSmtp,
221
- setupAclCommand,
222
- setupAclOptionsSchema,
223
- sshRuleLabel,
224
- upsertResourceRecordSet,
225
- usersCommand,
226
- usersOptionsSchema,
227
- withTrailingDot,
228
- withoutTrailingDot
229
- };
1
+ import { sendEmailOptionsSchema } from "./ses/send-email/schema.js";
2
+ import { defaultBody, sendViaApi, sendViaSmtp } from "./ses/send-email/utils.js";
3
+ import { sendEmailCommand } from "./ses/send-email/handler.js";
4
+ import "./ses/send-email/index.js";
5
+ import { DEFAULT_TTL, RECORD_TYPES, addRecordOptionsSchema } from "./route53/add-record/schema.js";
6
+ import { bareHostedZoneId, deleteResourceRecordSet, findCnameConflicts, findHostedZone, formatValues, getRecordSetsAtName, getResourceRecordSet, hostedZoneLabel, listHostedZones, normalizeRecordValue, planRecordChange, resolveRecordName, upsertResourceRecordSet, withTrailingDot, withoutTrailingDot } from "./route53/add-record/utils.js";
7
+ import { addRecordCommand, resolveHostedZone, resolveName, resolveRecordType } from "./route53/add-record/handler.js";
8
+ import { removeRecordOptionsSchema } from "./route53/remove-record/schema.js";
9
+ import { removeRecordCommand } from "./route53/remove-record/handler.js";
10
+ import "./route53/remove-record/index.js";
11
+ import "./route53/add-record/index.js";
12
+ import { usersOptionsSchema } from "./iam/users/schema.js";
13
+ import { buildUsername, createCliAccessKey, createUsersInteractive, ensureAclGroupsExist, ensureUser, ensureUserInGroup, inferAccountName, isValidSlug, normalizeIdentifier, normalizeSlug, parseMdUsername, roleToGroup } from "./iam/users/utils.js";
14
+ import { usersCommand } from "./iam/users/handler.js";
15
+ import "./iam/users/index.js";
16
+ import { setupAclOptionsSchema } from "./iam/setup-acl/schema.js";
17
+ import { ACL_GROUPS, CUSTOM_POLICIES, attach, detach, ensureGroup, printFinalState, publishPolicy } from "./iam/setup-acl/utils.js";
18
+ import { setupAclCommand } from "./iam/setup-acl/handler.js";
19
+ import "./iam/setup-acl/index.js";
20
+ import { ADMIN_GROUP_NAME } from "./iam/admin-group.js";
21
+ import { removeAdminOptionsSchema } from "./iam/remove-admin/schema.js";
22
+ import { removeAdminCommand } from "./iam/remove-admin/handler.js";
23
+ import "./iam/remove-admin/index.js";
24
+ import { checkAdminOptionsSchema } from "./iam/check-admin/schema.js";
25
+ import { checkAdminCommand } from "./iam/check-admin/handler.js";
26
+ import "./iam/check-admin/index.js";
27
+ import { breakGlassOptionsSchema } from "./iam/break-glass/schema.js";
28
+ import { breakGlassCommand } from "./iam/break-glass/handler.js";
29
+ import "./iam/break-glass/index.js";
30
+ import { DEFAULT_REGION, DEFAULT_ROAMING_NAME, SSH_PORT, allowIpOptionsSchema } from "./ec2/allow-ip/schema.js";
31
+ import { authorizeRule, describeSecurityGroups, extractRoamingFirstName, getCurrentPublicIp, getSecurityGroupDetails, instanceLabel, listEnabledRegions, listInstances, listSshIngressRules, printSshRules, resolveRoamingRule, revokeRule, roamingRuleDescription, ruleAlreadyAllowsIp, securityGroupLabel, sshRuleLabel } from "./ec2/allow-ip/utils.js";
32
+ import { allowIpCommand } from "./ec2/allow-ip/handler.js";
33
+ import "./ec2/allow-ip/index.js";
34
+ //#region src/commands/aws/index.js
35
+ /**
36
+ * Commander collector for repeatable options.
37
+ * @param {string} value
38
+ * @param {string[]} previous
39
+ * @returns {string[]}
40
+ */
41
+ function collect(value, previous) {
42
+ return [...previous, value];
43
+ }
44
+ /**
45
+ * Register the `aws` command group and its subcommands on the root program.
46
+ * @param {import('commander').Command} program
47
+ */
48
+ function registerAwsCommands(program) {
49
+ const aws = program.command("aws").summary("AWS operational commands (IAM, EC2, SES, Route53)").description("AWS operational commands for IAM, EC2, SES, and Route53");
50
+ const iam = aws.command("iam").summary("IAM ACL group and user management").description("IAM ACL group and user management");
51
+ iam.command("setup-acl").summary("Create ACL groups, policies, and (optionally) users").description("Idempotently create the ACL groups and managed policies, attach them per group, and optionally create IAM users.").option("--restrict-regions <yes|no>", "Attach the region restriction to acl-power-users (skips the prompt)").option("--no-create-users", "Skip IAM user creation after configuring groups").option("-p, --profile <profile>", "AWS profile (defaults to AWS_PROFILE)").option("-r, --region <region>", "AWS region").option("-v, --verbose", "Enable verbose logging").action(async (options) => {
52
+ await setupAclCommand({
53
+ restrictRegions: options.restrictRegions,
54
+ createUsers: options.createUsers,
55
+ profile: options.profile,
56
+ region: options.region,
57
+ verbose: options.verbose ?? false
58
+ });
59
+ });
60
+ iam.command("users").summary("Interactively create IAM users and assign ACL groups").description("Interactively create md-{identifier}-{account}-{role} IAM users, assign ACL groups, and print CLI setup commands.").option("--account-name <slug>", "AWS account slug used in md-{identifier}-{account}-{role}").option("-p, --profile <profile>", "AWS profile (defaults to AWS_PROFILE)").option("-v, --verbose", "Enable verbose logging").action(async (options) => {
61
+ await usersCommand({
62
+ accountName: options.accountName,
63
+ profile: options.profile,
64
+ verbose: options.verbose ?? false
65
+ });
66
+ });
67
+ iam.command("check-admin").summary("Alert if anyone is in acl-admin-do-not-use").description("Scan one profile (--profile or AWS_PROFILE) or all aws-vault profiles (--all) for members of the break-glass acl-admin-do-not-use group.").option("-p, --profile <profile>", "Operate on this profile (defaults to AWS_PROFILE)").option("--all", "Scan every aws-vault profile (default when no profile is set)").option("-v, --verbose", "Show skipped profiles and detailed errors").action(async (options) => {
68
+ await checkAdminCommand({
69
+ profile: options.profile,
70
+ all: options.all ?? false,
71
+ verbose: options.verbose ?? false
72
+ });
73
+ });
74
+ iam.command("remove-admin").summary("Remove users from the acl-admin-do-not-use group").description("Remove break-glass admin access by removing users from acl-admin-do-not-use, for one profile (--profile or AWS_PROFILE) or every aws-vault profile (--all).").option("-p, --profile <profile>", "Operate on this profile (defaults to AWS_PROFILE)").option("--all", "Scan every aws-vault profile (default when no profile is set)").option("--user <name>", "Only remove this user (repeatable); default removes all", collect, []).option("-y, --yes", "Skip the per-profile confirmation prompt").option("--dry-run", "Preview removals without changing anything").option("-v, --verbose", "Show skipped profiles and detailed errors").action(async (options) => {
75
+ await removeAdminCommand({
76
+ profile: options.profile,
77
+ all: options.all ?? false,
78
+ user: options.user ?? [],
79
+ yes: options.yes ?? false,
80
+ dryRun: options.dryRun ?? false,
81
+ verbose: options.verbose ?? false
82
+ });
83
+ });
84
+ iam.command("break-glass").summary("Grant break-glass admin access (acl-admin-do-not-use)").description("Grant break-glass AdministratorAccess by adding a user to acl-admin-do-not-use for one profile. Defaults to your own IAM user.").option("-p, --profile <profile>", "AWS profile (defaults to AWS_PROFILE)").option("--user <name>", "Grant to this user (repeatable); default is your own IAM user", collect, []).option("-y, --yes", "Skip the confirmation prompt").option("--dry-run", "Preview the grant without changing anything").option("-v, --verbose", "Show detailed errors").action(async (options) => {
85
+ await breakGlassCommand({
86
+ profile: options.profile,
87
+ user: options.user ?? [],
88
+ yes: options.yes ?? false,
89
+ dryRun: options.dryRun ?? false,
90
+ verbose: options.verbose ?? false
91
+ });
92
+ });
93
+ aws.command("ec2").summary("EC2 operational commands").description("EC2 operational commands").command("allow-ip").summary("Allow your current public IP for SSH on an EC2 security group").description("Update or create a named roaming SSH rule (port 22) for your current public IP on a chosen EC2 instance security group.").option("-p, --profile <profile>", "AWS profile (defaults to AWS_PROFILE)").option("-r, --region <region>", "AWS region").option("--rule-name <name>", "SSH rule description (default: \"{FirstName} Roaming\")").option("-v, --verbose", "Enable verbose logging").action(async (options) => {
94
+ await allowIpCommand({
95
+ profile: options.profile,
96
+ region: options.region,
97
+ ruleName: options.ruleName,
98
+ verbose: options.verbose ?? false
99
+ });
100
+ });
101
+ const route53 = aws.command("route53").summary("Route53 DNS commands").description("Route53 DNS commands");
102
+ route53.command("add-record").summary("Interactively add or update a DNS record").description("Add or update a Route53 resource record set. Prompts for hosted zone, type, name, and value when not passed as flags. Shows whether the change creates, overwrites, or appends to an existing record.").option("-p, --profile <profile>", "AWS profile (defaults to AWS_PROFILE)").option("-z, --zone <name-or-id>", "Hosted zone name or ID (e.g. mountaindev.com)").option("-t, --type <type>", "Record type (A, AAAA, CNAME, TXT, MX, NS, SRV, CAA)").option("-n, --name <name>", "Record name relative to the zone (e.g. \"redline\") or FQDN").option("--value <value>", "Record value (e.g. CNAME target)").option("--ttl <seconds>", "TTL in seconds (default: 300)", (value) => Number.parseInt(value, 10)).option("-y, --yes", "Skip the confirmation prompt").option("--dry-run", "Preview the change without calling Route53").option("-v, --verbose", "Enable verbose logging").action(async (options) => {
103
+ await addRecordCommand({
104
+ profile: options.profile,
105
+ zone: options.zone,
106
+ type: options.type,
107
+ name: options.name,
108
+ value: options.value,
109
+ ttl: options.ttl,
110
+ yes: options.yes ?? false,
111
+ dryRun: options.dryRun ?? false,
112
+ verbose: options.verbose ?? false
113
+ });
114
+ });
115
+ route53.command("remove-record").summary("Interactively delete a DNS record").description("Delete a Route53 resource record set. Prompts for hosted zone, type, and name when not passed as flags, shows the record it found, and confirms before deleting.").option("-p, --profile <profile>", "AWS profile (defaults to AWS_PROFILE)").option("-z, --zone <name-or-id>", "Hosted zone name or ID (e.g. mountaindev.com)").option("-t, --type <type>", "Record type (A, AAAA, CNAME, TXT, MX, NS, SRV, CAA)").option("-n, --name <name>", "Record name relative to the zone (e.g. \"redline\") or FQDN").option("-y, --yes", "Skip the confirmation prompt").option("--dry-run", "Preview the deletion without calling Route53").option("-v, --verbose", "Enable verbose logging").action(async (options) => {
116
+ await removeRecordCommand({
117
+ profile: options.profile,
118
+ zone: options.zone,
119
+ type: options.type,
120
+ name: options.name,
121
+ yes: options.yes ?? false,
122
+ dryRun: options.dryRun ?? false,
123
+ verbose: options.verbose ?? false
124
+ });
125
+ });
126
+ aws.command("ses").summary("SES operational commands").description("SES operational commands").command("send-email").summary("Send a test email via SES (API or SMTP)").description("Send a single test email through the SES API (default) or the SES SMTP endpoint.").requiredOption("--to <address>", "Recipient email address").requiredOption("--from <address>", "Verified SES sender email address").option("--subject <subject>", "Email subject line").option("--body <body>", "Email body (defaults to a timestamp and token)").option("--transport <api|smtp>", "Send via SES API or SES SMTP", "api").option("-r, --region <region>", "AWS region for SES", "us-east-1").option("-p, --profile <profile>", "AWS profile for api transport").option("--access-key-id <id>", "IAM access key ID used as the SMTP username (smtp transport)").option("--dry-run", "Print the email payload without sending").option("-v, --verbose", "Enable verbose logging").action(async (options) => {
127
+ await sendEmailCommand({
128
+ to: options.to,
129
+ from: options.from,
130
+ subject: options.subject,
131
+ body: options.body,
132
+ transport: options.transport,
133
+ region: options.region,
134
+ profile: options.profile,
135
+ accessKeyId: options.accessKeyId,
136
+ dryRun: options.dryRun ?? false,
137
+ verbose: options.verbose ?? false
138
+ });
139
+ });
140
+ }
141
+ //#endregion
142
+ export { ACL_GROUPS, ADMIN_GROUP_NAME, CUSTOM_POLICIES, DEFAULT_REGION, DEFAULT_ROAMING_NAME, DEFAULT_TTL, RECORD_TYPES, SSH_PORT, addRecordCommand, addRecordOptionsSchema, allowIpCommand, allowIpOptionsSchema, attach, authorizeRule, bareHostedZoneId, breakGlassCommand, breakGlassOptionsSchema, buildUsername, checkAdminCommand, checkAdminOptionsSchema, createCliAccessKey, createUsersInteractive, defaultBody, deleteResourceRecordSet, describeSecurityGroups, detach, ensureAclGroupsExist, ensureGroup, ensureUser, ensureUserInGroup, extractRoamingFirstName, findCnameConflicts, findHostedZone, formatValues, getCurrentPublicIp, getRecordSetsAtName, getResourceRecordSet, getSecurityGroupDetails, hostedZoneLabel, inferAccountName, instanceLabel, isValidSlug, listEnabledRegions, listHostedZones, listInstances, listSshIngressRules, normalizeIdentifier, normalizeRecordValue, normalizeSlug, parseMdUsername, planRecordChange, printFinalState, printSshRules, publishPolicy, registerAwsCommands, removeAdminCommand, removeAdminOptionsSchema, removeRecordCommand, removeRecordOptionsSchema, resolveHostedZone, resolveName, resolveRecordName, resolveRecordType, resolveRoamingRule, revokeRule, roamingRuleDescription, roleToGroup, ruleAlreadyAllowsIp, securityGroupLabel, sendEmailCommand, sendEmailOptionsSchema, sendViaApi, sendViaSmtp, setupAclCommand, setupAclOptionsSchema, sshRuleLabel, upsertResourceRecordSet, usersCommand, usersOptionsSchema, withTrailingDot, withoutTrailingDot };
@@ -1,18 +1,258 @@
1
- import {
2
- addRecordCommand,
3
- resolveHostedZone,
4
- resolveName,
5
- resolveRecordType
6
- } from "../../../../__chunks/G4NJHFFU.js";
7
- import "../../../../__chunks/33UYMUQD.js";
8
- import "../../../../__chunks/IEOGAQYI.js";
9
- import "../../../../__chunks/FNXUONAV.js";
10
- import "../../../../__chunks/5GIUAFXL.js";
11
- import "../../../../__chunks/73BJG53F.js";
12
- import "../../../../__chunks/ZHKVJO2U.js";
13
- export {
14
- addRecordCommand,
15
- resolveHostedZone,
16
- resolveName,
17
- resolveRecordType
18
- };
1
+ import { prompt, promptChoice, promptYesNo } from "../../utils/tty.js";
2
+ import { AwsCliError, getCallerIdentity, requireCommands } from "../../utils/exec-aws.js";
3
+ import { resolveProfile } from "../../utils/resolve-profile.js";
4
+ import { RECORD_TYPES, addRecordOptionsSchema } from "./schema.js";
5
+ import { findCnameConflicts, findHostedZone, formatValues, getRecordSetsAtName, hostedZoneLabel, listHostedZones, normalizeRecordValue, planRecordChange, resolveRecordName, upsertResourceRecordSet, withoutTrailingDot } from "./utils.js";
6
+ import chalk from "chalk";
7
+ import { ZodError } from "zod";
8
+ //#region src/commands/aws/route53/add-record/handler.js
9
+ /**
10
+ * Resolve the hosted zone: from --zone, or interactive picker.
11
+ * @param {{
12
+ * profile?: string;
13
+ * zoneOption?: string;
14
+ * verbose: boolean;
15
+ * }} params
16
+ * @returns {Promise<import("./utils.js").HostedZone>}
17
+ */
18
+ async function resolveHostedZone(params) {
19
+ const { profile, zoneOption, verbose } = params;
20
+ const zones = listHostedZones({
21
+ profile,
22
+ verbose
23
+ });
24
+ if (zones.length === 0) throw new Error("No Route53 hosted zones found for this profile.");
25
+ if (zoneOption) {
26
+ const match = findHostedZone({
27
+ zones,
28
+ zoneInput: zoneOption
29
+ });
30
+ if (!match) throw new Error(`No hosted zone matching "${zoneOption}". Available: ${zones.map((z) => withoutTrailingDot(z.name)).join(", ")}`);
31
+ return match;
32
+ }
33
+ const chosen = zones[await promptChoice({
34
+ message: "Choose a hosted zone:",
35
+ options: zones.map((zone) => hostedZoneLabel(zone))
36
+ })];
37
+ if (!chosen) throw new Error("No hosted zone selected");
38
+ return chosen;
39
+ }
40
+ /**
41
+ * Resolve record type from --type or interactive picker.
42
+ * @param {string | undefined} typeOption
43
+ * @returns {Promise<string>}
44
+ */
45
+ async function resolveRecordType(typeOption) {
46
+ if (typeOption) return typeOption.toUpperCase();
47
+ const index = await promptChoice({
48
+ message: "Choose a record type:",
49
+ options: RECORD_TYPES
50
+ });
51
+ const chosen = RECORD_TYPES[index];
52
+ if (!chosen) throw new Error("No record type selected");
53
+ return chosen;
54
+ }
55
+ /**
56
+ * Resolve record name from --name or prompt.
57
+ * @param {{ nameOption?: string; zoneName: string }} params
58
+ * @returns {Promise<string>} FQDN with trailing dot
59
+ */
60
+ async function resolveName(params) {
61
+ const { nameOption, zoneName } = params;
62
+ let input = nameOption;
63
+ if (!input) input = await prompt(`Record name (relative to ${withoutTrailingDot(zoneName)}, or FQDN; @ for apex): `);
64
+ if (!input) throw new Error("Record name is required");
65
+ return resolveRecordName({
66
+ nameInput: input,
67
+ zoneName
68
+ });
69
+ }
70
+ /**
71
+ * Resolve record value from --value or prompt.
72
+ * @param {{ valueOption?: string; type: string }} params
73
+ * @returns {Promise<string>}
74
+ */
75
+ async function resolveValue(params) {
76
+ const { valueOption, type } = params;
77
+ let input = valueOption;
78
+ if (!input) input = await prompt(`Record value${type === "CNAME" ? " (e.g. target.example.com.)" : type === "TXT" ? " (quotes added if omitted)" : ""}: `);
79
+ if (!input) throw new Error("Record value is required");
80
+ return normalizeRecordValue({
81
+ type,
82
+ value: input
83
+ });
84
+ }
85
+ /**
86
+ * When an existing multi-value set is present, ask replace vs append
87
+ * (single-value types default to replace).
88
+ * @param {{
89
+ * existing: import("./utils.js").ResourceRecordSet;
90
+ * type: string;
91
+ * }} params
92
+ * @returns {Promise<"replace" | "append">}
93
+ */
94
+ async function resolveChangeMode(params) {
95
+ const { existing, type } = params;
96
+ if (type === "CNAME" || existing.values.length <= 1) return "replace";
97
+ console.log("");
98
+ console.log(chalk.yellow(`Existing ${type} record has ${existing.values.length} values:${formatValues(existing.values)}`));
99
+ return await promptYesNo({
100
+ message: "Add to the existing values instead of replacing them?",
101
+ defaultYes: false
102
+ }) ? "append" : "replace";
103
+ }
104
+ /**
105
+ * `aws route53 add-record` handler: interactively (or via flags) create or
106
+ * update a Route53 resource record set, showing whether the change adds or
107
+ * overwrites.
108
+ * @param {unknown} options
109
+ */
110
+ async function addRecordCommand(options) {
111
+ try {
112
+ const { profile: profileOption, zone: zoneOption, type: typeOption, name: nameOption, value: valueOption, ttl: ttlOption, yes, dryRun, verbose } = addRecordOptionsSchema.parse(options);
113
+ const profile = await resolveProfile({ profile: profileOption });
114
+ if (!profile) {
115
+ console.error(chalk.red("Error: pass --profile or set AWS_PROFILE."));
116
+ process.exit(1);
117
+ }
118
+ requireCommands(["aws"]);
119
+ const identity = getCallerIdentity({
120
+ profile,
121
+ verbose
122
+ });
123
+ console.log("Caller:");
124
+ console.log(` Account: ${identity.Account}`);
125
+ console.log(` Arn: ${identity.Arn}`);
126
+ console.log("");
127
+ const zone = await resolveHostedZone({
128
+ profile,
129
+ zoneOption,
130
+ verbose
131
+ });
132
+ console.log(`Hosted zone: ${hostedZoneLabel(zone)}`);
133
+ console.log("");
134
+ const type = await resolveRecordType(typeOption);
135
+ const name = await resolveName({
136
+ nameOption,
137
+ zoneName: zone.name
138
+ });
139
+ const value = await resolveValue({
140
+ valueOption,
141
+ type
142
+ });
143
+ const ttl = ttlOption ?? 300;
144
+ console.log("");
145
+ console.log("Proposed record:");
146
+ console.log(` Name: ${withoutTrailingDot(name)}`);
147
+ console.log(` Type: ${type}`);
148
+ console.log(` TTL: ${ttl}`);
149
+ console.log(` Value: ${value}`);
150
+ console.log("");
151
+ const existingSets = getRecordSetsAtName({
152
+ profile,
153
+ hostedZoneId: zone.id,
154
+ name,
155
+ verbose
156
+ });
157
+ const existing = existingSets.find((set) => set.type === type) ?? null;
158
+ const conflicts = findCnameConflicts({
159
+ existingSets,
160
+ type
161
+ });
162
+ if (conflicts.length > 0) {
163
+ console.error(chalk.red(`❌ Conflict: cannot add a ${type} record at ${withoutTrailingDot(name)}.`));
164
+ console.error("");
165
+ console.error(chalk.yellow("Route53 does not allow a CNAME and any other record type to coexist at the same name. Conflicting record(s) already exist:"));
166
+ for (const conflict of conflicts) console.error(` ${conflict.type} ${withoutTrailingDot(conflict.name)}${formatValues(conflict.isAlias ? ["(alias)"] : conflict.values)}`);
167
+ console.error("");
168
+ console.error(chalk.yellow("Remove the conflicting record, then re-create the one you wanted:"));
169
+ const zoneName = withoutTrailingDot(zone.name);
170
+ const displayName = withoutTrailingDot(name);
171
+ const quotedValue = /^[A-Za-z0-9._:@/-]+$/.test(value) ? value : `"${value}"`;
172
+ const ttlFlag = ttl === 300 ? "" : ` --ttl ${ttl}`;
173
+ let step = 1;
174
+ for (const conflict of conflicts) console.error(chalk.cyan(` ${step++}. mtn aws route53 remove-record -z ${zoneName} -t ${conflict.type} -n ${displayName}`));
175
+ console.error(chalk.cyan(` ${step}. mtn aws route53 add-record -z ${zoneName} -t ${type} -n ${displayName} --value ${quotedValue}${ttlFlag}`));
176
+ process.exit(1);
177
+ }
178
+ if (existing?.isAlias) {
179
+ console.log(chalk.yellow("An ALIAS record already exists at this name + type. Continuing will replace it with a standard record set."));
180
+ console.log("");
181
+ } else if (existing) {
182
+ console.log(chalk.yellow(`Existing ${type} record at ${withoutTrailingDot(name)}:${formatValues(existing.values)}`));
183
+ if (existing.ttl !== void 0) console.log(` TTL: ${existing.ttl}`);
184
+ console.log("");
185
+ } else {
186
+ console.log(chalk.green(`No existing ${type} record at ${withoutTrailingDot(name)}.`));
187
+ console.log("");
188
+ }
189
+ /** @type {"replace" | "append"} */
190
+ let mode = "replace";
191
+ if (existing && !existing.isAlias && existing.values.length > 0) mode = await resolveChangeMode({
192
+ existing,
193
+ type
194
+ });
195
+ const plan = planRecordChange({
196
+ existing,
197
+ newValue: value,
198
+ mode
199
+ });
200
+ console.log(plan.summary);
201
+ console.log("");
202
+ if (plan.action === "noop") return;
203
+ if (plan.action === "overwrite" || plan.action === "append") {
204
+ console.log("Final values that will be written:");
205
+ for (const finalValue of plan.finalValues) console.log(` - ${finalValue}`);
206
+ console.log("");
207
+ }
208
+ if (dryRun) {
209
+ console.log(chalk.cyan("Dry run — no changes made."));
210
+ return;
211
+ }
212
+ if (!yes) {
213
+ if (!await promptYesNo({
214
+ message: plan.action === "create" ? "Create this record?" : plan.action === "append" ? "Add this value to the existing record?" : "Overwrite the existing record?",
215
+ defaultYes: false
216
+ })) {
217
+ console.log("Aborted.");
218
+ return;
219
+ }
220
+ }
221
+ const changeInfo = upsertResourceRecordSet({
222
+ profile,
223
+ hostedZoneId: zone.id,
224
+ name,
225
+ type,
226
+ ttl: existing?.ttl ?? ttl,
227
+ values: plan.finalValues,
228
+ verbose
229
+ });
230
+ console.log("");
231
+ console.log(chalk.green(`Done. ${plan.action === "create" ? "Created" : plan.action === "append" ? "Updated (appended)" : "Updated (overwrote)"} ${type} ${withoutTrailingDot(name)}.`));
232
+ if (changeInfo?.Id) {
233
+ console.log(` Change ID: ${changeInfo.Id}`);
234
+ console.log(` Status: ${changeInfo.Status ?? "PENDING"}`);
235
+ }
236
+ } catch (error) {
237
+ if (error instanceof ZodError) {
238
+ console.error(chalk.red("\n❌ Invalid command options:"));
239
+ error.errors.forEach((err) => {
240
+ console.error(chalk.red(` ${err.path.join(".")}: ${err.message}`));
241
+ });
242
+ process.exit(1);
243
+ }
244
+ const verbose = options?.verbose || false;
245
+ console.error(chalk.red("\n❌ add-record failed:"));
246
+ if (error instanceof AwsCliError || error instanceof Error) {
247
+ console.error(chalk.red(` ${error.message}`));
248
+ if (verbose && error.stack) {
249
+ console.error(chalk.gray("\nStack trace:"));
250
+ console.error(chalk.gray(error.stack));
251
+ }
252
+ } else console.error(chalk.red(` ${String(error)}`));
253
+ console.error(chalk.yellow("\n💡 Use --verbose for detailed error information\n"));
254
+ process.exit(1);
255
+ }
256
+ }
257
+ //#endregion
258
+ export { addRecordCommand, resolveHostedZone, resolveName, resolveRecordType };