@go-to-k/cdkd 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/cli.js +1004 -9
- package/dist/cli.js.map +4 -4
- package/dist/go-to-k-cdkd-0.15.0.tgz +0 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/dist/go-to-k-cdkd-0.14.0.tgz +0 -0
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -7063,6 +7063,8 @@ import {
|
|
|
7063
7063
|
UntagRoleCommand,
|
|
7064
7064
|
PutRolePermissionsBoundaryCommand,
|
|
7065
7065
|
DeleteRolePermissionsBoundaryCommand,
|
|
7066
|
+
ListRolesCommand,
|
|
7067
|
+
ListRoleTagsCommand,
|
|
7066
7068
|
NoSuchEntityException
|
|
7067
7069
|
} from "@aws-sdk/client-iam";
|
|
7068
7070
|
init_aws_clients();
|
|
@@ -7171,6 +7173,32 @@ function applyDefaultNameForFallback(logicalId, resourceType, properties) {
|
|
|
7171
7173
|
};
|
|
7172
7174
|
}
|
|
7173
7175
|
|
|
7176
|
+
// src/provisioning/import-helpers.ts
|
|
7177
|
+
function readNameProperty(input, propertyName) {
|
|
7178
|
+
const value = input.properties?.[propertyName];
|
|
7179
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
7180
|
+
}
|
|
7181
|
+
function resolveExplicitPhysicalId(input, nameProperty) {
|
|
7182
|
+
if (input.knownPhysicalId)
|
|
7183
|
+
return input.knownPhysicalId;
|
|
7184
|
+
if (nameProperty) {
|
|
7185
|
+
const name = readNameProperty(input, nameProperty);
|
|
7186
|
+
if (name)
|
|
7187
|
+
return name;
|
|
7188
|
+
}
|
|
7189
|
+
return void 0;
|
|
7190
|
+
}
|
|
7191
|
+
var CDK_PATH_TAG = "aws:cdk:path";
|
|
7192
|
+
function matchesCdkPath(tags, cdkPath) {
|
|
7193
|
+
if (!tags || !cdkPath)
|
|
7194
|
+
return false;
|
|
7195
|
+
for (const t of tags) {
|
|
7196
|
+
if (t.Key === CDK_PATH_TAG && t.Value === cdkPath)
|
|
7197
|
+
return true;
|
|
7198
|
+
}
|
|
7199
|
+
return false;
|
|
7200
|
+
}
|
|
7201
|
+
|
|
7174
7202
|
// src/provisioning/providers/iam-role-provider.ts
|
|
7175
7203
|
var IAMRoleProvider = class {
|
|
7176
7204
|
iamClient;
|
|
@@ -7677,6 +7705,58 @@ var IAMRoleProvider = class {
|
|
|
7677
7705
|
this.logger.debug(`Added/updated ${tagsToAdd.length} tags on role ${roleName}`);
|
|
7678
7706
|
}
|
|
7679
7707
|
}
|
|
7708
|
+
/**
|
|
7709
|
+
* Adopt an existing IAM role into cdkd state.
|
|
7710
|
+
*
|
|
7711
|
+
* Lookup order:
|
|
7712
|
+
* 1. `--resource` override or `Properties.RoleName` → use directly,
|
|
7713
|
+
* verify via `GetRole`.
|
|
7714
|
+
* 2. `ListRoles` + `ListRoleTags`, match `aws:cdk:path` tag.
|
|
7715
|
+
*
|
|
7716
|
+
* `ListRoles` is paginated and IAM is global (no region scoping), so this
|
|
7717
|
+
* walks every role in the account once. Acceptable for the cardinalities
|
|
7718
|
+
* we expect (typically <100 roles per account); larger accounts may want
|
|
7719
|
+
* to provide `--resource` overrides instead.
|
|
7720
|
+
*/
|
|
7721
|
+
async import(input) {
|
|
7722
|
+
const explicit = resolveExplicitPhysicalId(input, "RoleName");
|
|
7723
|
+
if (explicit) {
|
|
7724
|
+
try {
|
|
7725
|
+
await this.iamClient.send(new GetRoleCommand({ RoleName: explicit }));
|
|
7726
|
+
return { physicalId: explicit, attributes: {} };
|
|
7727
|
+
} catch (err) {
|
|
7728
|
+
if (err instanceof NoSuchEntityException)
|
|
7729
|
+
return null;
|
|
7730
|
+
throw err;
|
|
7731
|
+
}
|
|
7732
|
+
}
|
|
7733
|
+
if (!input.cdkPath)
|
|
7734
|
+
return null;
|
|
7735
|
+
let marker;
|
|
7736
|
+
do {
|
|
7737
|
+
const list = await this.iamClient.send(
|
|
7738
|
+
new ListRolesCommand({ ...marker && { Marker: marker } })
|
|
7739
|
+
);
|
|
7740
|
+
for (const role of list.Roles ?? []) {
|
|
7741
|
+
if (!role.RoleName)
|
|
7742
|
+
continue;
|
|
7743
|
+
try {
|
|
7744
|
+
const tags = await this.iamClient.send(
|
|
7745
|
+
new ListRoleTagsCommand({ RoleName: role.RoleName })
|
|
7746
|
+
);
|
|
7747
|
+
if (matchesCdkPath(tags.Tags, input.cdkPath)) {
|
|
7748
|
+
return { physicalId: role.RoleName, attributes: {} };
|
|
7749
|
+
}
|
|
7750
|
+
} catch (err) {
|
|
7751
|
+
if (err instanceof NoSuchEntityException)
|
|
7752
|
+
continue;
|
|
7753
|
+
throw err;
|
|
7754
|
+
}
|
|
7755
|
+
}
|
|
7756
|
+
marker = list.IsTruncated ? list.Marker : void 0;
|
|
7757
|
+
} while (marker);
|
|
7758
|
+
return null;
|
|
7759
|
+
}
|
|
7680
7760
|
};
|
|
7681
7761
|
|
|
7682
7762
|
// src/deployment/dag-executor.ts
|