cdk-real-drift 0.12.63 → 0.12.64
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/dist/cli.js +117 -10
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7230,12 +7230,52 @@ const CHILD_ENUMERATORS = {
|
|
|
7230
7230
|
"AWS::RDS::DBCluster": enumerateRdsClusterChildren,
|
|
7231
7231
|
"AWS::Route53::HostedZone": enumerateRoute53HostedZoneChildren
|
|
7232
7232
|
};
|
|
7233
|
+
function normalizeApiPath(p) {
|
|
7234
|
+
let out = p.startsWith("/") ? p : `/${p}`;
|
|
7235
|
+
if (out.length > 1 && out.endsWith("/")) out = out.slice(0, -1);
|
|
7236
|
+
return out;
|
|
7237
|
+
}
|
|
7238
|
+
const OPENAPI_HTTP_VERBS = new Set([
|
|
7239
|
+
"get",
|
|
7240
|
+
"post",
|
|
7241
|
+
"put",
|
|
7242
|
+
"delete",
|
|
7243
|
+
"patch",
|
|
7244
|
+
"head",
|
|
7245
|
+
"options"
|
|
7246
|
+
]);
|
|
7247
|
+
function deriveSpecRestApiPaths(body) {
|
|
7248
|
+
if (typeof body !== "object" || body === null || Array.isArray(body)) return null;
|
|
7249
|
+
const rawPaths = body.paths;
|
|
7250
|
+
if (typeof rawPaths !== "object" || rawPaths === null || Array.isArray(rawPaths)) return null;
|
|
7251
|
+
const paths = /* @__PURE__ */ new Set();
|
|
7252
|
+
const methods = /* @__PURE__ */ new Set();
|
|
7253
|
+
for (const [rawKey, ops] of Object.entries(rawPaths)) {
|
|
7254
|
+
const norm = normalizeApiPath(rawKey);
|
|
7255
|
+
const segs = norm.split("/").filter((s) => s.length > 0);
|
|
7256
|
+
paths.add("/");
|
|
7257
|
+
let acc = "";
|
|
7258
|
+
for (const s of segs) {
|
|
7259
|
+
acc = `${acc}/${s}`;
|
|
7260
|
+
paths.add(acc);
|
|
7261
|
+
}
|
|
7262
|
+
if (typeof ops === "object" && ops !== null && !Array.isArray(ops)) for (const opKey of Object.keys(ops)) {
|
|
7263
|
+
const lower = opKey.toLowerCase();
|
|
7264
|
+
if (OPENAPI_HTTP_VERBS.has(lower)) methods.add(`${norm}|${lower.toUpperCase()}`);
|
|
7265
|
+
else if (lower === "x-amazon-apigateway-any-method") methods.add(`${norm}|ANY`);
|
|
7266
|
+
}
|
|
7267
|
+
}
|
|
7268
|
+
return {
|
|
7269
|
+
paths,
|
|
7270
|
+
methods
|
|
7271
|
+
};
|
|
7272
|
+
}
|
|
7233
7273
|
function isBodyDefinedRestApi(declared) {
|
|
7234
7274
|
return declared.Body != null || declared.BodyS3Location != null;
|
|
7235
7275
|
}
|
|
7236
7276
|
function diffApiGatewayChildren(input) {
|
|
7237
|
-
const { apiId, rootResourceId, declaredResourceIds, declaredMethodKeys, liveResources, liveMethodsByResource, bodyDefined } = input;
|
|
7238
|
-
if (bodyDefined) return [];
|
|
7277
|
+
const { apiId, rootResourceId, declaredResourceIds, declaredMethodKeys, liveResources, liveMethodsByResource, bodyDefined, specChildren } = input;
|
|
7278
|
+
if (bodyDefined && !specChildren) return [];
|
|
7239
7279
|
const liveRootId = liveResources.find((r) => r.path === "/")?.id;
|
|
7240
7280
|
const declaredResources = new Set(declaredResourceIds);
|
|
7241
7281
|
if (rootResourceId) declaredResources.add(rootResourceId);
|
|
@@ -7248,6 +7288,10 @@ function diffApiGatewayChildren(input) {
|
|
|
7248
7288
|
const addedResourceIds = /* @__PURE__ */ new Set();
|
|
7249
7289
|
for (const r of liveResources) {
|
|
7250
7290
|
if (declaredResources.has(r.id)) continue;
|
|
7291
|
+
if (specChildren) {
|
|
7292
|
+
const normPath = r.path != null ? normalizeApiPath(r.path) : void 0;
|
|
7293
|
+
if (normPath != null && specChildren.paths.has(normPath)) continue;
|
|
7294
|
+
}
|
|
7251
7295
|
addedResourceIds.add(r.id);
|
|
7252
7296
|
added.push({
|
|
7253
7297
|
resourceType: "AWS::ApiGateway::Resource",
|
|
@@ -7260,7 +7304,13 @@ function diffApiGatewayChildren(input) {
|
|
|
7260
7304
|
if (addedResourceIds.has(resourceId)) continue;
|
|
7261
7305
|
if (!rootResourceId && resourceId === liveRootId) continue;
|
|
7262
7306
|
for (const m of methods) {
|
|
7263
|
-
if (
|
|
7307
|
+
if (specChildren) {
|
|
7308
|
+
if (m.httpMethod === "OPTIONS") continue;
|
|
7309
|
+
const resPath = pathOf.get(resourceId);
|
|
7310
|
+
if (resPath === void 0) continue;
|
|
7311
|
+
const normResPath = normalizeApiPath(resPath);
|
|
7312
|
+
if (specChildren.methods.has(`${normResPath}|${m.httpMethod}`)) continue;
|
|
7313
|
+
} else if (declaredMethods.has(`${resourceId}|${m.httpMethod}`)) continue;
|
|
7264
7314
|
added.push({
|
|
7265
7315
|
resourceType: "AWS::ApiGateway::Method",
|
|
7266
7316
|
identifier: `${apiId}|${resourceId}|${m.httpMethod}`,
|
|
@@ -7322,11 +7372,12 @@ async function enumerateRestApiChildren(ctx) {
|
|
|
7322
7372
|
const name = typeof r.declared.StageName === "string" ? r.declared.StageName : r.physicalId;
|
|
7323
7373
|
if (name) declaredStageNames.push(name);
|
|
7324
7374
|
}
|
|
7375
|
+
const specChildren = bodyDefined ? deriveSpecRestApiPaths(parent.declared.Body) : null;
|
|
7325
7376
|
const client = new APIGatewayClient({
|
|
7326
7377
|
region,
|
|
7327
7378
|
...READ_RETRY
|
|
7328
7379
|
});
|
|
7329
|
-
const items = bodyDefined ? [] : await getAllResources(client, apiId);
|
|
7380
|
+
const items = bodyDefined && !specChildren ? [] : await getAllResources(client, apiId);
|
|
7330
7381
|
const liveResources = items.filter((i) => typeof i.id === "string").map((i) => ({
|
|
7331
7382
|
id: i.id,
|
|
7332
7383
|
path: i.path,
|
|
@@ -7354,7 +7405,8 @@ async function enumerateRestApiChildren(ctx) {
|
|
|
7354
7405
|
declaredMethodKeys,
|
|
7355
7406
|
liveResources,
|
|
7356
7407
|
liveMethodsByResource,
|
|
7357
|
-
bodyDefined
|
|
7408
|
+
bodyDefined,
|
|
7409
|
+
specChildren
|
|
7358
7410
|
});
|
|
7359
7411
|
const authorizerAdded = diffApiGatewayAuthorizers({
|
|
7360
7412
|
apiId,
|
|
@@ -7572,9 +7624,50 @@ function isBodyDefinedHttpApi(declared) {
|
|
|
7572
7624
|
function isQuickCreateHttpApi(declared) {
|
|
7573
7625
|
return declared.Target != null;
|
|
7574
7626
|
}
|
|
7627
|
+
function deriveSpecHttpApiRouteKeys(body) {
|
|
7628
|
+
if (typeof body !== "object" || body === null || Array.isArray(body)) return null;
|
|
7629
|
+
const rawPaths = body.paths;
|
|
7630
|
+
if (typeof rawPaths !== "object" || rawPaths === null || Array.isArray(rawPaths)) return null;
|
|
7631
|
+
const keys = /* @__PURE__ */ new Set();
|
|
7632
|
+
for (const [rawKey, ops] of Object.entries(rawPaths)) {
|
|
7633
|
+
if (rawKey === "$default") {
|
|
7634
|
+
keys.add("$default");
|
|
7635
|
+
continue;
|
|
7636
|
+
}
|
|
7637
|
+
const norm = normalizeApiPath(rawKey);
|
|
7638
|
+
if (typeof ops === "object" && ops !== null && !Array.isArray(ops)) for (const opKey of Object.keys(ops)) {
|
|
7639
|
+
const lower = opKey.toLowerCase();
|
|
7640
|
+
if (OPENAPI_HTTP_VERBS.has(lower)) keys.add(`${lower.toUpperCase()} ${norm}`);
|
|
7641
|
+
else if (lower === "x-amazon-apigateway-any-method") keys.add(`ANY ${norm}`);
|
|
7642
|
+
}
|
|
7643
|
+
}
|
|
7644
|
+
return keys;
|
|
7645
|
+
}
|
|
7575
7646
|
function diffApiGatewayV2Children(input) {
|
|
7576
|
-
const { apiId, declaredRouteIds, declaredIntegrationIds, liveRoutes, liveIntegrations, specMaterialized } = input;
|
|
7577
|
-
if (specMaterialized)
|
|
7647
|
+
const { apiId, declaredRouteIds, declaredIntegrationIds, liveRoutes, liveIntegrations, specMaterialized, specRouteKeys, quickCreate } = input;
|
|
7648
|
+
if (specMaterialized) {
|
|
7649
|
+
if (!quickCreate && !specRouteKeys) return [];
|
|
7650
|
+
const added = [];
|
|
7651
|
+
for (const r of liveRoutes) {
|
|
7652
|
+
if (quickCreate) {
|
|
7653
|
+
if (r.key === "$default") continue;
|
|
7654
|
+
} else {
|
|
7655
|
+
const key = r.key != null ? normalizeV2RouteKey(r.key) : void 0;
|
|
7656
|
+
if (key != null && specRouteKeys?.has(key)) continue;
|
|
7657
|
+
if (key == null) continue;
|
|
7658
|
+
}
|
|
7659
|
+
added.push({
|
|
7660
|
+
resourceType: "AWS::ApiGatewayV2::Route",
|
|
7661
|
+
identifier: `${apiId}|${r.id}`,
|
|
7662
|
+
label: r.key ?? r.id,
|
|
7663
|
+
live: {
|
|
7664
|
+
RouteId: r.id,
|
|
7665
|
+
RouteKey: r.key
|
|
7666
|
+
}
|
|
7667
|
+
});
|
|
7668
|
+
}
|
|
7669
|
+
return added;
|
|
7670
|
+
}
|
|
7578
7671
|
const declaredRoutes = new Set(declaredRouteIds);
|
|
7579
7672
|
const declaredIntegrations = new Set(declaredIntegrationIds);
|
|
7580
7673
|
const added = [];
|
|
@@ -7601,6 +7694,12 @@ function diffApiGatewayV2Children(input) {
|
|
|
7601
7694
|
}
|
|
7602
7695
|
return added;
|
|
7603
7696
|
}
|
|
7697
|
+
function normalizeV2RouteKey(key) {
|
|
7698
|
+
if (key === "$default") return "$default";
|
|
7699
|
+
const sp = key.indexOf(" ");
|
|
7700
|
+
if (sp < 0) return key;
|
|
7701
|
+
return `${key.slice(0, sp).toUpperCase()} ${normalizeApiPath(key.slice(sp + 1).trim())}`;
|
|
7702
|
+
}
|
|
7604
7703
|
function integrationLabel(i) {
|
|
7605
7704
|
if (!i.IntegrationType) return void 0;
|
|
7606
7705
|
return i.IntegrationUri ? `${i.IntegrationType} ${i.IntegrationUri}` : i.IntegrationType;
|
|
@@ -7702,6 +7801,8 @@ async function enumerateHttpApiChildren(ctx) {
|
|
|
7702
7801
|
const bodyDefined = isBodyDefinedHttpApi(parent.declared);
|
|
7703
7802
|
const quickCreate = isQuickCreateHttpApi(parent.declared);
|
|
7704
7803
|
const specMaterialized = bodyDefined || quickCreate;
|
|
7804
|
+
const specRouteKeys = bodyDefined ? deriveSpecHttpApiRouteKeys(parent.declared.Body) : null;
|
|
7805
|
+
const skipRoutesSweep = bodyDefined && !quickCreate && !specRouteKeys;
|
|
7705
7806
|
const declaredRouteIds = [];
|
|
7706
7807
|
const declaredIntegrationIds = [];
|
|
7707
7808
|
const declaredAuthorizerIds = [];
|
|
@@ -7721,7 +7822,7 @@ async function enumerateHttpApiChildren(ctx) {
|
|
|
7721
7822
|
...READ_RETRY
|
|
7722
7823
|
});
|
|
7723
7824
|
const [routes, integrations, authorizers, stages] = await Promise.all([
|
|
7724
|
-
pageRoutes(client, apiId),
|
|
7825
|
+
skipRoutesSweep ? Promise.resolve([]) : pageRoutes(client, apiId),
|
|
7725
7826
|
pageIntegrations(client, apiId),
|
|
7726
7827
|
pageV2Authorizers(client, apiId),
|
|
7727
7828
|
pageV2Stages(client, apiId)
|
|
@@ -7745,7 +7846,9 @@ async function enumerateHttpApiChildren(ctx) {
|
|
|
7745
7846
|
declaredIntegrationIds,
|
|
7746
7847
|
liveRoutes,
|
|
7747
7848
|
liveIntegrations,
|
|
7748
|
-
specMaterialized
|
|
7849
|
+
specMaterialized,
|
|
7850
|
+
specRouteKeys,
|
|
7851
|
+
quickCreate
|
|
7749
7852
|
});
|
|
7750
7853
|
const authorizerAdded = diffApiGatewayV2Authorizers({
|
|
7751
7854
|
apiId,
|
|
@@ -8195,7 +8298,11 @@ async function openSearchDomainTargetsPool(region, userPoolId) {
|
|
|
8195
8298
|
});
|
|
8196
8299
|
const domainNames = ((await os.send(new ListDomainNamesCommand({}))).DomainNames ?? []).map((d) => d.DomainName).filter((n) => typeof n === "string");
|
|
8197
8300
|
if (domainNames.length === 0) return false;
|
|
8198
|
-
|
|
8301
|
+
for (let i = 0; i < domainNames.length; i += 5) {
|
|
8302
|
+
const batch = domainNames.slice(i, i + 5);
|
|
8303
|
+
if (((await os.send(new DescribeDomainsCommand({ DomainNames: batch }))).DomainStatusList ?? []).some((d) => d.CognitoOptions?.Enabled === true && d.CognitoOptions.UserPoolId === userPoolId)) return true;
|
|
8304
|
+
}
|
|
8305
|
+
return false;
|
|
8199
8306
|
} catch {
|
|
8200
8307
|
return true;
|
|
8201
8308
|
}
|