cdk-real-drift 0.12.36 → 0.12.38
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 +86 -50
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -11,9 +11,9 @@ import { CloudFormationClient, DescribeStackResourcesCommand, DescribeStacksComm
|
|
|
11
11
|
import { DescribeAddressesCommand, DescribeClientVpnAuthorizationRulesCommand, DescribeClientVpnEndpointsCommand, DescribeClientVpnTargetNetworksCommand, DescribeLaunchTemplateVersionsCommand, DescribeNetworkAclsCommand, DescribeRouteTablesCommand, DescribeSecurityGroupsCommand, DescribeSubnetsCommand, DescribeVpcEndpointsCommand, EC2Client, ModifyClientVpnEndpointCommand } from "@aws-sdk/client-ec2";
|
|
12
12
|
import { DescribeDBClustersCommand, DescribeDBInstancesCommand, DescribeOptionGroupOptionsCommand, RDSClient } from "@aws-sdk/client-rds";
|
|
13
13
|
import { DescribeParametersCommand, GetParametersCommand, SSMClient } from "@aws-sdk/client-ssm";
|
|
14
|
+
import { createCredentialChain, fromEnv, fromNodeProviderChain } from "@aws-sdk/credential-providers";
|
|
14
15
|
import jsonata from "jsonata";
|
|
15
16
|
import { KMSClient, ListAliasesCommand } from "@aws-sdk/client-kms";
|
|
16
|
-
import { createCredentialChain, fromEnv, fromNodeProviderChain } from "@aws-sdk/credential-providers";
|
|
17
17
|
import { APIGatewayClient, GetAuthorizersCommand, GetGatewayResponsesCommand, GetModelsCommand, GetRequestValidatorsCommand, GetResourcesCommand, GetStagesCommand, UpdateIntegrationCommand, UpdateIntegrationResponseCommand, UpdateMethodResponseCommand, UpdateRestApiCommand } from "@aws-sdk/client-api-gateway";
|
|
18
18
|
import { AppConfigClient, ListConfigurationProfilesCommand, ListEnvironmentsCommand } from "@aws-sdk/client-appconfig";
|
|
19
19
|
import { AppSyncClient, ListApiKeysCommand, ListDataSourcesCommand, ListFunctionsCommand, ListResolversCommand, ListTypesCommand } from "@aws-sdk/client-appsync";
|
|
@@ -1762,6 +1762,31 @@ async function recordCorpusCase(dir, c) {
|
|
|
1762
1762
|
return p;
|
|
1763
1763
|
}
|
|
1764
1764
|
|
|
1765
|
+
//#endregion
|
|
1766
|
+
//#region src/read/client-config.ts
|
|
1767
|
+
/** Port of toolkit-lib awscli-compatible `shouldPrioritizeEnv()` (env creds win over profile). */
|
|
1768
|
+
function shouldPrioritizeEnv() {
|
|
1769
|
+
if (process.env.CDKRD_EXPLICIT_PROFILE) return false;
|
|
1770
|
+
const id = process.env.AWS_ACCESS_KEY_ID || process.env.AMAZON_ACCESS_KEY_ID;
|
|
1771
|
+
const key = process.env.AWS_SECRET_ACCESS_KEY || process.env.AMAZON_SECRET_ACCESS_KEY;
|
|
1772
|
+
return !!id && !!key;
|
|
1773
|
+
}
|
|
1774
|
+
const CLIENT_REQUEST_HANDLER = {
|
|
1775
|
+
connectionTimeout: 6e3,
|
|
1776
|
+
requestTimeout: 6e4,
|
|
1777
|
+
throwOnRequestTimeout: true
|
|
1778
|
+
};
|
|
1779
|
+
const CLIENT_CREDENTIALS = (awsIdentityProperties) => (shouldPrioritizeEnv() ? createCredentialChain(fromEnv(), fromNodeProviderChain({ clientConfig: { requestHandler: CLIENT_REQUEST_HANDLER } })) : fromNodeProviderChain({ clientConfig: { requestHandler: CLIENT_REQUEST_HANDLER } }))(awsIdentityProperties);
|
|
1780
|
+
const CLIENT_TIMEOUTS = {
|
|
1781
|
+
credentials: CLIENT_CREDENTIALS,
|
|
1782
|
+
requestHandler: CLIENT_REQUEST_HANDLER
|
|
1783
|
+
};
|
|
1784
|
+
const READ_RETRY = {
|
|
1785
|
+
maxAttempts: 10,
|
|
1786
|
+
retryMode: "adaptive",
|
|
1787
|
+
...CLIENT_TIMEOUTS
|
|
1788
|
+
};
|
|
1789
|
+
|
|
1765
1790
|
//#endregion
|
|
1766
1791
|
//#region src/normalize/cc-api-strip.ts
|
|
1767
1792
|
const ALWAYS_STRIPPED = new Set([
|
|
@@ -4558,8 +4583,12 @@ async function loadDesired(client, stackName, region, templateOverride, recovery
|
|
|
4558
4583
|
const credentials = client.config?.credentials;
|
|
4559
4584
|
ctx.crossRegionExports = await getCrossRegionExports(new SSMClient(credentials ? {
|
|
4560
4585
|
region,
|
|
4586
|
+
...READ_RETRY,
|
|
4561
4587
|
credentials
|
|
4562
|
-
} : {
|
|
4588
|
+
} : {
|
|
4589
|
+
region,
|
|
4590
|
+
...READ_RETRY
|
|
4591
|
+
}), accountId, region, crossRegionExportNames);
|
|
4563
4592
|
} catch (err) {
|
|
4564
4593
|
const msg = err instanceof Error ? err.message : String(err);
|
|
4565
4594
|
console.error(`warning: ${stackName}: ssm:GetParameters failed — crossRegionReferences reader GetAtt references (/cdk/exports/*) will resolve UNRESOLVED (their declared properties are skipped, not compared). Grant ssm:GetParameters for full coverage. (${msg})`);
|
|
@@ -4705,31 +4734,6 @@ function isLogGroupArnWildcardMatch(desired, actual) {
|
|
|
4705
4734
|
return stripLogGroupWildcard(desired) === stripLogGroupWildcard(actual);
|
|
4706
4735
|
}
|
|
4707
4736
|
|
|
4708
|
-
//#endregion
|
|
4709
|
-
//#region src/read/client-config.ts
|
|
4710
|
-
/** Port of toolkit-lib awscli-compatible `shouldPrioritizeEnv()` (env creds win over profile). */
|
|
4711
|
-
function shouldPrioritizeEnv() {
|
|
4712
|
-
if (process.env.CDKRD_EXPLICIT_PROFILE) return false;
|
|
4713
|
-
const id = process.env.AWS_ACCESS_KEY_ID || process.env.AMAZON_ACCESS_KEY_ID;
|
|
4714
|
-
const key = process.env.AWS_SECRET_ACCESS_KEY || process.env.AMAZON_SECRET_ACCESS_KEY;
|
|
4715
|
-
return !!id && !!key;
|
|
4716
|
-
}
|
|
4717
|
-
const CLIENT_REQUEST_HANDLER = {
|
|
4718
|
-
connectionTimeout: 6e3,
|
|
4719
|
-
requestTimeout: 6e4,
|
|
4720
|
-
throwOnRequestTimeout: true
|
|
4721
|
-
};
|
|
4722
|
-
const CLIENT_CREDENTIALS = (awsIdentityProperties) => (shouldPrioritizeEnv() ? createCredentialChain(fromEnv(), fromNodeProviderChain({ clientConfig: { requestHandler: CLIENT_REQUEST_HANDLER } })) : fromNodeProviderChain({ clientConfig: { requestHandler: CLIENT_REQUEST_HANDLER } }))(awsIdentityProperties);
|
|
4723
|
-
const CLIENT_TIMEOUTS = {
|
|
4724
|
-
credentials: CLIENT_CREDENTIALS,
|
|
4725
|
-
requestHandler: CLIENT_REQUEST_HANDLER
|
|
4726
|
-
};
|
|
4727
|
-
const READ_RETRY = {
|
|
4728
|
-
maxAttempts: 10,
|
|
4729
|
-
retryMode: "adaptive",
|
|
4730
|
-
...CLIENT_TIMEOUTS
|
|
4731
|
-
};
|
|
4732
|
-
|
|
4733
4737
|
//#endregion
|
|
4734
4738
|
//#region src/read/kms-aliases.ts
|
|
4735
4739
|
const cache$1 = /* @__PURE__ */ new Map();
|
|
@@ -5553,12 +5557,12 @@ function isSelfEchoTrivialEmpty(v, physicalId) {
|
|
|
5553
5557
|
function isIdentityOnlyHusk(el, idField) {
|
|
5554
5558
|
return Object.entries(el).every(([k, v]) => k === idField || isTrivialEmpty(v));
|
|
5555
5559
|
}
|
|
5556
|
-
function rdsMaterializedDefault(catalog, physicalId,
|
|
5560
|
+
function rdsMaterializedDefault(catalog, physicalId, aligned, path, settingName) {
|
|
5557
5561
|
if (!catalog || physicalId === void 0) return void 0;
|
|
5558
5562
|
const m = /OptionConfigurations\.(\d+)\.OptionSettings$/.exec(path);
|
|
5559
5563
|
if (!m) return void 0;
|
|
5560
|
-
const configs =
|
|
5561
|
-
const optName =
|
|
5564
|
+
const configs = Array.isArray(aligned) ? aligned : void 0;
|
|
5565
|
+
const optName = configs ? configs[Number(m[1])]?.OptionName : void 0;
|
|
5562
5566
|
if (typeof optName !== "string") return void 0;
|
|
5563
5567
|
const perOption = catalog[physicalId]?.[optName];
|
|
5564
5568
|
return perOption && settingName in perOption ? perOption[settingName] : void 0;
|
|
@@ -6396,7 +6400,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6396
6400
|
let isRdsOptionDefault = false;
|
|
6397
6401
|
if (resourceType === "AWS::RDS::OptionGroup") if (isIdentityOnlyHusk(loRec, nvSubsetSpec.nameField)) isRdsOptionDefault = true;
|
|
6398
6402
|
else {
|
|
6399
|
-
const matDefault = rdsMaterializedDefault(opts.rdsOptionSettingDefaults, physicalId,
|
|
6403
|
+
const matDefault = rdsMaterializedDefault(opts.rdsOptionSettingDefaults, physicalId, liveVal, d.path, loName);
|
|
6400
6404
|
isRdsOptionDefault = matDefault != null && matDefault === loValue;
|
|
6401
6405
|
}
|
|
6402
6406
|
findings.push({
|
|
@@ -6744,7 +6748,13 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6744
6748
|
} catch {
|
|
6745
6749
|
liveDefParsed = void 0;
|
|
6746
6750
|
}
|
|
6747
|
-
|
|
6751
|
+
let declaredDef = sfnDefinitionObject;
|
|
6752
|
+
if (sfnDefinitionSubstitutions !== void 0) try {
|
|
6753
|
+
declaredDef = JSON.parse(applyDefinitionSubstitutions(JSON.stringify(sfnDefinitionObject), sfnDefinitionSubstitutions));
|
|
6754
|
+
} catch {
|
|
6755
|
+
declaredDef = sfnDefinitionObject;
|
|
6756
|
+
}
|
|
6757
|
+
if (liveDefParsed !== void 0 && deepEqual(liveDefParsed, declaredDef)) {
|
|
6748
6758
|
findings.push({
|
|
6749
6759
|
tier: "atDefault",
|
|
6750
6760
|
logicalId,
|
|
@@ -6754,6 +6764,16 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6754
6764
|
});
|
|
6755
6765
|
continue;
|
|
6756
6766
|
}
|
|
6767
|
+
if (liveDefParsed !== void 0 && deepEqualModuloNonAsciiMask(declaredDef, liveDefParsed)) {
|
|
6768
|
+
findings.push({
|
|
6769
|
+
tier: "readGap",
|
|
6770
|
+
logicalId,
|
|
6771
|
+
resourceType,
|
|
6772
|
+
path: "Definition",
|
|
6773
|
+
note: GETTEMPLATE_MASK_NOTE
|
|
6774
|
+
});
|
|
6775
|
+
continue;
|
|
6776
|
+
}
|
|
6757
6777
|
}
|
|
6758
6778
|
const twinSourceKey = SHAPE_ECHO_TWIN[resourceType]?.[k];
|
|
6759
6779
|
const twinSource = twinSourceKey !== void 0 ? twinSources[twinSourceKey] ?? declared[twinSourceKey] : void 0;
|
|
@@ -6955,35 +6975,39 @@ async function enumerateRestApiChildren(ctx) {
|
|
|
6955
6975
|
const authorizerAdded = diffApiGatewayAuthorizers({
|
|
6956
6976
|
apiId,
|
|
6957
6977
|
declaredAuthorizerIds,
|
|
6958
|
-
liveAuthorizers: (await getAllAuthorizers(client, apiId)).filter((a) => typeof a.id === "string").map((a) => ({
|
|
6978
|
+
liveAuthorizers: (bodyDefined ? [] : await getAllAuthorizers(client, apiId)).filter((a) => typeof a.id === "string").map((a) => ({
|
|
6959
6979
|
id: a.id,
|
|
6960
6980
|
label: a.name ?? a.id
|
|
6961
|
-
}))
|
|
6981
|
+
})),
|
|
6982
|
+
bodyDefined
|
|
6962
6983
|
});
|
|
6963
6984
|
const modelAdded = diffApiGatewayModels({
|
|
6964
6985
|
apiId,
|
|
6965
6986
|
declaredModelNames,
|
|
6966
|
-
liveModels: (await getAllModels(client, apiId)).filter((m) => typeof m.name === "string").map((m) => ({
|
|
6987
|
+
liveModels: (bodyDefined ? [] : await getAllModels(client, apiId)).filter((m) => typeof m.name === "string").map((m) => ({
|
|
6967
6988
|
name: m.name,
|
|
6968
6989
|
label: m.name
|
|
6969
|
-
}))
|
|
6990
|
+
})),
|
|
6991
|
+
bodyDefined
|
|
6970
6992
|
});
|
|
6971
6993
|
const validatorAdded = diffApiGatewayRequestValidators({
|
|
6972
6994
|
apiId,
|
|
6973
6995
|
declaredValidatorIds,
|
|
6974
|
-
liveValidators: (await getAllRequestValidators(client, apiId)).filter((v) => typeof v.id === "string").map((v) => ({
|
|
6996
|
+
liveValidators: (bodyDefined ? [] : await getAllRequestValidators(client, apiId)).filter((v) => typeof v.id === "string").map((v) => ({
|
|
6975
6997
|
id: v.id,
|
|
6976
6998
|
label: v.name ?? v.id
|
|
6977
|
-
}))
|
|
6999
|
+
})),
|
|
7000
|
+
bodyDefined
|
|
6978
7001
|
});
|
|
6979
7002
|
const gatewayResponseAdded = diffApiGatewayGatewayResponses({
|
|
6980
7003
|
apiId,
|
|
6981
7004
|
declaredResponseTypes,
|
|
6982
|
-
liveResponseTypes: (await getAllGatewayResponses(client, apiId)).filter((g) => typeof g.responseType === "string").map((g) => ({
|
|
7005
|
+
liveResponseTypes: (bodyDefined ? [] : await getAllGatewayResponses(client, apiId)).filter((g) => typeof g.responseType === "string").map((g) => ({
|
|
6983
7006
|
type: g.responseType,
|
|
6984
7007
|
label: g.responseType
|
|
6985
7008
|
})),
|
|
6986
|
-
hasUnresolvedDeclaredResponseType: gatewayResponseTypeUnresolved
|
|
7009
|
+
hasUnresolvedDeclaredResponseType: gatewayResponseTypeUnresolved,
|
|
7010
|
+
bodyDefined
|
|
6987
7011
|
});
|
|
6988
7012
|
const stageAdded = diffApiGatewayStages({
|
|
6989
7013
|
apiId,
|
|
@@ -7024,7 +7048,8 @@ async function getAllStages(client, apiId) {
|
|
|
7024
7048
|
return (await client.send(new GetStagesCommand({ restApiId: apiId }))).item ?? [];
|
|
7025
7049
|
}
|
|
7026
7050
|
function diffApiGatewayAuthorizers(input) {
|
|
7027
|
-
const { apiId, declaredAuthorizerIds, liveAuthorizers } = input;
|
|
7051
|
+
const { apiId, declaredAuthorizerIds, liveAuthorizers, bodyDefined } = input;
|
|
7052
|
+
if (bodyDefined) return [];
|
|
7028
7053
|
const declared = new Set(declaredAuthorizerIds);
|
|
7029
7054
|
const added = [];
|
|
7030
7055
|
for (const a of liveAuthorizers) {
|
|
@@ -7057,7 +7082,8 @@ async function getAllAuthorizers(client, apiId) {
|
|
|
7057
7082
|
}
|
|
7058
7083
|
const BUILTIN_MODEL_NAMES = new Set(["Empty", "Error"]);
|
|
7059
7084
|
function diffApiGatewayModels(input) {
|
|
7060
|
-
const { apiId, declaredModelNames, liveModels } = input;
|
|
7085
|
+
const { apiId, declaredModelNames, liveModels, bodyDefined } = input;
|
|
7086
|
+
if (bodyDefined) return [];
|
|
7061
7087
|
const declared = new Set(declaredModelNames);
|
|
7062
7088
|
const added = [];
|
|
7063
7089
|
for (const m of liveModels) {
|
|
@@ -7090,7 +7116,8 @@ async function getAllModels(client, apiId) {
|
|
|
7090
7116
|
return out;
|
|
7091
7117
|
}
|
|
7092
7118
|
function diffApiGatewayRequestValidators(input) {
|
|
7093
|
-
const { apiId, declaredValidatorIds, liveValidators } = input;
|
|
7119
|
+
const { apiId, declaredValidatorIds, liveValidators, bodyDefined } = input;
|
|
7120
|
+
if (bodyDefined) return [];
|
|
7094
7121
|
const declared = new Set(declaredValidatorIds);
|
|
7095
7122
|
const added = [];
|
|
7096
7123
|
for (const v of liveValidators) {
|
|
@@ -7122,6 +7149,7 @@ async function getAllRequestValidators(client, apiId) {
|
|
|
7122
7149
|
return out;
|
|
7123
7150
|
}
|
|
7124
7151
|
function diffApiGatewayGatewayResponses(input) {
|
|
7152
|
+
if (input.bodyDefined) return [];
|
|
7125
7153
|
if (input.hasUnresolvedDeclaredResponseType) return [];
|
|
7126
7154
|
const { apiId, declaredResponseTypes, liveResponseTypes } = input;
|
|
7127
7155
|
const declared = new Set(declaredResponseTypes);
|
|
@@ -7678,14 +7706,15 @@ function diffUserPoolGroups(input) {
|
|
|
7678
7706
|
const added = [];
|
|
7679
7707
|
for (const g of liveGroups) {
|
|
7680
7708
|
if (declared.has(g.name)) continue;
|
|
7681
|
-
if (autoGroupNames.has(g.name)) continue;
|
|
7709
|
+
if (autoGroupNames.has(g.name) && g.roleArn === void 0) continue;
|
|
7682
7710
|
added.push({
|
|
7683
7711
|
resourceType: "AWS::Cognito::UserPoolGroup",
|
|
7684
7712
|
identifier: `${userPoolId}|${g.name}`,
|
|
7685
7713
|
label: g.label ?? g.name,
|
|
7686
7714
|
live: {
|
|
7687
7715
|
GroupName: g.name,
|
|
7688
|
-
UserPoolId: userPoolId
|
|
7716
|
+
UserPoolId: userPoolId,
|
|
7717
|
+
...g.roleArn !== void 0 ? { RoleArn: g.roleArn } : {}
|
|
7689
7718
|
}
|
|
7690
7719
|
});
|
|
7691
7720
|
}
|
|
@@ -7807,7 +7836,10 @@ async function enumerateUserPoolChildren(ctx) {
|
|
|
7807
7836
|
userPoolId,
|
|
7808
7837
|
declaredGroupNames,
|
|
7809
7838
|
declaredProviderNames,
|
|
7810
|
-
liveGroups: (await pageUserPoolGroups(client, userPoolId)).filter((g) => typeof g.GroupName === "string").map((g) => ({
|
|
7839
|
+
liveGroups: (await pageUserPoolGroups(client, userPoolId)).filter((g) => typeof g.GroupName === "string").map((g) => ({
|
|
7840
|
+
name: g.GroupName,
|
|
7841
|
+
roleArn: g.RoleArn
|
|
7842
|
+
}))
|
|
7811
7843
|
});
|
|
7812
7844
|
const resourceServerAdded = diffUserPoolResourceServers({
|
|
7813
7845
|
userPoolId,
|
|
@@ -10768,10 +10800,14 @@ const supplementTrustStore = async ({ physicalId, region }) => {
|
|
|
10768
10800
|
...READ_RETRY
|
|
10769
10801
|
}).send(new GetTrustStoreCaCertificatesBundleCommand({ TrustStoreArn: arn }))).Location);
|
|
10770
10802
|
if (!url) return void 0;
|
|
10771
|
-
|
|
10772
|
-
|
|
10773
|
-
|
|
10774
|
-
|
|
10803
|
+
try {
|
|
10804
|
+
const resp = await fetch(url, { signal: AbortSignal.timeout(CLIENT_REQUEST_HANDLER.requestTimeout) });
|
|
10805
|
+
if (!resp.ok) return void 0;
|
|
10806
|
+
const hash = hashCaBundle(await resp.text());
|
|
10807
|
+
return hash !== void 0 ? { CaCertificatesBundleSha256: hash } : void 0;
|
|
10808
|
+
} catch {
|
|
10809
|
+
return;
|
|
10810
|
+
}
|
|
10775
10811
|
};
|
|
10776
10812
|
const supplementLambdaFunction = async ({ physicalId, region }) => {
|
|
10777
10813
|
const name = str$1(physicalId);
|