cdk-real-drift 0.12.77 → 0.12.79
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 +96 -5
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -10,9 +10,10 @@ import { CloudControlClient, DeleteResourceCommand, GetResourceCommand, GetResou
|
|
|
10
10
|
import { homedir } from "node:os";
|
|
11
11
|
import { BaseCredentials, CdkAppMultiContext, NonInteractiveIoHost, StackSelectionStrategy, Toolkit } from "@aws-cdk/toolkit-lib";
|
|
12
12
|
import { CloudFormationClient, DescribeStackResourcesCommand, DescribeStacksCommand, DescribeTypeCommand, GetTemplateCommand, ListExportsCommand, ListStackResourcesCommand } from "@aws-sdk/client-cloudformation";
|
|
13
|
-
import { DescribeAddressesCommand, DescribeClientVpnAuthorizationRulesCommand, DescribeClientVpnEndpointsCommand, DescribeClientVpnTargetNetworksCommand, DescribeInternetGatewaysCommand, DescribeLaunchTemplateVersionsCommand, DescribeNetworkAclsCommand, DescribeRouteTablesCommand, DescribeSecurityGroupsCommand, DescribeSubnetsCommand, DescribeVpcEndpointsCommand, DescribeVpcsCommand, EC2Client, ModifyClientVpnEndpointCommand } from "@aws-sdk/client-ec2";
|
|
13
|
+
import { DescribeAddressesCommand, DescribeClientVpnAuthorizationRulesCommand, DescribeClientVpnEndpointsCommand, DescribeClientVpnTargetNetworksCommand, DescribeInternetGatewaysCommand, DescribeLaunchTemplateVersionsCommand, DescribeNetworkAclsCommand, DescribeRouteTablesCommand, DescribeSecurityGroupsCommand, DescribeSubnetsCommand, DescribeVpcEndpointsCommand, DescribeVpcsCommand, EC2Client, GetEbsEncryptionByDefaultCommand, ModifyClientVpnEndpointCommand } from "@aws-sdk/client-ec2";
|
|
14
|
+
import { DescribeServicesCommand, ECSClient, ListAccountSettingsCommand, ListServicesCommand, UpdateServiceCommand } from "@aws-sdk/client-ecs";
|
|
14
15
|
import { DescribeDBClustersCommand, DescribeDBInstancesCommand, DescribeOptionGroupOptionsCommand, RDSClient } from "@aws-sdk/client-rds";
|
|
15
|
-
import { DescribeParametersCommand, GetParametersCommand, SSMClient } from "@aws-sdk/client-ssm";
|
|
16
|
+
import { DescribeParametersCommand, GetParametersCommand, GetServiceSettingCommand, SSMClient } from "@aws-sdk/client-ssm";
|
|
16
17
|
import jsonata from "jsonata";
|
|
17
18
|
import { KMSClient, ListAliasesCommand } from "@aws-sdk/client-kms";
|
|
18
19
|
import { APIGatewayClient, GetAuthorizersCommand, GetGatewayResponsesCommand, GetModelsCommand, GetRequestValidatorsCommand, GetResourcesCommand, GetStagesCommand, UpdateIntegrationCommand, UpdateIntegrationResponseCommand, UpdateMethodResponseCommand, UpdateRestApiCommand } from "@aws-sdk/client-api-gateway";
|
|
@@ -21,7 +22,6 @@ import { AppSyncClient, DeleteApiKeyCommand, ListApiKeysCommand, ListDataSources
|
|
|
21
22
|
import { ApiGatewayV2Client, DeleteAccessLogSettingsCommand, DeleteRouteSettingsCommand, GetAuthorizersCommand as GetAuthorizersCommand$1, GetIntegrationsCommand, GetRoutesCommand, GetStagesCommand as GetStagesCommand$1, UpdateStageCommand } from "@aws-sdk/client-apigatewayv2";
|
|
22
23
|
import { CloudWatchLogsClient, DescribeMetricFiltersCommand, DescribeSubscriptionFiltersCommand, PutBearerTokenAuthenticationCommand, PutMetricFilterCommand } from "@aws-sdk/client-cloudwatch-logs";
|
|
23
24
|
import { CognitoIdentityProviderClient, ListGroupsCommand, ListIdentityProvidersCommand, ListResourceServersCommand, ListUserPoolClientsCommand } from "@aws-sdk/client-cognito-identity-provider";
|
|
24
|
-
import { DescribeServicesCommand, ECSClient, ListServicesCommand, UpdateServiceCommand } from "@aws-sdk/client-ecs";
|
|
25
25
|
import { DescribeMountTargetsCommand, EFSClient } from "@aws-sdk/client-efs";
|
|
26
26
|
import { DescribeListenersCommand, DescribeRulesCommand, ElasticLoadBalancingV2Client, GetTrustStoreCaCertificatesBundleCommand, ModifyLoadBalancerAttributesCommand, ModifyTargetGroupAttributesCommand } from "@aws-sdk/client-elastic-load-balancing-v2";
|
|
27
27
|
import { DescribeEventBusCommand, EventBridgeClient, ListRulesCommand, PutPermissionCommand } from "@aws-sdk/client-eventbridge";
|
|
@@ -5576,6 +5576,15 @@ function shouldFoldDefaultSgList(resourceType, key, liveValue, defaultSgIds) {
|
|
|
5576
5576
|
if (!Array.isArray(liveValue)) return true;
|
|
5577
5577
|
return liveValue.length === 1 && typeof liveValue[0] === "string" && defaultSgIds.has(liveValue[0]);
|
|
5578
5578
|
}
|
|
5579
|
+
function accountDerivedDefault(resourceType, key, ad) {
|
|
5580
|
+
if (!ad) return void 0;
|
|
5581
|
+
if (resourceType === "AWS::ECS::Cluster" && key === "ClusterSettings" && ad.ecsContainerInsights !== void 0) return { value: [{
|
|
5582
|
+
Name: "containerInsights",
|
|
5583
|
+
Value: ad.ecsContainerInsights
|
|
5584
|
+
}] };
|
|
5585
|
+
if (resourceType === "AWS::SSM::Parameter" && key === "Tier" && ad.ssmParameterTier !== void 0) return { value: ad.ssmParameterTier };
|
|
5586
|
+
if (resourceType === "AWS::EC2::Volume" && key === "Encrypted" && ad.ebsEncryptionByDefault !== void 0) return { value: ad.ebsEncryptionByDefault };
|
|
5587
|
+
}
|
|
5579
5588
|
const stripCognitoAttrPrefix = (id) => id.replace(/^(custom|dev):/, "");
|
|
5580
5589
|
const IDENTITY_KEYED_SUBSET_ARRAYS = {
|
|
5581
5590
|
"AWS::Cognito::UserPool": { Schema: {
|
|
@@ -7061,6 +7070,17 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
7061
7070
|
}
|
|
7062
7071
|
continue;
|
|
7063
7072
|
}
|
|
7073
|
+
const acctDefault = accountDerivedDefault(resourceType, k, opts.accountDefaults);
|
|
7074
|
+
if (acctDefault !== void 0) {
|
|
7075
|
+
findings.push({
|
|
7076
|
+
tier: matchesKnownDefault(v, acctDefault.value) ? "atDefault" : "undeclared",
|
|
7077
|
+
logicalId,
|
|
7078
|
+
resourceType,
|
|
7079
|
+
path: k,
|
|
7080
|
+
actual: v
|
|
7081
|
+
});
|
|
7082
|
+
continue;
|
|
7083
|
+
}
|
|
7064
7084
|
if (k in schema.defaults && matchesKnownDefault(v, schema.defaults[k]) || k in schema.defaultPaths && matchesKnownDefault(v, schema.defaultPaths[k]) || k in knownDef && matchesKnownDefault(v, knownDef[k]) || KNOWN_DEFAULT_ONE_OF[resourceType]?.[k]?.some((d) => matchesKnownDefault(v, d)) || VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS[resourceType]?.has(k) && !isTrivialEmpty(v) && !(k in knownDef) || clbDefaultSslPoliciesAtDefault(resourceType, k, v)) {
|
|
7065
7085
|
findings.push({
|
|
7066
7086
|
tier: "atDefault",
|
|
@@ -7498,6 +7518,7 @@ async function enumerateRestApiChildren(ctx) {
|
|
|
7498
7518
|
const declaredValidatorIds = [];
|
|
7499
7519
|
const declaredResponseTypes = [];
|
|
7500
7520
|
let gatewayResponseTypeUnresolved = false;
|
|
7521
|
+
let deploymentStageUnresolved = false;
|
|
7501
7522
|
const declaredStageNames = [];
|
|
7502
7523
|
for (const r of desired.resources) if (r.resourceType === "AWS::ApiGateway::Authorizer" && parentRefMatches(r.declared.RestApiId, apiId) && r.physicalId) declaredAuthorizerIds.push(r.physicalId);
|
|
7503
7524
|
else if (r.resourceType === "AWS::ApiGateway::Model" && parentRefMatches(r.declared.RestApiId, apiId)) {
|
|
@@ -7510,6 +7531,9 @@ async function enumerateRestApiChildren(ctx) {
|
|
|
7510
7531
|
} else if (r.resourceType === "AWS::ApiGateway::Stage" && parentRefMatches(r.declared.RestApiId, apiId)) {
|
|
7511
7532
|
const name = typeof r.declared.StageName === "string" ? r.declared.StageName : r.physicalId;
|
|
7512
7533
|
if (name) declaredStageNames.push(name);
|
|
7534
|
+
} else if (r.resourceType === "AWS::ApiGateway::Deployment" && parentRefMatches(r.declared.RestApiId, apiId)) {
|
|
7535
|
+
if (r.declared.StageName === UNRESOLVED || hasUnresolved(r.declared.StageName)) deploymentStageUnresolved = true;
|
|
7536
|
+
else if (typeof r.declared.StageName === "string") declaredStageNames.push(r.declared.StageName);
|
|
7513
7537
|
}
|
|
7514
7538
|
const specChildren = bodyDefined ? deriveSpecRestApiPaths(parent.declared.Body) : null;
|
|
7515
7539
|
const client = new APIGatewayClient({
|
|
@@ -7590,7 +7614,8 @@ async function enumerateRestApiChildren(ctx) {
|
|
|
7590
7614
|
liveStages: (await getAllStages(client, apiId)).filter((s) => typeof s.stageName === "string").map((s) => ({
|
|
7591
7615
|
name: s.stageName,
|
|
7592
7616
|
label: s.stageName
|
|
7593
|
-
}))
|
|
7617
|
+
})),
|
|
7618
|
+
unresolvedDeploymentStage: deploymentStageUnresolved
|
|
7594
7619
|
});
|
|
7595
7620
|
return [
|
|
7596
7621
|
...resourceAndMethodAdded,
|
|
@@ -7603,6 +7628,7 @@ async function enumerateRestApiChildren(ctx) {
|
|
|
7603
7628
|
}
|
|
7604
7629
|
function diffApiGatewayStages(input) {
|
|
7605
7630
|
const { apiId, declaredStageNames, liveStages } = input;
|
|
7631
|
+
if (input.unresolvedDeploymentStage) return [];
|
|
7606
7632
|
const declared = new Set(declaredStageNames);
|
|
7607
7633
|
const added = [];
|
|
7608
7634
|
for (const s of liveStages) {
|
|
@@ -7903,6 +7929,7 @@ async function pageV2Authorizers(client, apiId) {
|
|
|
7903
7929
|
}
|
|
7904
7930
|
function diffApiGatewayV2Stages(input) {
|
|
7905
7931
|
const { apiId, declaredStageNames, liveStages, quickCreate } = input;
|
|
7932
|
+
if (input.unresolvedDeploymentStage) return [];
|
|
7906
7933
|
const declared = new Set(declaredStageNames);
|
|
7907
7934
|
const added = [];
|
|
7908
7935
|
for (const s of liveStages) {
|
|
@@ -7946,6 +7973,7 @@ async function enumerateHttpApiChildren(ctx) {
|
|
|
7946
7973
|
const declaredIntegrationIds = [];
|
|
7947
7974
|
const declaredAuthorizerIds = [];
|
|
7948
7975
|
const declaredStageNames = [];
|
|
7976
|
+
let deploymentStageUnresolved = false;
|
|
7949
7977
|
for (const r of desired.resources) {
|
|
7950
7978
|
if (!parentRefMatches(r.declared.ApiId, apiId)) continue;
|
|
7951
7979
|
if (r.resourceType === "AWS::ApiGatewayV2::Route" && r.physicalId) declaredRouteIds.push(r.physicalId);
|
|
@@ -7954,6 +7982,9 @@ async function enumerateHttpApiChildren(ctx) {
|
|
|
7954
7982
|
else if (r.resourceType === "AWS::ApiGatewayV2::Stage") {
|
|
7955
7983
|
const name = r.physicalId ?? r.declared.StageName;
|
|
7956
7984
|
if (name) declaredStageNames.push(name);
|
|
7985
|
+
} else if (r.resourceType === "AWS::ApiGatewayV2::Deployment") {
|
|
7986
|
+
if (r.declared.StageName === UNRESOLVED || hasUnresolved(r.declared.StageName)) deploymentStageUnresolved = true;
|
|
7987
|
+
else if (typeof r.declared.StageName === "string") declaredStageNames.push(r.declared.StageName);
|
|
7957
7988
|
}
|
|
7958
7989
|
}
|
|
7959
7990
|
const client = new ApiGatewayV2Client({
|
|
@@ -7999,7 +8030,8 @@ async function enumerateHttpApiChildren(ctx) {
|
|
|
7999
8030
|
apiId,
|
|
8000
8031
|
declaredStageNames,
|
|
8001
8032
|
liveStages,
|
|
8002
|
-
quickCreate
|
|
8033
|
+
quickCreate,
|
|
8034
|
+
unresolvedDeploymentStage: deploymentStageUnresolved
|
|
8003
8035
|
});
|
|
8004
8036
|
return added.concat(authorizerAdded, stageAdded);
|
|
8005
8037
|
}
|
|
@@ -12571,6 +12603,51 @@ async function fetchDefaultVpcSubnetIds(region) {
|
|
|
12571
12603
|
defaultSubnetIdsCache.set(region, ids);
|
|
12572
12604
|
return ids;
|
|
12573
12605
|
}
|
|
12606
|
+
const ecsContainerInsightsCache = /* @__PURE__ */ new Map();
|
|
12607
|
+
async function fetchEcsContainerInsightsDefault(region) {
|
|
12608
|
+
if (ecsContainerInsightsCache.has(region)) return ecsContainerInsightsCache.get(region);
|
|
12609
|
+
try {
|
|
12610
|
+
const value = (await new ECSClient({
|
|
12611
|
+
region,
|
|
12612
|
+
...READ_RETRY
|
|
12613
|
+
}).send(new ListAccountSettingsCommand({
|
|
12614
|
+
name: "containerInsights",
|
|
12615
|
+
effectiveSettings: true
|
|
12616
|
+
}))).settings?.find((s) => s.name === "containerInsights")?.value;
|
|
12617
|
+
ecsContainerInsightsCache.set(region, value);
|
|
12618
|
+
return value;
|
|
12619
|
+
} catch {
|
|
12620
|
+
return;
|
|
12621
|
+
}
|
|
12622
|
+
}
|
|
12623
|
+
const ssmParameterTierCache = /* @__PURE__ */ new Map();
|
|
12624
|
+
async function fetchSsmDefaultParameterTier(region) {
|
|
12625
|
+
if (ssmParameterTierCache.has(region)) return ssmParameterTierCache.get(region);
|
|
12626
|
+
try {
|
|
12627
|
+
const value = (await new SSMClient({
|
|
12628
|
+
region,
|
|
12629
|
+
...READ_RETRY
|
|
12630
|
+
}).send(new GetServiceSettingCommand({ SettingId: "/ssm/parameter-store/default-parameter-tier" }))).ServiceSetting?.SettingValue;
|
|
12631
|
+
ssmParameterTierCache.set(region, value);
|
|
12632
|
+
return value;
|
|
12633
|
+
} catch {
|
|
12634
|
+
return;
|
|
12635
|
+
}
|
|
12636
|
+
}
|
|
12637
|
+
const ebsEncryptionByDefaultCache = /* @__PURE__ */ new Map();
|
|
12638
|
+
async function fetchEbsEncryptionByDefault(region) {
|
|
12639
|
+
if (ebsEncryptionByDefaultCache.has(region)) return ebsEncryptionByDefaultCache.get(region);
|
|
12640
|
+
try {
|
|
12641
|
+
const value = (await new EC2Client({
|
|
12642
|
+
region,
|
|
12643
|
+
...READ_RETRY
|
|
12644
|
+
}).send(new GetEbsEncryptionByDefaultCommand({}))).EbsEncryptionByDefault;
|
|
12645
|
+
ebsEncryptionByDefaultCache.set(region, value);
|
|
12646
|
+
return value;
|
|
12647
|
+
} catch {
|
|
12648
|
+
return;
|
|
12649
|
+
}
|
|
12650
|
+
}
|
|
12574
12651
|
const kmsDeniedWarned = /* @__PURE__ */ new Set();
|
|
12575
12652
|
const kmsTransientWarned = /* @__PURE__ */ new Set();
|
|
12576
12653
|
const POOL_SIZE = 6;
|
|
@@ -13148,6 +13225,19 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
13148
13225
|
if (desired.resources.some((r) => DEFAULT_SG_LIST_TYPES.has(r.resourceType))) defaultSgIds = await fetchDefaultSgIds(region);
|
|
13149
13226
|
let defaultSubnetIds = /* @__PURE__ */ new Set();
|
|
13150
13227
|
if (desired.resources.some((r) => DEFAULT_SUBNET_LIST_TYPES.has(r.resourceType))) defaultSubnetIds = await fetchDefaultVpcSubnetIds(region);
|
|
13228
|
+
const accountDefaults = {};
|
|
13229
|
+
if (desired.resources.some((r) => r.resourceType === "AWS::ECS::Cluster")) {
|
|
13230
|
+
const v = await fetchEcsContainerInsightsDefault(region);
|
|
13231
|
+
if (v !== void 0) accountDefaults.ecsContainerInsights = v;
|
|
13232
|
+
}
|
|
13233
|
+
if (desired.resources.some((r) => r.resourceType === "AWS::SSM::Parameter")) {
|
|
13234
|
+
const v = await fetchSsmDefaultParameterTier(region);
|
|
13235
|
+
if (v !== void 0) accountDefaults.ssmParameterTier = v;
|
|
13236
|
+
}
|
|
13237
|
+
if (desired.resources.some((r) => r.resourceType === "AWS::EC2::Volume")) {
|
|
13238
|
+
const v = await fetchEbsEncryptionByDefault(region);
|
|
13239
|
+
if (v !== void 0) accountDefaults.ebsEncryptionByDefault = v;
|
|
13240
|
+
}
|
|
13151
13241
|
const classifyOpts = {
|
|
13152
13242
|
accountId: desired.accountId,
|
|
13153
13243
|
region,
|
|
@@ -13155,6 +13245,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
13155
13245
|
stackTags: desired.stackTags ?? {},
|
|
13156
13246
|
defaultSgIds,
|
|
13157
13247
|
defaultSubnetIds,
|
|
13248
|
+
accountDefaults,
|
|
13158
13249
|
oaiCanonicalIds,
|
|
13159
13250
|
siblingSgRules: buildSiblingSgRules(desired),
|
|
13160
13251
|
siblingEventBusPolicies: buildSiblingEventBusPolicies(desired),
|