cdk-real-drift 0.11.2 → 0.12.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/README.md +4 -0
- package/dist/cli.js +154 -43
- package/dist/cli.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -792,6 +792,10 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
|
|
|
792
792
|
`dms:DescribeEndpoints` + `dms:DescribeReplicationSubnetGroups` (read an
|
|
793
793
|
`AWS::DMS::Endpoint` / `AWS::DMS::ReplicationSubnetGroup` — the classic DMS
|
|
794
794
|
migration/CDC family, NON_PROVISIONABLE with no Cloud Control handlers),
|
|
795
|
+
`lakeformation:DescribeResource` (reads an `AWS::LakeFormation::Resource` — a
|
|
796
|
+
registered S3 data location whose Cloud Control `GetResource` returns
|
|
797
|
+
`UnsupportedActionException`; the physical id IS the location `ResourceArn`, and
|
|
798
|
+
the reader projects `RoleArn` / `WithFederation` / `HybridAccessEnabled`),
|
|
795
799
|
`mediaconvert:GetQueue` + `mediaconvert:GetJobTemplate` (read an
|
|
796
800
|
`AWS::MediaConvert::Queue` / `AWS::MediaConvert::JobTemplate` — a video-pipeline
|
|
797
801
|
staple, NON_PROVISIONABLE with no Cloud Control handlers; the physical id IS the
|
package/dist/cli.js
CHANGED
|
@@ -8,6 +8,7 @@ import { CloudControlClient, DeleteResourceCommand, GetResourceCommand, GetResou
|
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
9
|
import { BaseCredentials, CdkAppMultiContext, NonInteractiveIoHost, StackSelectionStrategy, Toolkit } from "@aws-cdk/toolkit-lib";
|
|
10
10
|
import { CloudFormationClient, DescribeStackResourcesCommand, DescribeStacksCommand, DescribeTypeCommand, GetTemplateCommand, ListExportsCommand, ListStackResourcesCommand } from "@aws-sdk/client-cloudformation";
|
|
11
|
+
import { DescribeAddressesCommand, DescribeClientVpnAuthorizationRulesCommand, DescribeClientVpnEndpointsCommand, DescribeClientVpnTargetNetworksCommand, DescribeLaunchTemplateVersionsCommand, DescribeNetworkAclsCommand, DescribeRouteTablesCommand, DescribeSecurityGroupsCommand, DescribeSubnetsCommand, DescribeVpcEndpointsCommand, EC2Client, ModifyClientVpnEndpointCommand } from "@aws-sdk/client-ec2";
|
|
11
12
|
import { DescribeDBClustersCommand, DescribeDBInstancesCommand, DescribeOptionGroupOptionsCommand, RDSClient } from "@aws-sdk/client-rds";
|
|
12
13
|
import { DescribeParametersCommand, GetParametersCommand, SSMClient } from "@aws-sdk/client-ssm";
|
|
13
14
|
import jsonata from "jsonata";
|
|
@@ -19,7 +20,6 @@ import { AppSyncClient, ListApiKeysCommand, ListDataSourcesCommand, ListFunction
|
|
|
19
20
|
import { ApiGatewayV2Client, DeleteAccessLogSettingsCommand, DeleteRouteSettingsCommand, GetAuthorizersCommand as GetAuthorizersCommand$1, GetIntegrationsCommand, GetRoutesCommand, GetStagesCommand as GetStagesCommand$1, UpdateStageCommand } from "@aws-sdk/client-apigatewayv2";
|
|
20
21
|
import { CloudWatchLogsClient, DescribeMetricFiltersCommand, DescribeSubscriptionFiltersCommand, PutBearerTokenAuthenticationCommand, PutMetricFilterCommand } from "@aws-sdk/client-cloudwatch-logs";
|
|
21
22
|
import { CognitoIdentityProviderClient, ListGroupsCommand, ListIdentityProvidersCommand, ListResourceServersCommand, ListUserPoolClientsCommand } from "@aws-sdk/client-cognito-identity-provider";
|
|
22
|
-
import { DescribeAddressesCommand, DescribeClientVpnAuthorizationRulesCommand, DescribeClientVpnEndpointsCommand, DescribeClientVpnTargetNetworksCommand, DescribeLaunchTemplateVersionsCommand, DescribeNetworkAclsCommand, DescribeRouteTablesCommand, DescribeSubnetsCommand, DescribeVpcEndpointsCommand, EC2Client, ModifyClientVpnEndpointCommand } from "@aws-sdk/client-ec2";
|
|
23
23
|
import { DescribeServicesCommand, ECSClient, ListServicesCommand, UpdateServiceCommand } from "@aws-sdk/client-ecs";
|
|
24
24
|
import { DescribeMountTargetsCommand, EFSClient } from "@aws-sdk/client-efs";
|
|
25
25
|
import { DescribeListenersCommand, DescribeRulesCommand, ElasticLoadBalancingV2Client, GetTrustStoreCaCertificatesBundleCommand, ModifyLoadBalancerAttributesCommand, ModifyTargetGroupAttributesCommand } from "@aws-sdk/client-elastic-load-balancing-v2";
|
|
@@ -42,6 +42,7 @@ import { DescribeParameterGroupsCommand as DescribeParameterGroupsCommand$1, Des
|
|
|
42
42
|
import { CloudWatchClient, DescribeAnomalyDetectorsCommand, PutAnomalyDetectorCommand } from "@aws-sdk/client-cloudwatch";
|
|
43
43
|
import { DLMClient, GetLifecyclePolicyCommand, UpdateLifecyclePolicyCommand } from "@aws-sdk/client-dlm";
|
|
44
44
|
import { DatabaseMigrationServiceClient, DescribeEndpointsCommand, DescribeReplicationInstancesCommand, DescribeReplicationSubnetGroupsCommand, DescribeReplicationTasksCommand } from "@aws-sdk/client-database-migration-service";
|
|
45
|
+
import { DescribeResourceCommand, EntityNotFoundException, LakeFormationClient } from "@aws-sdk/client-lakeformation";
|
|
45
46
|
import { GetJobTemplateCommand, GetQueueCommand, MediaConvertClient } from "@aws-sdk/client-mediaconvert";
|
|
46
47
|
import { DescribeConfigurationCommand, DescribeConfigurationRevisionCommand, KafkaClient, UpdateConfigurationCommand } from "@aws-sdk/client-kafka";
|
|
47
48
|
import { GetWorkgroupCommand, RedshiftServerlessClient } from "@aws-sdk/client-redshift-serverless";
|
|
@@ -1641,6 +1642,7 @@ function sanitizeAccountId(value, accountId) {
|
|
|
1641
1642
|
function buildCorpusCase(resource, liveRaw, schema, opts, findings) {
|
|
1642
1643
|
const sgSibling = resource.resourceType === "AWS::EC2::SecurityGroup" && resource.physicalId ? opts.siblingSgRules?.[resource.physicalId] : void 0;
|
|
1643
1644
|
const bucketNotif = resource.physicalId && opts.bucketNotificationManaged?.has(resource.physicalId) ? [resource.physicalId] : void 0;
|
|
1645
|
+
const eipSiblingId = resource.physicalId && opts.siblingEipAssociations?.has(resource.physicalId) ? resource.physicalId : opts.siblingEipAssociations?.has(resource.logicalId) ? resource.logicalId : void 0;
|
|
1644
1646
|
const echoModel = resource.physicalId && opts.clusterEchoModel?.[resource.physicalId] ? opts.clusterEchoModel[resource.physicalId] : void 0;
|
|
1645
1647
|
const rdsOptCatalog = resource.physicalId && opts.rdsOptionSettingDefaults?.[resource.physicalId] ? opts.rdsOptionSettingDefaults[resource.physicalId] : void 0;
|
|
1646
1648
|
const listenerArn = resource.resourceType === "AWS::GlobalAccelerator::EndpointGroup" ? resource.declared?.ListenerArn : void 0;
|
|
@@ -1676,6 +1678,7 @@ function buildCorpusCase(resource, liveRaw, schema, opts, findings) {
|
|
|
1676
1678
|
oaiCanonicalIds: opts.oaiCanonicalIds,
|
|
1677
1679
|
...sgSibling && resource.physicalId ? { siblingSgRules: { [resource.physicalId]: sgSibling } } : {},
|
|
1678
1680
|
...bucketNotif ? { bucketNotificationManaged: bucketNotif } : {},
|
|
1681
|
+
...eipSiblingId ? { siblingEipAssociations: [eipSiblingId] } : {},
|
|
1679
1682
|
...echoModel && resource.physicalId ? { clusterEchoModel: { [resource.physicalId]: echoModel } } : {},
|
|
1680
1683
|
...rdsOptCatalog && resource.physicalId ? { rdsOptionSettingDefaults: { [resource.physicalId]: rdsOptCatalog } } : {},
|
|
1681
1684
|
...gaListenerPort ? { siblingListenerPorts: gaListenerPort } : {}
|
|
@@ -3040,7 +3043,6 @@ function ebOptionSettingTier(namespace, optionName, value, envType, siblingOptio
|
|
|
3040
3043
|
return "undeclared";
|
|
3041
3044
|
}
|
|
3042
3045
|
const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
|
|
3043
|
-
"AWS::ElasticLoadBalancingV2::LoadBalancer": new Set(["SecurityGroups"]),
|
|
3044
3046
|
"AWS::ApiGateway::ApiKey": new Set(["Value"]),
|
|
3045
3047
|
"AWS::Backup::BackupVault": new Set(["EncryptionKeyArn"]),
|
|
3046
3048
|
"AWS::Batch::JobQueue": new Set(["JobQueueType"]),
|
|
@@ -3114,15 +3116,11 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
|
|
|
3114
3116
|
"CpuOptions",
|
|
3115
3117
|
"SubnetId"
|
|
3116
3118
|
]),
|
|
3117
|
-
"AWS::EC2::NetworkInterface": new Set([
|
|
3118
|
-
"PrivateIpAddress",
|
|
3119
|
-
"PrivateIpAddresses",
|
|
3120
|
-
"GroupSet"
|
|
3121
|
-
]),
|
|
3119
|
+
"AWS::EC2::NetworkInterface": new Set(["PrivateIpAddress", "PrivateIpAddresses"]),
|
|
3122
3120
|
"AWS::EC2::Volume": new Set(["KmsKeyId", "AvailabilityZoneId"]),
|
|
3123
3121
|
"AWS::EC2::NatGateway": new Set(["PrivateIpAddress", "VpcId"]),
|
|
3124
3122
|
"AWS::EFS::MountTarget": new Set(["IpAddress"]),
|
|
3125
|
-
"AWS::EC2::EIP": new Set(["NetworkBorderGroup"
|
|
3123
|
+
"AWS::EC2::EIP": new Set(["NetworkBorderGroup"]),
|
|
3126
3124
|
"AWS::EFS::FileSystem": new Set(["KmsKeyId"]),
|
|
3127
3125
|
"AWS::EC2::SecurityGroup": new Set(["VpcId"]),
|
|
3128
3126
|
"AWS::GlobalAccelerator::Accelerator": new Set(["IpAddresses"]),
|
|
@@ -5096,6 +5094,23 @@ function guardDutyFeaturesAllAtDefault(features) {
|
|
|
5096
5094
|
};
|
|
5097
5095
|
return features.every(atDefault);
|
|
5098
5096
|
}
|
|
5097
|
+
const DEFAULT_SG_LIST_PATHS = {
|
|
5098
|
+
"AWS::ElasticLoadBalancingV2::LoadBalancer": "SecurityGroups",
|
|
5099
|
+
"AWS::EC2::NetworkInterface": "GroupSet"
|
|
5100
|
+
};
|
|
5101
|
+
/** #889 fold decision for an UNDECLARED default-SG list (ALB SecurityGroups / ENI GroupSet).
|
|
5102
|
+
* Returns whether the value-independent fold should still apply for this live value:
|
|
5103
|
+
* - `true` → FOLD (atDefault): the live list is a single VPC-default SG id, OR the prefetch is
|
|
5104
|
+
* unavailable (fail OPEN — no ec2:DescribeSecurityGroups / lookup failed / empty).
|
|
5105
|
+
* - `false` → SURFACE (undeclared): the live list has 2+ elements (an out-of-band SG APPEND) or
|
|
5106
|
+
* a single NON-default SG (an out-of-band SWAP) — a real, security-relevant drift.
|
|
5107
|
+
* Pure; `defaultSgIds` is the resolved set of VPC-default SG ids (undefined/empty when unresolved).*/
|
|
5108
|
+
function shouldFoldDefaultSgList(resourceType, key, liveValue, defaultSgIds) {
|
|
5109
|
+
if (DEFAULT_SG_LIST_PATHS[resourceType] !== key) return false;
|
|
5110
|
+
if (!defaultSgIds || defaultSgIds.size === 0) return true;
|
|
5111
|
+
if (!Array.isArray(liveValue)) return true;
|
|
5112
|
+
return liveValue.length === 1 && typeof liveValue[0] === "string" && defaultSgIds.has(liveValue[0]);
|
|
5113
|
+
}
|
|
5099
5114
|
const stripCognitoAttrPrefix = (id) => id.replace(/^(custom|dev):/, "");
|
|
5100
5115
|
const IDENTITY_KEYED_SUBSET_ARRAYS = {
|
|
5101
5116
|
"AWS::Cognito::UserPool": { Schema: {
|
|
@@ -5632,6 +5647,9 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
5632
5647
|
const sibHooks = physicalId ? opts.siblingLifecycleHooks?.[physicalId] : void 0;
|
|
5633
5648
|
if (sibHooks) subtractSiblingLifecycleHooks(live, sibHooks);
|
|
5634
5649
|
}
|
|
5650
|
+
if (resourceType === "AWS::EC2::EIP" && "NetworkInterfaceId" in live) {
|
|
5651
|
+
if (physicalId !== void 0 && opts.siblingEipAssociations?.has(physicalId) || opts.siblingEipAssociations?.has(logicalId)) delete live.NetworkInterfaceId;
|
|
5652
|
+
}
|
|
5635
5653
|
if (resourceType === "AWS::S3::Bucket" && physicalId && opts.bucketNotificationManaged?.has(physicalId) && !("NotificationConfiguration" in declared)) delete live.NotificationConfiguration;
|
|
5636
5654
|
const echoSpec = CLUSTER_ECHO_CHILD[resourceType];
|
|
5637
5655
|
const echoModel = echoSpec && physicalId ? opts.clusterEchoModel?.[physicalId] : void 0;
|
|
@@ -6311,6 +6329,16 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6311
6329
|
});
|
|
6312
6330
|
continue;
|
|
6313
6331
|
}
|
|
6332
|
+
if (DEFAULT_SG_LIST_PATHS[resourceType] === k && !isTrivialEmpty(v)) {
|
|
6333
|
+
findings.push({
|
|
6334
|
+
tier: shouldFoldDefaultSgList(resourceType, k, v, opts.defaultSgIds) ? "atDefault" : "undeclared",
|
|
6335
|
+
logicalId,
|
|
6336
|
+
resourceType,
|
|
6337
|
+
path: k,
|
|
6338
|
+
actual: v
|
|
6339
|
+
});
|
|
6340
|
+
continue;
|
|
6341
|
+
}
|
|
6314
6342
|
if (k in schema.defaults && matchesKnownDefault(v, schema.defaults[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)) {
|
|
6315
6343
|
findings.push({
|
|
6316
6344
|
tier: "atDefault",
|
|
@@ -6556,6 +6584,19 @@ function parentRefMatches(declaredValue, ...candidates) {
|
|
|
6556
6584
|
if (declaredValue === UNRESOLVED || hasUnresolved(declaredValue)) return true;
|
|
6557
6585
|
return candidates.some((c) => c !== void 0 && declaredValue === c);
|
|
6558
6586
|
}
|
|
6587
|
+
function unqualifiedFunctionRef(ref) {
|
|
6588
|
+
if (typeof ref !== "string") return ref;
|
|
6589
|
+
if (ref.startsWith("arn:")) {
|
|
6590
|
+
const seg = ref.split(":");
|
|
6591
|
+
if (seg.length >= 8 && seg[5] === "function") return seg.slice(0, 7).join(":");
|
|
6592
|
+
return ref;
|
|
6593
|
+
}
|
|
6594
|
+
const i = ref.indexOf(":");
|
|
6595
|
+
return i === -1 ? ref : ref.slice(0, i);
|
|
6596
|
+
}
|
|
6597
|
+
function lambdaFunctionRefMatches(declaredValue, ...candidates) {
|
|
6598
|
+
return parentRefMatches(unqualifiedFunctionRef(declaredValue), ...candidates.map((c) => c === void 0 ? void 0 : unqualifiedFunctionRef(c)));
|
|
6599
|
+
}
|
|
6559
6600
|
const CHILD_ENUMERATORS = {
|
|
6560
6601
|
"AWS::ApiGateway::RestApi": enumerateRestApiChildren,
|
|
6561
6602
|
"AWS::ApiGatewayV2::Api": enumerateHttpApiChildren,
|
|
@@ -7264,7 +7305,7 @@ async function enumerateLambdaFunctionChildren(ctx) {
|
|
|
7264
7305
|
for (const r of desired.resources) {
|
|
7265
7306
|
if (r.resourceType !== "AWS::Lambda::EventSourceMapping" || !r.physicalId) continue;
|
|
7266
7307
|
const fn = r.declared.FunctionName;
|
|
7267
|
-
if (
|
|
7308
|
+
if (lambdaFunctionRefMatches(fn, functionName, fnArn)) declaredMappingIds.push(r.physicalId);
|
|
7268
7309
|
}
|
|
7269
7310
|
const declaredUrlArns = [];
|
|
7270
7311
|
for (const r of desired.resources) {
|
|
@@ -7283,7 +7324,7 @@ async function enumerateLambdaFunctionChildren(ctx) {
|
|
|
7283
7324
|
const declaredVersionArns = [];
|
|
7284
7325
|
for (const r of desired.resources) {
|
|
7285
7326
|
if (r.resourceType !== "AWS::Lambda::Version" || !r.physicalId) continue;
|
|
7286
|
-
if (
|
|
7327
|
+
if (lambdaFunctionRefMatches(r.declared.FunctionName, functionName, fnArn)) declaredVersionArns.push(r.physicalId);
|
|
7287
7328
|
}
|
|
7288
7329
|
const client = new LambdaClient({
|
|
7289
7330
|
region,
|
|
@@ -9011,6 +9052,28 @@ const readDmsReplicationTask = async ({ physicalId, region }) => {
|
|
|
9011
9052
|
if (str$1(t.TaskData)) model.TaskData = t.TaskData;
|
|
9012
9053
|
return model;
|
|
9013
9054
|
};
|
|
9055
|
+
const readLakeFormationResource = async ({ physicalId, region }) => {
|
|
9056
|
+
const arn = str$1(physicalId);
|
|
9057
|
+
if (!arn) return void 0;
|
|
9058
|
+
const c = new LakeFormationClient({
|
|
9059
|
+
region,
|
|
9060
|
+
...READ_RETRY
|
|
9061
|
+
});
|
|
9062
|
+
let info;
|
|
9063
|
+
try {
|
|
9064
|
+
info = (await c.send(new DescribeResourceCommand({ ResourceArn: arn }))).ResourceInfo;
|
|
9065
|
+
} catch (e) {
|
|
9066
|
+
if (e instanceof EntityNotFoundException) throw new ResourceGoneError(`LakeFormation Resource ${arn} absent`);
|
|
9067
|
+
throw e;
|
|
9068
|
+
}
|
|
9069
|
+
if (!info) throw new ResourceGoneError(`LakeFormation Resource ${arn} absent`);
|
|
9070
|
+
const model = {};
|
|
9071
|
+
if (str$1(info.ResourceArn)) model.ResourceArn = info.ResourceArn;
|
|
9072
|
+
if (str$1(info.RoleArn)) model.RoleArn = info.RoleArn;
|
|
9073
|
+
if (typeof info.WithFederation === "boolean") model.WithFederation = info.WithFederation;
|
|
9074
|
+
if (typeof info.HybridAccessEnabled === "boolean") model.HybridAccessEnabled = info.HybridAccessEnabled;
|
|
9075
|
+
return model;
|
|
9076
|
+
};
|
|
9014
9077
|
const readMediaConvertQueue = async ({ physicalId, region }) => {
|
|
9015
9078
|
const name = str$1(physicalId);
|
|
9016
9079
|
if (!name) return void 0;
|
|
@@ -10015,6 +10078,7 @@ const SDK_OVERRIDES = {
|
|
|
10015
10078
|
"AWS::DMS::ReplicationSubnetGroup": readDmsReplicationSubnetGroup,
|
|
10016
10079
|
"AWS::DMS::ReplicationInstance": readDmsReplicationInstance,
|
|
10017
10080
|
"AWS::DMS::ReplicationTask": readDmsReplicationTask,
|
|
10081
|
+
"AWS::LakeFormation::Resource": readLakeFormationResource,
|
|
10018
10082
|
"AWS::MediaConvert::Queue": readMediaConvertQueue,
|
|
10019
10083
|
"AWS::MediaConvert::JobTemplate": readMediaConvertJobTemplate,
|
|
10020
10084
|
"AWS::Route53::RecordSet": readRoute53RecordSet,
|
|
@@ -10941,6 +11005,36 @@ function liveModelMap(reads) {
|
|
|
10941
11005
|
for (const [logicalId, read] of reads) if (read.live) out.set(logicalId, read.live);
|
|
10942
11006
|
return out;
|
|
10943
11007
|
}
|
|
11008
|
+
const DEFAULT_SG_LIST_TYPES = new Set(["AWS::ElasticLoadBalancingV2::LoadBalancer", "AWS::EC2::NetworkInterface"]);
|
|
11009
|
+
const defaultSgIdsCache = /* @__PURE__ */ new Map();
|
|
11010
|
+
async function fetchDefaultSgIds(region) {
|
|
11011
|
+
const cached = defaultSgIdsCache.get(region);
|
|
11012
|
+
if (cached) return cached;
|
|
11013
|
+
const ids = /* @__PURE__ */ new Set();
|
|
11014
|
+
try {
|
|
11015
|
+
const c = new EC2Client({
|
|
11016
|
+
region,
|
|
11017
|
+
...READ_RETRY
|
|
11018
|
+
});
|
|
11019
|
+
let token;
|
|
11020
|
+
do {
|
|
11021
|
+
const r = await c.send(new DescribeSecurityGroupsCommand({
|
|
11022
|
+
Filters: [{
|
|
11023
|
+
Name: "group-name",
|
|
11024
|
+
Values: ["default"]
|
|
11025
|
+
}],
|
|
11026
|
+
NextToken: token,
|
|
11027
|
+
MaxResults: 1e3
|
|
11028
|
+
}));
|
|
11029
|
+
for (const g of r.SecurityGroups ?? []) if (g.GroupId) ids.add(g.GroupId);
|
|
11030
|
+
token = r.NextToken;
|
|
11031
|
+
} while (token);
|
|
11032
|
+
} catch {
|
|
11033
|
+
return ids;
|
|
11034
|
+
}
|
|
11035
|
+
defaultSgIdsCache.set(region, ids);
|
|
11036
|
+
return ids;
|
|
11037
|
+
}
|
|
10944
11038
|
const kmsDeniedWarned = /* @__PURE__ */ new Set();
|
|
10945
11039
|
const kmsTransientWarned = /* @__PURE__ */ new Set();
|
|
10946
11040
|
const POOL_SIZE = 6;
|
|
@@ -11203,6 +11297,44 @@ function resolvePrincipalKey(ref, byLogicalId) {
|
|
|
11203
11297
|
if (typeof logicalId === "string") return byLogicalId.get(logicalId);
|
|
11204
11298
|
}
|
|
11205
11299
|
}
|
|
11300
|
+
const EIP_ASSOCIATION_TYPE = "AWS::EC2::EIPAssociation";
|
|
11301
|
+
const NAT_GATEWAY_TYPE = "AWS::EC2::NatGateway";
|
|
11302
|
+
function buildSiblingEipAssociations(desired) {
|
|
11303
|
+
const eipIdentities = /* @__PURE__ */ new Map();
|
|
11304
|
+
for (const r of desired.resources) {
|
|
11305
|
+
if (r.resourceType !== "AWS::EC2::EIP") continue;
|
|
11306
|
+
const ids = [r.logicalId];
|
|
11307
|
+
if (r.physicalId) ids.push(r.physicalId);
|
|
11308
|
+
eipIdentities.set(r.logicalId, ids);
|
|
11309
|
+
}
|
|
11310
|
+
const associated = /* @__PURE__ */ new Set();
|
|
11311
|
+
const markEip = (ref) => {
|
|
11312
|
+
let eipLogicalId;
|
|
11313
|
+
if (ref && typeof ref === "object") {
|
|
11314
|
+
if ("Ref" in ref && typeof ref.Ref === "string") eipLogicalId = ref.Ref;
|
|
11315
|
+
else if ("Fn::GetAtt" in ref) {
|
|
11316
|
+
const g = ref["Fn::GetAtt"];
|
|
11317
|
+
if (Array.isArray(g) && typeof g[0] === "string") eipLogicalId = g[0];
|
|
11318
|
+
}
|
|
11319
|
+
}
|
|
11320
|
+
if (eipLogicalId !== void 0) {
|
|
11321
|
+
const ids = eipIdentities.get(eipLogicalId);
|
|
11322
|
+
if (ids) for (const id of ids) associated.add(id);
|
|
11323
|
+
return;
|
|
11324
|
+
}
|
|
11325
|
+
if (typeof ref === "string" && ref) associated.add(ref);
|
|
11326
|
+
};
|
|
11327
|
+
for (const r of desired.resources) {
|
|
11328
|
+
const decl = r.declared;
|
|
11329
|
+
if (!decl || typeof decl !== "object") continue;
|
|
11330
|
+
const d = decl;
|
|
11331
|
+
if (r.resourceType === EIP_ASSOCIATION_TYPE) {
|
|
11332
|
+
markEip(d.AllocationId);
|
|
11333
|
+
markEip(d.EIP);
|
|
11334
|
+
} else if (r.resourceType === NAT_GATEWAY_TYPE) markEip(d.AllocationId);
|
|
11335
|
+
}
|
|
11336
|
+
return associated;
|
|
11337
|
+
}
|
|
11206
11338
|
function buildClusterEchoModels(desired) {
|
|
11207
11339
|
const parentTypes = new Set(Object.values(CLUSTER_ECHO_CHILD).map((s) => s.parentType));
|
|
11208
11340
|
const clusterByPhys = {};
|
|
@@ -11399,10 +11531,13 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
11399
11531
|
if (decision.stampTransient) kmsTransientWarned.add(region);
|
|
11400
11532
|
if (decision.warning) console.error(decision.warning);
|
|
11401
11533
|
}
|
|
11534
|
+
let defaultSgIds = /* @__PURE__ */ new Set();
|
|
11535
|
+
if (desired.resources.some((r) => DEFAULT_SG_LIST_TYPES.has(r.resourceType))) defaultSgIds = await fetchDefaultSgIds(region);
|
|
11402
11536
|
const classifyOpts = {
|
|
11403
11537
|
accountId: desired.accountId,
|
|
11404
11538
|
region,
|
|
11405
11539
|
kmsAliasTargets,
|
|
11540
|
+
defaultSgIds,
|
|
11406
11541
|
oaiCanonicalIds,
|
|
11407
11542
|
siblingSgRules: buildSiblingSgRules(desired),
|
|
11408
11543
|
siblingEventBusPolicies: buildSiblingEventBusPolicies(desired),
|
|
@@ -11410,6 +11545,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
11410
11545
|
siblingUserGroups: buildSiblingUserGroups(desired),
|
|
11411
11546
|
siblingLifecycleHooks: buildSiblingLifecycleHooks(desired),
|
|
11412
11547
|
siblingListenerPorts: buildSiblingListenerPorts(desired),
|
|
11548
|
+
siblingEipAssociations: buildSiblingEipAssociations(desired),
|
|
11413
11549
|
bucketNotificationManaged: buildBucketNotificationManaged(desired),
|
|
11414
11550
|
clusterEchoModel: buildClusterEchoModels(desired),
|
|
11415
11551
|
rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region)
|
|
@@ -11463,10 +11599,13 @@ async function regatherTouched(gathered, touched, region) {
|
|
|
11463
11599
|
for (const r of targets) if (r.declaredRaw) r.declared = resolveProperties(r.declaredRaw, desired.ctx);
|
|
11464
11600
|
const kmsAliasTargets = targets.some((r) => usesManagedKmsAlias(r.declared) || typeNeedsManagedKeyResolution(r.resourceType)) ? (await fetchManagedAliasTargets(region)).targets : {};
|
|
11465
11601
|
const oaiCanonicalIds = buildOaiCanonicalIds(desired);
|
|
11602
|
+
let defaultSgIds = /* @__PURE__ */ new Set();
|
|
11603
|
+
if (targets.some((r) => DEFAULT_SG_LIST_TYPES.has(r.resourceType))) defaultSgIds = await fetchDefaultSgIds(region);
|
|
11466
11604
|
const classifyOpts = {
|
|
11467
11605
|
accountId: desired.accountId,
|
|
11468
11606
|
region,
|
|
11469
11607
|
kmsAliasTargets,
|
|
11608
|
+
defaultSgIds,
|
|
11470
11609
|
oaiCanonicalIds,
|
|
11471
11610
|
siblingSgRules: buildSiblingSgRules(desired),
|
|
11472
11611
|
siblingEventBusPolicies: buildSiblingEventBusPolicies(desired),
|
|
@@ -11474,6 +11613,7 @@ async function regatherTouched(gathered, touched, region) {
|
|
|
11474
11613
|
siblingUserGroups: buildSiblingUserGroups(desired),
|
|
11475
11614
|
siblingLifecycleHooks: buildSiblingLifecycleHooks(desired),
|
|
11476
11615
|
siblingListenerPorts: buildSiblingListenerPorts(desired),
|
|
11616
|
+
siblingEipAssociations: buildSiblingEipAssociations(desired),
|
|
11477
11617
|
bucketNotificationManaged: buildBucketNotificationManaged(desired),
|
|
11478
11618
|
clusterEchoModel: buildClusterEchoModels(desired),
|
|
11479
11619
|
rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region)
|
|
@@ -12436,35 +12576,10 @@ async function bulkMultiselect(message, options) {
|
|
|
12436
12576
|
function unescape(seg) {
|
|
12437
12577
|
return seg.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
12438
12578
|
}
|
|
12439
|
-
function pointerSegs(path) {
|
|
12440
|
-
return path.split("/").slice(1).map(unescape);
|
|
12441
|
-
}
|
|
12442
|
-
var StaleRevertModelError = class extends Error {
|
|
12443
|
-
pointerPath;
|
|
12444
|
-
constructor(pointerPath) {
|
|
12445
|
-
super(`revert aborted: the live value at ${pointerPath} changed since drift was detected (an element in the same array was added or removed) — re-run \`check\` and revert again`);
|
|
12446
|
-
this.name = "StaleRevertModelError";
|
|
12447
|
-
this.pointerPath = pointerPath;
|
|
12448
|
-
}
|
|
12449
|
-
};
|
|
12450
|
-
function assertPriorUnchanged(model, ops) {
|
|
12451
|
-
for (const op of ops) {
|
|
12452
|
-
if (op.prior === void 0) continue;
|
|
12453
|
-
if (!deepEqual(getAt(model, pointerSegs(op.path)), op.prior)) throw new StaleRevertModelError(op.path);
|
|
12454
|
-
}
|
|
12455
|
-
}
|
|
12456
|
-
function getAt(root, segs) {
|
|
12457
|
-
let node = root;
|
|
12458
|
-
for (const seg of segs) {
|
|
12459
|
-
if (node === null || typeof node !== "object") return void 0;
|
|
12460
|
-
node = node[seg];
|
|
12461
|
-
}
|
|
12462
|
-
return node;
|
|
12463
|
-
}
|
|
12464
12579
|
function applyOps(model, ops) {
|
|
12465
12580
|
const out = structuredClone(model);
|
|
12466
12581
|
for (const op of ops) {
|
|
12467
|
-
const segs =
|
|
12582
|
+
const segs = op.path.split("/").slice(1).map(unescape);
|
|
12468
12583
|
if (op.op === "add") setAt(out, segs, op.value);
|
|
12469
12584
|
else removeAt(out, segs);
|
|
12470
12585
|
}
|
|
@@ -12502,12 +12617,10 @@ const assertOpsConsumed = (resourceType, ops, handled) => {
|
|
|
12502
12617
|
async function desiredModel(type, ctx, ops) {
|
|
12503
12618
|
const reader = SDK_OVERRIDES[type];
|
|
12504
12619
|
const current = (reader && await reader(ctx)) ?? {};
|
|
12505
|
-
|
|
12620
|
+
return applyOps(current.PolicyDocument === void 0 ? current : {
|
|
12506
12621
|
...current,
|
|
12507
12622
|
PolicyDocument: canonicalizeForCompare(current.PolicyDocument)
|
|
12508
|
-
};
|
|
12509
|
-
assertPriorUnchanged(aligned, ops);
|
|
12510
|
-
return applyOps(aligned, ops);
|
|
12623
|
+
}, ops);
|
|
12511
12624
|
}
|
|
12512
12625
|
const policyJson = (m) => m.PolicyDocument === void 0 ? void 0 : JSON.stringify(m.PolicyDocument);
|
|
12513
12626
|
const writeS3BucketPolicy = async (ctx, ops) => {
|
|
@@ -12867,9 +12980,7 @@ const writeWafv2WebAcl = async (ctx, ops) => {
|
|
|
12867
12980
|
Scope: scope
|
|
12868
12981
|
}));
|
|
12869
12982
|
if (!cur.WebACL || !cur.LockToken) throw new Error("could not read current WebACL for revert");
|
|
12870
|
-
const
|
|
12871
|
-
assertPriorUnchanged(alignedWebAcl, ops);
|
|
12872
|
-
const m = applyOps(alignedWebAcl, ops);
|
|
12983
|
+
const m = applyOps(canonicalizeForCompare(cur.WebACL), ops);
|
|
12873
12984
|
const desc = m.Description;
|
|
12874
12985
|
await c.send(new UpdateWebACLCommand({
|
|
12875
12986
|
Name: name,
|