@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.
- package/CHANGELOG.md +91 -0
- package/cjs/__chunks/VH7oDXx4.cjs +28 -0
- package/cjs/commands/aws/ec2/allow-ip/handler.cjs +261 -0
- package/cjs/commands/aws/ec2/allow-ip/handler.d.ts +6 -0
- package/cjs/commands/aws/ec2/allow-ip/index.cjs +25 -0
- package/cjs/commands/aws/ec2/allow-ip/index.d.ts +3 -0
- package/cjs/commands/aws/ec2/allow-ip/schema.cjs +33 -0
- package/cjs/commands/aws/ec2/allow-ip/schema.d.ts +33 -0
- package/cjs/commands/aws/ec2/allow-ip/utils.cjs +379 -0
- package/cjs/commands/aws/ec2/allow-ip/utils.d.ts +189 -0
- package/cjs/commands/aws/iam/admin-group.cjs +111 -0
- package/cjs/commands/aws/iam/admin-group.d.ts +55 -0
- package/cjs/commands/aws/iam/break-glass/handler.cjs +127 -0
- package/cjs/commands/aws/iam/break-glass/handler.d.ts +7 -0
- package/cjs/commands/aws/iam/break-glass/index.cjs +7 -0
- package/cjs/commands/aws/iam/break-glass/index.d.ts +2 -0
- package/cjs/commands/aws/iam/break-glass/schema.cjs +21 -0
- package/cjs/commands/aws/iam/break-glass/schema.d.ts +25 -0
- package/cjs/commands/aws/iam/check-admin/handler.cjs +89 -0
- package/cjs/commands/aws/iam/check-admin/handler.d.ts +5 -0
- package/cjs/commands/aws/iam/check-admin/index.cjs +7 -0
- package/cjs/commands/aws/iam/check-admin/index.d.ts +2 -0
- package/cjs/commands/aws/iam/check-admin/schema.cjs +19 -0
- package/cjs/commands/aws/iam/check-admin/schema.d.ts +19 -0
- package/cjs/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
- package/cjs/commands/aws/iam/policies/sts-federation.json +11 -0
- package/cjs/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
- package/cjs/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
- package/cjs/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
- package/cjs/commands/aws/iam/policies/user-admins-write-list.json +117 -0
- package/cjs/commands/aws/iam/remove-admin/handler.cjs +120 -0
- package/cjs/commands/aws/iam/remove-admin/handler.d.ts +6 -0
- package/cjs/commands/aws/iam/remove-admin/index.cjs +7 -0
- package/cjs/commands/aws/iam/remove-admin/index.d.ts +2 -0
- package/cjs/commands/aws/iam/remove-admin/schema.cjs +22 -0
- package/cjs/commands/aws/iam/remove-admin/schema.d.ts +28 -0
- package/cjs/commands/aws/iam/setup-acl/handler.cjs +227 -0
- package/cjs/commands/aws/iam/setup-acl/handler.d.ts +6 -0
- package/cjs/commands/aws/iam/setup-acl/index.cjs +13 -0
- package/cjs/commands/aws/iam/setup-acl/index.d.ts +3 -0
- package/cjs/commands/aws/iam/setup-acl/schema.cjs +19 -0
- package/cjs/commands/aws/iam/setup-acl/schema.d.ts +24 -0
- package/cjs/commands/aws/iam/setup-acl/utils.cjs +305 -0
- package/cjs/commands/aws/iam/setup-acl/utils.d.ts +61 -0
- package/cjs/commands/aws/iam/users/handler.cjs +59 -0
- package/cjs/commands/aws/iam/users/handler.d.ts +5 -0
- package/cjs/commands/aws/iam/users/index.cjs +18 -0
- package/cjs/commands/aws/iam/users/index.d.ts +3 -0
- package/cjs/commands/aws/iam/users/schema.cjs +17 -0
- package/cjs/commands/aws/iam/users/schema.d.ts +18 -0
- package/cjs/commands/aws/iam/users/utils.cjs +454 -0
- package/cjs/commands/aws/iam/users/utils.d.ts +119 -0
- package/cjs/commands/aws/index.cjs +223 -0
- package/cjs/commands/aws/index.d.ts +14 -0
- package/cjs/commands/aws/route53/add-record/handler.cjs +264 -0
- package/cjs/commands/aws/route53/add-record/handler.d.ts +36 -0
- package/cjs/commands/aws/route53/add-record/index.cjs +26 -0
- package/cjs/commands/aws/route53/add-record/index.d.ts +3 -0
- package/cjs/commands/aws/route53/add-record/schema.cjs +43 -0
- package/cjs/commands/aws/route53/add-record/schema.d.ts +45 -0
- package/cjs/commands/aws/route53/add-record/utils.cjs +404 -0
- package/cjs/commands/aws/route53/add-record/utils.d.ts +216 -0
- package/cjs/commands/aws/route53/remove-record/handler.cjs +114 -0
- package/cjs/commands/aws/route53/remove-record/handler.d.ts +6 -0
- package/cjs/commands/aws/route53/remove-record/index.cjs +5 -0
- package/cjs/commands/aws/route53/remove-record/index.d.ts +2 -0
- package/cjs/commands/aws/route53/remove-record/schema.cjs +22 -0
- package/cjs/commands/aws/route53/remove-record/schema.d.ts +30 -0
- package/cjs/commands/aws/schema.cjs +19 -0
- package/cjs/commands/aws/schema.d.ts +13 -0
- package/cjs/commands/aws/ses/send-email/handler.cjs +73 -0
- package/cjs/commands/aws/ses/send-email/handler.d.ts +5 -0
- package/cjs/commands/aws/ses/send-email/index.cjs +9 -0
- package/cjs/commands/aws/ses/send-email/index.d.ts +3 -0
- package/cjs/commands/aws/ses/send-email/schema.cjs +24 -0
- package/cjs/commands/aws/ses/send-email/schema.d.ts +39 -0
- package/cjs/commands/aws/ses/send-email/utils.cjs +87 -0
- package/cjs/commands/aws/ses/send-email/utils.d.ts +47 -0
- package/cjs/commands/aws/ses/smtp-password.cjs +72 -0
- package/cjs/commands/aws/ses/smtp-password.d.ts +21 -0
- package/cjs/commands/aws/utils/exec-aws.cjs +145 -0
- package/cjs/commands/aws/utils/exec-aws.d.ts +79 -0
- package/cjs/commands/aws/utils/resolve-policy-path.cjs +15 -0
- package/cjs/commands/aws/utils/resolve-policy-path.d.ts +8 -0
- package/cjs/commands/aws/utils/resolve-profile.cjs +93 -0
- package/cjs/commands/aws/utils/resolve-profile.d.ts +28 -0
- package/cjs/commands/aws/utils/tty.cjs +54 -0
- package/cjs/commands/aws/utils/tty.d.ts +24 -0
- package/cjs/commands/db/create-readonly-user/handler.cjs +254 -0
- package/cjs/commands/db/create-readonly-user/handler.d.ts +5 -0
- package/cjs/commands/db/create-readonly-user/index.cjs +18 -0
- package/cjs/commands/db/create-readonly-user/index.d.ts +3 -0
- package/cjs/commands/db/create-readonly-user/mysql.cjs +102 -0
- package/cjs/commands/db/create-readonly-user/mysql.d.ts +33 -0
- package/cjs/commands/db/create-readonly-user/postgres.cjs +209 -0
- package/cjs/commands/db/create-readonly-user/postgres.d.ts +31 -0
- package/cjs/commands/db/create-readonly-user/schema.cjs +39 -0
- package/cjs/commands/db/create-readonly-user/schema.d.ts +55 -0
- package/cjs/commands/db/create-readonly-user/utils.cjs +160 -0
- package/cjs/commands/db/create-readonly-user/utils.d.ts +112 -0
- package/cjs/commands/db/index.cjs +46 -0
- package/cjs/commands/db/index.d.ts +6 -0
- package/cjs/commands/doppler/handler.cjs +95 -9
- package/cjs/commands/doppler/index.cjs +33 -41
- package/cjs/commands/doppler/index.d.ts +1 -0
- package/cjs/commands/doppler/schema.cjs +130 -6
- package/cjs/commands/doppler/schema.d.ts +233 -17
- package/cjs/commands/doppler/set-secret.cjs +378 -0
- package/cjs/commands/doppler/set-secret.d.ts +113 -0
- package/cjs/commands/doppler/utils/exec.cjs +106 -12
- package/cjs/commands/doppler/utils.cjs +412 -30
- package/cjs/commands/doppler/utils.d.ts +32 -8
- package/cjs/commands/icons/handler.cjs +82 -8
- package/cjs/commands/icons/index.cjs +15 -31
- package/cjs/commands/icons/schema.cjs +101 -13
- package/cjs/commands/icons/schema.d.ts +1 -1
- package/cjs/commands/icons/utils.cjs +131 -13
- package/cjs/commands/index.cjs +54 -82
- package/cjs/commands/schema.cjs +25 -8
- package/cjs/index.cjs +3 -4
- package/esm/commands/aws/ec2/allow-ip/handler.d.ts +6 -0
- package/esm/commands/aws/ec2/allow-ip/handler.js +258 -0
- package/esm/commands/aws/ec2/allow-ip/index.d.ts +3 -0
- package/esm/commands/aws/ec2/allow-ip/index.js +4 -0
- package/esm/commands/aws/ec2/allow-ip/schema.d.ts +33 -0
- package/esm/commands/aws/ec2/allow-ip/schema.js +29 -0
- package/esm/commands/aws/ec2/allow-ip/utils.d.ts +189 -0
- package/esm/commands/aws/ec2/allow-ip/utils.js +363 -0
- package/esm/commands/aws/iam/admin-group.d.ts +55 -0
- package/esm/commands/aws/iam/admin-group.js +104 -0
- package/esm/commands/aws/iam/break-glass/handler.d.ts +7 -0
- package/esm/commands/aws/iam/break-glass/handler.js +124 -0
- package/esm/commands/aws/iam/break-glass/index.d.ts +2 -0
- package/esm/commands/aws/iam/break-glass/index.js +4 -0
- package/esm/commands/aws/iam/break-glass/schema.d.ts +25 -0
- package/esm/commands/aws/iam/break-glass/schema.js +19 -0
- package/esm/commands/aws/iam/check-admin/handler.d.ts +5 -0
- package/esm/commands/aws/iam/check-admin/handler.js +86 -0
- package/esm/commands/aws/iam/check-admin/index.d.ts +2 -0
- package/esm/commands/aws/iam/check-admin/index.js +4 -0
- package/esm/commands/aws/iam/check-admin/schema.d.ts +19 -0
- package/esm/commands/aws/iam/check-admin/schema.js +17 -0
- package/esm/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
- package/esm/commands/aws/iam/policies/sts-federation.json +11 -0
- package/esm/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
- package/esm/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
- package/esm/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
- package/esm/commands/aws/iam/policies/user-admins-write-list.json +117 -0
- package/esm/commands/aws/iam/remove-admin/handler.d.ts +6 -0
- package/esm/commands/aws/iam/remove-admin/handler.js +117 -0
- package/esm/commands/aws/iam/remove-admin/index.d.ts +2 -0
- package/esm/commands/aws/iam/remove-admin/index.js +4 -0
- package/esm/commands/aws/iam/remove-admin/schema.d.ts +28 -0
- package/esm/commands/aws/iam/remove-admin/schema.js +20 -0
- package/esm/commands/aws/iam/setup-acl/handler.d.ts +6 -0
- package/esm/commands/aws/iam/setup-acl/handler.js +224 -0
- package/esm/commands/aws/iam/setup-acl/index.d.ts +3 -0
- package/esm/commands/aws/iam/setup-acl/index.js +4 -0
- package/esm/commands/aws/iam/setup-acl/schema.d.ts +24 -0
- package/esm/commands/aws/iam/setup-acl/schema.js +18 -0
- package/esm/commands/aws/iam/setup-acl/utils.d.ts +61 -0
- package/esm/commands/aws/iam/setup-acl/utils.js +298 -0
- package/esm/commands/aws/iam/users/handler.d.ts +5 -0
- package/esm/commands/aws/iam/users/handler.js +56 -0
- package/esm/commands/aws/iam/users/index.d.ts +3 -0
- package/esm/commands/aws/iam/users/index.js +4 -0
- package/esm/commands/aws/iam/users/schema.d.ts +18 -0
- package/esm/commands/aws/iam/users/schema.js +16 -0
- package/esm/commands/aws/iam/users/utils.d.ts +119 -0
- package/esm/commands/aws/iam/users/utils.js +440 -0
- package/esm/commands/aws/index.d.ts +14 -0
- package/esm/commands/aws/index.js +142 -0
- package/esm/commands/aws/route53/add-record/handler.d.ts +36 -0
- package/esm/commands/aws/route53/add-record/handler.js +258 -0
- package/esm/commands/aws/route53/add-record/index.d.ts +3 -0
- package/esm/commands/aws/route53/add-record/index.js +4 -0
- package/esm/commands/aws/route53/add-record/schema.d.ts +45 -0
- package/esm/commands/aws/route53/add-record/schema.js +40 -0
- package/esm/commands/aws/route53/add-record/utils.d.ts +216 -0
- package/esm/commands/aws/route53/add-record/utils.js +389 -0
- package/esm/commands/aws/route53/remove-record/handler.d.ts +6 -0
- package/esm/commands/aws/route53/remove-record/handler.js +111 -0
- package/esm/commands/aws/route53/remove-record/index.d.ts +2 -0
- package/esm/commands/aws/route53/remove-record/index.js +3 -0
- package/esm/commands/aws/route53/remove-record/schema.d.ts +30 -0
- package/esm/commands/aws/route53/remove-record/schema.js +21 -0
- package/esm/commands/aws/schema.d.ts +13 -0
- package/esm/commands/aws/schema.js +16 -0
- package/esm/commands/aws/ses/send-email/handler.d.ts +5 -0
- package/esm/commands/aws/ses/send-email/handler.js +70 -0
- package/esm/commands/aws/ses/send-email/index.d.ts +3 -0
- package/esm/commands/aws/ses/send-email/index.js +4 -0
- package/esm/commands/aws/ses/send-email/schema.d.ts +39 -0
- package/esm/commands/aws/ses/send-email/schema.js +23 -0
- package/esm/commands/aws/ses/send-email/utils.d.ts +47 -0
- package/esm/commands/aws/ses/send-email/utils.js +84 -0
- package/esm/commands/aws/ses/smtp-password.d.ts +21 -0
- package/esm/commands/aws/ses/smtp-password.js +69 -0
- package/esm/commands/aws/utils/exec-aws.d.ts +79 -0
- package/esm/commands/aws/utils/exec-aws.js +137 -0
- package/esm/commands/aws/utils/resolve-policy-path.d.ts +8 -0
- package/esm/commands/aws/utils/resolve-policy-path.js +14 -0
- package/esm/commands/aws/utils/resolve-profile.d.ts +28 -0
- package/esm/commands/aws/utils/resolve-profile.js +88 -0
- package/esm/commands/aws/utils/tty.d.ts +24 -0
- package/esm/commands/aws/utils/tty.js +51 -0
- package/esm/commands/db/create-readonly-user/handler.d.ts +5 -0
- package/esm/commands/db/create-readonly-user/handler.js +251 -0
- package/esm/commands/db/create-readonly-user/index.d.ts +3 -0
- package/esm/commands/db/create-readonly-user/index.js +4 -0
- package/esm/commands/db/create-readonly-user/mysql.d.ts +33 -0
- package/esm/commands/db/create-readonly-user/mysql.js +98 -0
- package/esm/commands/db/create-readonly-user/postgres.d.ts +31 -0
- package/esm/commands/db/create-readonly-user/postgres.js +205 -0
- package/esm/commands/db/create-readonly-user/schema.d.ts +55 -0
- package/esm/commands/db/create-readonly-user/schema.js +35 -0
- package/esm/commands/db/create-readonly-user/utils.d.ts +112 -0
- package/esm/commands/db/create-readonly-user/utils.js +151 -0
- package/esm/commands/db/index.d.ts +6 -0
- package/esm/commands/db/index.js +31 -0
- package/esm/commands/doppler/handler.js +92 -9
- package/esm/commands/doppler/index.d.ts +1 -0
- package/esm/commands/doppler/index.js +6 -41
- package/esm/commands/doppler/schema.d.ts +233 -17
- package/esm/commands/doppler/schema.js +125 -7
- package/esm/commands/doppler/set-secret.d.ts +113 -0
- package/esm/commands/doppler/set-secret.js +370 -0
- package/esm/commands/doppler/utils/exec.js +100 -12
- package/esm/commands/doppler/utils.d.ts +32 -8
- package/esm/commands/doppler/utils.js +396 -30
- package/esm/commands/icons/handler.js +79 -8
- package/esm/commands/icons/index.js +4 -31
- package/esm/commands/icons/schema.d.ts +1 -1
- package/esm/commands/icons/schema.js +97 -15
- package/esm/commands/icons/utils.js +125 -13
- package/esm/commands/index.js +49 -78
- package/esm/commands/schema.js +22 -7
- package/esm/index.js +3 -4
- package/package.json +12 -2
- package/vitest.config.ts +11 -0
- package/cjs/__chunks/4GFJUCSP.cjs +0 -52
- package/cjs/__chunks/4SFWHCB3.cjs +0 -133
- package/cjs/__chunks/B2KFW7T7.cjs +0 -1
- package/cjs/__chunks/EMMC33QA.cjs +0 -401
- package/cjs/__chunks/INFOPAHN.cjs +0 -117
- package/cjs/__chunks/J36P6UNE.cjs +0 -75
- package/cjs/__chunks/NIMXXHJQ.cjs +0 -92
- package/cjs/__chunks/NSRFG4DF.cjs +0 -100
- package/cjs/__chunks/WNJ3ZYLI.cjs +0 -1
- package/cjs/__chunks/ZMDIOZPT.cjs +0 -22
- package/esm/__chunks/46HGXFME.js +0 -0
- package/esm/__chunks/6G4PXXKF.js +0 -75
- package/esm/__chunks/6L5RNR7G.js +0 -100
- package/esm/__chunks/FL7AILGH.js +0 -133
- package/esm/__chunks/HJSXC6HP.js +0 -117
- package/esm/__chunks/O262GK4B.js +0 -401
- package/esm/__chunks/O3CCA76Q.js +0 -22
- package/esm/__chunks/SJXQJ7RS.js +0 -92
- package/esm/__chunks/SNCKIAOR.js +0 -0
- package/esm/__chunks/X3R5PSWH.js +0 -52
|
@@ -0,0 +1,305 @@
|
|
|
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_utils_resolve_policy_path = require("../../utils/resolve-policy-path.cjs");
|
|
4
|
+
//#region src/commands/aws/iam/setup-acl/utils.js
|
|
5
|
+
/**
|
|
6
|
+
* The five ACL groups managed by setup-acl.
|
|
7
|
+
*/
|
|
8
|
+
const ACL_GROUPS = [
|
|
9
|
+
"acl-admin-do-not-use",
|
|
10
|
+
"acl-iam-full-access",
|
|
11
|
+
"acl-power-users",
|
|
12
|
+
"acl-read-only",
|
|
13
|
+
"acl-s3-restrictions"
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* Custom managed policies published from bundled JSON documents.
|
|
17
|
+
* @type {Array<{ name: string; fileName: string }>}
|
|
18
|
+
*/
|
|
19
|
+
const CUSTOM_POLICIES = [
|
|
20
|
+
{
|
|
21
|
+
name: "UserAdminsWriteList",
|
|
22
|
+
fileName: "user-admins-write-list.json"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "UserAdminsDenyList",
|
|
26
|
+
fileName: "user-admins-deny-list.json"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "UserAdminsSelfServiceIAM",
|
|
30
|
+
fileName: "user-admins-self-service-iam.json"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "UserAdminsDenyRegionsList",
|
|
34
|
+
fileName: "user-admins-deny-regions-list.json"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "sts-federation",
|
|
38
|
+
fileName: "sts-federation.json"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "S3RestrictionsDenyNonS3Services",
|
|
42
|
+
fileName: "s3-restrictions-deny-non-s3-services.json"
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
/**
|
|
46
|
+
* Create an IAM group if it does not already exist.
|
|
47
|
+
* @param {{ name: string; profile?: string; verbose?: boolean }} params
|
|
48
|
+
*/
|
|
49
|
+
function ensureGroup(params) {
|
|
50
|
+
const { name, profile, verbose } = params;
|
|
51
|
+
let exists = true;
|
|
52
|
+
try {
|
|
53
|
+
require_commands_aws_utils_exec_aws.runAws({
|
|
54
|
+
profile,
|
|
55
|
+
args: [
|
|
56
|
+
"iam",
|
|
57
|
+
"get-group",
|
|
58
|
+
"--group-name",
|
|
59
|
+
name
|
|
60
|
+
],
|
|
61
|
+
verbose
|
|
62
|
+
});
|
|
63
|
+
} catch {
|
|
64
|
+
exists = false;
|
|
65
|
+
}
|
|
66
|
+
if (exists) {
|
|
67
|
+
console.log(` Group exists: ${name}`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
console.log(` Create group: ${name}`);
|
|
71
|
+
require_commands_aws_utils_exec_aws.runAws({
|
|
72
|
+
profile,
|
|
73
|
+
args: [
|
|
74
|
+
"iam",
|
|
75
|
+
"create-group",
|
|
76
|
+
"--group-name",
|
|
77
|
+
name,
|
|
78
|
+
"--path",
|
|
79
|
+
"/"
|
|
80
|
+
],
|
|
81
|
+
expectJson: false,
|
|
82
|
+
verbose
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Create or update a customer-managed policy from a bundled JSON document.
|
|
87
|
+
* Handles the IAM five-version limit by pruning the oldest non-default version.
|
|
88
|
+
* @param {{ name: string; fileName: string; accountId: string; profile?: string; verbose?: boolean }} params
|
|
89
|
+
*/
|
|
90
|
+
function publishPolicy(params) {
|
|
91
|
+
const { name, fileName, accountId, profile, verbose } = params;
|
|
92
|
+
const arn = `arn:aws:iam::${accountId}:policy/${name}`;
|
|
93
|
+
const file = require_commands_aws_utils_resolve_policy_path.resolvePolicyPath(fileName);
|
|
94
|
+
let exists = true;
|
|
95
|
+
try {
|
|
96
|
+
require_commands_aws_utils_exec_aws.runAws({
|
|
97
|
+
profile,
|
|
98
|
+
args: [
|
|
99
|
+
"iam",
|
|
100
|
+
"get-policy",
|
|
101
|
+
"--policy-arn",
|
|
102
|
+
arn
|
|
103
|
+
],
|
|
104
|
+
verbose
|
|
105
|
+
});
|
|
106
|
+
} catch {
|
|
107
|
+
exists = false;
|
|
108
|
+
}
|
|
109
|
+
if (!exists) {
|
|
110
|
+
console.log(` Create policy: ${name}`);
|
|
111
|
+
require_commands_aws_utils_exec_aws.runAws({
|
|
112
|
+
profile,
|
|
113
|
+
args: [
|
|
114
|
+
"iam",
|
|
115
|
+
"create-policy",
|
|
116
|
+
"--policy-name",
|
|
117
|
+
name,
|
|
118
|
+
"--policy-document",
|
|
119
|
+
`file://${file}`,
|
|
120
|
+
"--description",
|
|
121
|
+
`ACL: ${name}`
|
|
122
|
+
],
|
|
123
|
+
expectJson: false,
|
|
124
|
+
verbose
|
|
125
|
+
});
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if ((Number.parseInt(require_commands_aws_utils_exec_aws.runAws({
|
|
129
|
+
profile,
|
|
130
|
+
args: [
|
|
131
|
+
"iam",
|
|
132
|
+
"list-policy-versions",
|
|
133
|
+
"--policy-arn",
|
|
134
|
+
arn,
|
|
135
|
+
"--query",
|
|
136
|
+
"length(Versions[?IsDefaultVersion==`false`])",
|
|
137
|
+
"--output",
|
|
138
|
+
"text"
|
|
139
|
+
],
|
|
140
|
+
expectJson: false,
|
|
141
|
+
verbose
|
|
142
|
+
}), 10) || 0) >= 4) {
|
|
143
|
+
const oldest = require_commands_aws_utils_exec_aws.runAws({
|
|
144
|
+
profile,
|
|
145
|
+
args: [
|
|
146
|
+
"iam",
|
|
147
|
+
"list-policy-versions",
|
|
148
|
+
"--policy-arn",
|
|
149
|
+
arn,
|
|
150
|
+
"--query",
|
|
151
|
+
"Versions[?IsDefaultVersion==`false`] | sort_by(@, &CreateDate)[0].VersionId",
|
|
152
|
+
"--output",
|
|
153
|
+
"text"
|
|
154
|
+
],
|
|
155
|
+
expectJson: false,
|
|
156
|
+
verbose
|
|
157
|
+
});
|
|
158
|
+
console.log(` Prune oldest version of ${name}: ${oldest}`);
|
|
159
|
+
require_commands_aws_utils_exec_aws.runAws({
|
|
160
|
+
profile,
|
|
161
|
+
args: [
|
|
162
|
+
"iam",
|
|
163
|
+
"delete-policy-version",
|
|
164
|
+
"--policy-arn",
|
|
165
|
+
arn,
|
|
166
|
+
"--version-id",
|
|
167
|
+
oldest
|
|
168
|
+
],
|
|
169
|
+
expectJson: false,
|
|
170
|
+
verbose
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
console.log(` Update policy: ${name}`);
|
|
174
|
+
require_commands_aws_utils_exec_aws.runAws({
|
|
175
|
+
profile,
|
|
176
|
+
args: [
|
|
177
|
+
"iam",
|
|
178
|
+
"create-policy-version",
|
|
179
|
+
"--policy-arn",
|
|
180
|
+
arn,
|
|
181
|
+
"--policy-document",
|
|
182
|
+
`file://${file}`,
|
|
183
|
+
"--set-as-default"
|
|
184
|
+
],
|
|
185
|
+
expectJson: false,
|
|
186
|
+
verbose
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* @param {{ group: string; arn: string; profile?: string; verbose?: boolean }} params
|
|
191
|
+
* @returns {boolean}
|
|
192
|
+
*/
|
|
193
|
+
function isPolicyAttached(params) {
|
|
194
|
+
const { group, arn, profile, verbose } = params;
|
|
195
|
+
const out = require_commands_aws_utils_exec_aws.runAws({
|
|
196
|
+
profile,
|
|
197
|
+
args: [
|
|
198
|
+
"iam",
|
|
199
|
+
"list-attached-group-policies",
|
|
200
|
+
"--group-name",
|
|
201
|
+
group,
|
|
202
|
+
"--query",
|
|
203
|
+
`AttachedPolicies[?PolicyArn=='${arn}'].PolicyArn`,
|
|
204
|
+
"--output",
|
|
205
|
+
"text"
|
|
206
|
+
],
|
|
207
|
+
expectJson: false,
|
|
208
|
+
verbose
|
|
209
|
+
});
|
|
210
|
+
return Boolean(out);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Attach a policy to a group if not already attached.
|
|
214
|
+
* @param {{ group: string; arn: string; profile?: string; verbose?: boolean }} params
|
|
215
|
+
*/
|
|
216
|
+
function attach(params) {
|
|
217
|
+
const { group, arn, profile, verbose } = params;
|
|
218
|
+
const policyName = arn.split("/").pop() ?? arn;
|
|
219
|
+
if (isPolicyAttached({
|
|
220
|
+
group,
|
|
221
|
+
arn,
|
|
222
|
+
profile,
|
|
223
|
+
verbose
|
|
224
|
+
})) {
|
|
225
|
+
console.log(` [${group}] already attached: ${policyName}`);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
console.log(` [${group}] attach: ${policyName}`);
|
|
229
|
+
require_commands_aws_utils_exec_aws.runAws({
|
|
230
|
+
profile,
|
|
231
|
+
args: [
|
|
232
|
+
"iam",
|
|
233
|
+
"attach-group-policy",
|
|
234
|
+
"--group-name",
|
|
235
|
+
group,
|
|
236
|
+
"--policy-arn",
|
|
237
|
+
arn
|
|
238
|
+
],
|
|
239
|
+
expectJson: false,
|
|
240
|
+
verbose
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Detach a (legacy) policy from a group if it is currently attached.
|
|
245
|
+
* @param {{ group: string; arn: string; profile?: string; verbose?: boolean }} params
|
|
246
|
+
*/
|
|
247
|
+
function detach(params) {
|
|
248
|
+
const { group, arn, profile, verbose } = params;
|
|
249
|
+
const policyName = arn.split("/").pop() ?? arn;
|
|
250
|
+
if (!isPolicyAttached({
|
|
251
|
+
group,
|
|
252
|
+
arn,
|
|
253
|
+
profile,
|
|
254
|
+
verbose
|
|
255
|
+
})) return;
|
|
256
|
+
console.log(` [${group}] detach legacy: ${policyName}`);
|
|
257
|
+
require_commands_aws_utils_exec_aws.runAws({
|
|
258
|
+
profile,
|
|
259
|
+
args: [
|
|
260
|
+
"iam",
|
|
261
|
+
"detach-group-policy",
|
|
262
|
+
"--group-name",
|
|
263
|
+
group,
|
|
264
|
+
"--policy-arn",
|
|
265
|
+
arn
|
|
266
|
+
],
|
|
267
|
+
expectJson: false,
|
|
268
|
+
verbose
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Print the attached policies for each ACL group.
|
|
273
|
+
* @param {{ profile?: string; verbose?: boolean }} params
|
|
274
|
+
*/
|
|
275
|
+
function printFinalState(params) {
|
|
276
|
+
const { profile, verbose } = params;
|
|
277
|
+
for (const group of ACL_GROUPS) {
|
|
278
|
+
console.log("");
|
|
279
|
+
console.log(`=== ${group} ===`);
|
|
280
|
+
const table = require_commands_aws_utils_exec_aws.runAws({
|
|
281
|
+
profile,
|
|
282
|
+
args: [
|
|
283
|
+
"iam",
|
|
284
|
+
"list-attached-group-policies",
|
|
285
|
+
"--group-name",
|
|
286
|
+
group,
|
|
287
|
+
"--query",
|
|
288
|
+
"AttachedPolicies[].PolicyName",
|
|
289
|
+
"--output",
|
|
290
|
+
"table"
|
|
291
|
+
],
|
|
292
|
+
expectJson: false,
|
|
293
|
+
verbose
|
|
294
|
+
});
|
|
295
|
+
console.log(table);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
//#endregion
|
|
299
|
+
exports.ACL_GROUPS = ACL_GROUPS;
|
|
300
|
+
exports.CUSTOM_POLICIES = CUSTOM_POLICIES;
|
|
301
|
+
exports.attach = attach;
|
|
302
|
+
exports.detach = detach;
|
|
303
|
+
exports.ensureGroup = ensureGroup;
|
|
304
|
+
exports.printFinalState = printFinalState;
|
|
305
|
+
exports.publishPolicy = publishPolicy;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create an IAM group if it does not already exist.
|
|
3
|
+
* @param {{ name: string; profile?: string; verbose?: boolean }} params
|
|
4
|
+
*/
|
|
5
|
+
export function ensureGroup(params: {
|
|
6
|
+
name: string;
|
|
7
|
+
profile?: string;
|
|
8
|
+
verbose?: boolean;
|
|
9
|
+
}): void;
|
|
10
|
+
/**
|
|
11
|
+
* Create or update a customer-managed policy from a bundled JSON document.
|
|
12
|
+
* Handles the IAM five-version limit by pruning the oldest non-default version.
|
|
13
|
+
* @param {{ name: string; fileName: string; accountId: string; profile?: string; verbose?: boolean }} params
|
|
14
|
+
*/
|
|
15
|
+
export function publishPolicy(params: {
|
|
16
|
+
name: string;
|
|
17
|
+
fileName: string;
|
|
18
|
+
accountId: string;
|
|
19
|
+
profile?: string;
|
|
20
|
+
verbose?: boolean;
|
|
21
|
+
}): void;
|
|
22
|
+
/**
|
|
23
|
+
* Attach a policy to a group if not already attached.
|
|
24
|
+
* @param {{ group: string; arn: string; profile?: string; verbose?: boolean }} params
|
|
25
|
+
*/
|
|
26
|
+
export function attach(params: {
|
|
27
|
+
group: string;
|
|
28
|
+
arn: string;
|
|
29
|
+
profile?: string;
|
|
30
|
+
verbose?: boolean;
|
|
31
|
+
}): void;
|
|
32
|
+
/**
|
|
33
|
+
* Detach a (legacy) policy from a group if it is currently attached.
|
|
34
|
+
* @param {{ group: string; arn: string; profile?: string; verbose?: boolean }} params
|
|
35
|
+
*/
|
|
36
|
+
export function detach(params: {
|
|
37
|
+
group: string;
|
|
38
|
+
arn: string;
|
|
39
|
+
profile?: string;
|
|
40
|
+
verbose?: boolean;
|
|
41
|
+
}): void;
|
|
42
|
+
/**
|
|
43
|
+
* Print the attached policies for each ACL group.
|
|
44
|
+
* @param {{ profile?: string; verbose?: boolean }} params
|
|
45
|
+
*/
|
|
46
|
+
export function printFinalState(params: {
|
|
47
|
+
profile?: string;
|
|
48
|
+
verbose?: boolean;
|
|
49
|
+
}): void;
|
|
50
|
+
/**
|
|
51
|
+
* The five ACL groups managed by setup-acl.
|
|
52
|
+
*/
|
|
53
|
+
export const ACL_GROUPS: string[];
|
|
54
|
+
/**
|
|
55
|
+
* Custom managed policies published from bundled JSON documents.
|
|
56
|
+
* @type {Array<{ name: string; fileName: string }>}
|
|
57
|
+
*/
|
|
58
|
+
export const CUSTOM_POLICIES: Array<{
|
|
59
|
+
name: string;
|
|
60
|
+
fileName: string;
|
|
61
|
+
}>;
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
const require_commands_aws_utils_resolve_profile = require("../../utils/resolve-profile.cjs");
|
|
5
|
+
const require_commands_aws_iam_users_schema = require("./schema.cjs");
|
|
6
|
+
const require_commands_aws_iam_users_utils = require("./utils.cjs");
|
|
7
|
+
let chalk = require("chalk");
|
|
8
|
+
chalk = require_rolldown_runtime.__toESM(chalk, 1);
|
|
9
|
+
let zod = require("zod");
|
|
10
|
+
//#region src/commands/aws/iam/users/handler.js
|
|
11
|
+
/**
|
|
12
|
+
* `aws iam users` handler: interactively create IAM users and assign ACL groups.
|
|
13
|
+
* @param {unknown} options
|
|
14
|
+
*/
|
|
15
|
+
async function usersCommand(options) {
|
|
16
|
+
try {
|
|
17
|
+
const { accountName, profile: profileOption, verbose } = require_commands_aws_iam_users_schema.usersOptionsSchema.parse(options);
|
|
18
|
+
require_commands_aws_utils_exec_aws.requireCommands(["aws"]);
|
|
19
|
+
const profile = await require_commands_aws_utils_resolve_profile.resolveProfile({ profile: profileOption });
|
|
20
|
+
console.log(chalk.default.blue("\nAWS IAM user management"));
|
|
21
|
+
console.log("");
|
|
22
|
+
console.log("Caller:");
|
|
23
|
+
const identity = require_commands_aws_utils_exec_aws.getCallerIdentity({
|
|
24
|
+
profile,
|
|
25
|
+
verbose
|
|
26
|
+
});
|
|
27
|
+
console.log(` Account: ${identity.Account}`);
|
|
28
|
+
console.log(` Arn: ${identity.Arn}`);
|
|
29
|
+
console.log("");
|
|
30
|
+
await require_commands_aws_iam_users_utils.createUsersInteractive({
|
|
31
|
+
accountName,
|
|
32
|
+
profile,
|
|
33
|
+
identity,
|
|
34
|
+
verbose
|
|
35
|
+
});
|
|
36
|
+
console.log("Done.");
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (error instanceof zod.ZodError) {
|
|
39
|
+
console.error(chalk.default.red("\n❌ Invalid command options:"));
|
|
40
|
+
error.errors.forEach((err) => {
|
|
41
|
+
console.error(chalk.default.red(` ${err.path.join(".")}: ${err.message}`));
|
|
42
|
+
});
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
const verbose = options?.verbose || false;
|
|
46
|
+
console.error(chalk.default.red("\n❌ iam users failed:"));
|
|
47
|
+
if (error instanceof Error) {
|
|
48
|
+
console.error(chalk.default.red(` ${error.message}`));
|
|
49
|
+
if (verbose && error.stack) {
|
|
50
|
+
console.error(chalk.default.gray("\nStack trace:"));
|
|
51
|
+
console.error(chalk.default.gray(error.stack));
|
|
52
|
+
}
|
|
53
|
+
} else console.error(chalk.default.red(` ${String(error)}`));
|
|
54
|
+
console.error(chalk.default.yellow("\n💡 Requires the AWS CLI and a profile with IAM write access.\n"));
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
exports.usersCommand = usersCommand;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_commands_aws_iam_users_schema = require("./schema.cjs");
|
|
3
|
+
const require_commands_aws_iam_users_utils = require("./utils.cjs");
|
|
4
|
+
const require_commands_aws_iam_users_handler = require("./handler.cjs");
|
|
5
|
+
exports.buildUsername = require_commands_aws_iam_users_utils.buildUsername;
|
|
6
|
+
exports.createCliAccessKey = require_commands_aws_iam_users_utils.createCliAccessKey;
|
|
7
|
+
exports.createUsersInteractive = require_commands_aws_iam_users_utils.createUsersInteractive;
|
|
8
|
+
exports.ensureAclGroupsExist = require_commands_aws_iam_users_utils.ensureAclGroupsExist;
|
|
9
|
+
exports.ensureUser = require_commands_aws_iam_users_utils.ensureUser;
|
|
10
|
+
exports.ensureUserInGroup = require_commands_aws_iam_users_utils.ensureUserInGroup;
|
|
11
|
+
exports.inferAccountName = require_commands_aws_iam_users_utils.inferAccountName;
|
|
12
|
+
exports.isValidSlug = require_commands_aws_iam_users_utils.isValidSlug;
|
|
13
|
+
exports.normalizeIdentifier = require_commands_aws_iam_users_utils.normalizeIdentifier;
|
|
14
|
+
exports.normalizeSlug = require_commands_aws_iam_users_utils.normalizeSlug;
|
|
15
|
+
exports.parseMdUsername = require_commands_aws_iam_users_utils.parseMdUsername;
|
|
16
|
+
exports.roleToGroup = require_commands_aws_iam_users_utils.roleToGroup;
|
|
17
|
+
exports.usersCommand = require_commands_aws_iam_users_handler.usersCommand;
|
|
18
|
+
exports.usersOptionsSchema = require_commands_aws_iam_users_schema.usersOptionsSchema;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_commands_aws_schema = require("../../schema.cjs");
|
|
3
|
+
let zod = require("zod");
|
|
4
|
+
//#region src/commands/aws/iam/users/schema.js
|
|
5
|
+
/**
|
|
6
|
+
* Zod schema for `aws iam users` options.
|
|
7
|
+
*/
|
|
8
|
+
const usersOptionsSchema = zod.z.object({
|
|
9
|
+
accountName: zod.z.string().optional().describe("AWS account slug used in md-{identifier}-{account}-{role}"),
|
|
10
|
+
profile: require_commands_aws_schema.profileField,
|
|
11
|
+
verbose: require_commands_aws_schema.verboseField
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {z.infer<typeof usersOptionsSchema>} UsersOptions
|
|
15
|
+
*/
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.usersOptionsSchema = usersOptionsSchema;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema for `aws iam users` options.
|
|
3
|
+
*/
|
|
4
|
+
export const usersOptionsSchema: z.ZodObject<{
|
|
5
|
+
accountName: z.ZodOptional<z.ZodString>;
|
|
6
|
+
profile: z.ZodOptional<z.ZodString>;
|
|
7
|
+
verbose: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
verbose: boolean;
|
|
10
|
+
profile?: string | undefined;
|
|
11
|
+
accountName?: string | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
profile?: string | undefined;
|
|
14
|
+
verbose?: boolean | undefined;
|
|
15
|
+
accountName?: string | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
export type UsersOptions = z.infer<typeof usersOptionsSchema>;
|
|
18
|
+
import { z } from "zod";
|