cdk-real-drift 0.2.4 → 0.2.6
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 +11 -1
- package/dist/cli.js +93 -8
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -583,7 +583,13 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
|
|
|
583
583
|
`elasticache:DescribeReplicationGroups` + `elasticache:DescribeCacheClusters`
|
|
584
584
|
(supplement an `AWS::ElastiCache::ReplicationGroup` with its writeOnly
|
|
585
585
|
`PreferredMaintenanceWindow` / `NotificationTopicArn` / `EngineVersion`, read
|
|
586
|
-
from the member cache cluster),
|
|
586
|
+
from the member cache cluster),
|
|
587
|
+
`elasticache:DescribeCacheParameterGroups` + `elasticache:DescribeCacheParameters`
|
|
588
|
+
(read an `AWS::ElastiCache::ParameterGroup`'s `Properties` as the `Source=user`
|
|
589
|
+
MODIFIED set only — the Cloud Control read returns the full effective set, so the
|
|
590
|
+
~60 inherited engine defaults would otherwise surface as first-run drift; an
|
|
591
|
+
out-of-band parameter change is `Source=user` and still detected),
|
|
592
|
+
`ecs:DescribeServices` (supplements an
|
|
587
593
|
`AWS::ECS::Service` with its writeOnly `ServiceConnectConfiguration` /
|
|
588
594
|
`VolumeConfigurations`, read from the PRIMARY deployment),
|
|
589
595
|
`elasticache:DescribeUsers` + `memorydb:DescribeUsers` (supplement an
|
|
@@ -633,6 +639,10 @@ permissions), plus, for the SDK-written types: `s3:PutBucketPolicy` /
|
|
|
633
639
|
the whole `ConnectionInput` is re-supplied; a connection with an inline password
|
|
634
640
|
is refused, never overwritten, so the un-read credential is never cleared),
|
|
635
641
|
`logs:PutMetricFilter`, `route53:ChangeResourceRecordSets`,
|
|
642
|
+
`elasticache:ModifyCacheParameterGroup` / `ResetCacheParameterGroup` (revert an
|
|
643
|
+
`AWS::ElastiCache::ParameterGroup` — a changed declared parameter is modified back
|
|
644
|
+
to its desired value; an out-of-band-added undeclared parameter is reset to the
|
|
645
|
+
family default),
|
|
636
646
|
`ses:UpdateReceiptRule` (reverts an `AWS::SES::ReceiptRule` — the whole rule is
|
|
637
647
|
re-supplied in place, since Cloud Control has no handler for the type),
|
|
638
648
|
`cloudwatch:PutAnomalyDetector` (reverts an `AWS::CloudWatch::AnomalyDetector`
|
package/dist/cli.js
CHANGED
|
@@ -31,7 +31,7 @@ import { GetClassifierCommand, GetConnectionCommand, GetJobCommand, GetTableComm
|
|
|
31
31
|
import { ChangeResourceRecordSetsCommand, ListResourceRecordSetsCommand, Route53Client } from "@aws-sdk/client-route-53";
|
|
32
32
|
import { AttachGroupPolicyCommand, AttachRolePolicyCommand, AttachUserPolicyCommand, CreatePolicyVersionCommand, DeletePolicyVersionCommand, DeleteRolePolicyCommand, DetachGroupPolicyCommand, DetachRolePolicyCommand, DetachUserPolicyCommand, GetGroupPolicyCommand, GetPolicyCommand as GetPolicyCommand$1, GetPolicyVersionCommand, GetRolePolicyCommand, GetUserPolicyCommand, IAMClient, ListEntitiesForPolicyCommand, ListPolicyVersionsCommand, PutGroupPolicyCommand, PutRolePolicyCommand, PutUserPolicyCommand } from "@aws-sdk/client-iam";
|
|
33
33
|
import { DeleteBucketPolicyCommand, GetBucketPolicyCommand, PutBucketPolicyCommand, S3Client } from "@aws-sdk/client-s3";
|
|
34
|
-
import { DescribeCacheClustersCommand, DescribeReplicationGroupsCommand, DescribeUsersCommand, ElastiCacheClient } from "@aws-sdk/client-elasticache";
|
|
34
|
+
import { DescribeCacheClustersCommand, DescribeCacheParameterGroupsCommand, DescribeCacheParametersCommand, DescribeReplicationGroupsCommand, DescribeUsersCommand, ElastiCacheClient, ModifyCacheParameterGroupCommand, ResetCacheParameterGroupCommand } from "@aws-sdk/client-elasticache";
|
|
35
35
|
import { DescribeUsersCommand as DescribeUsersCommand$1, MemoryDBClient } from "@aws-sdk/client-memorydb";
|
|
36
36
|
import { CloudWatchClient, DescribeAnomalyDetectorsCommand, PutAnomalyDetectorCommand } from "@aws-sdk/client-cloudwatch";
|
|
37
37
|
import { DLMClient, GetLifecyclePolicyCommand, UpdateLifecyclePolicyCommand } from "@aws-sdk/client-dlm";
|
|
@@ -2678,6 +2678,19 @@ const UNORDERED_OBJECT_ARRAY_PROPS = {
|
|
|
2678
2678
|
"AWS::WAFv2::LoggingConfiguration": new Set(["RedactedFields"]),
|
|
2679
2679
|
"AWS::EC2::PrefixList": new Set(["Entries"])
|
|
2680
2680
|
};
|
|
2681
|
+
const UNORDERED_OBJECT_ARRAY_IDENTITY = {
|
|
2682
|
+
"AWS::Cognito::UserPoolResourceServer": { Scopes: "ScopeName" },
|
|
2683
|
+
"AWS::SecretsManager::Secret": { ReplicaRegions: "Region" },
|
|
2684
|
+
"AWS::ElastiCache::CacheCluster": { LogDeliveryConfigurations: "LogType" },
|
|
2685
|
+
"AWS::ElastiCache::ReplicationGroup": { LogDeliveryConfigurations: "LogType" },
|
|
2686
|
+
"AWS::AutoScaling::AutoScalingGroup": { LifecycleHookSpecificationList: "LifecycleHookName" },
|
|
2687
|
+
"AWS::Redshift::ClusterParameterGroup": { Parameters: "ParameterName" },
|
|
2688
|
+
"AWS::ElasticLoadBalancingV2::ListenerRule": { Conditions: "Field" },
|
|
2689
|
+
"AWS::EC2::PrefixList": { Entries: "Cidr" },
|
|
2690
|
+
"AWS::IAM::Role": { Policies: "PolicyName" },
|
|
2691
|
+
"AWS::IAM::User": { Policies: "PolicyName" },
|
|
2692
|
+
"AWS::IAM::Group": { Policies: "PolicyName" }
|
|
2693
|
+
};
|
|
2681
2694
|
const UNORDERED_NESTED_OBJECT_ARRAY_PATHS = {
|
|
2682
2695
|
"AWS::CloudFront::CachePolicy": new Set(["CachePolicyConfig.ParametersInCacheKeyAndForwardedToOrigin.HeadersConfig.Headers"]),
|
|
2683
2696
|
"AWS::CloudFront::Distribution": new Set(["DistributionConfig.Aliases"]),
|
|
@@ -2729,11 +2742,15 @@ function canonicalJson(v) {
|
|
|
2729
2742
|
}
|
|
2730
2743
|
return JSON.stringify(v) ?? "null";
|
|
2731
2744
|
}
|
|
2732
|
-
function sortUnorderedObjectArray(v) {
|
|
2745
|
+
function sortUnorderedObjectArray(v, identityField) {
|
|
2733
2746
|
if (!Array.isArray(v)) return v;
|
|
2747
|
+
const keyOf = (e) => {
|
|
2748
|
+
const id = identityField && e !== null && typeof e === "object" && !Array.isArray(e) ? e[identityField] : void 0;
|
|
2749
|
+
return `${id === void 0 ? "" : `${String(id)}`}${canonicalJson(e)}`;
|
|
2750
|
+
};
|
|
2734
2751
|
return [...v].sort((a, b) => {
|
|
2735
|
-
const ka =
|
|
2736
|
-
const kb =
|
|
2752
|
+
const ka = keyOf(a);
|
|
2753
|
+
const kb = keyOf(b);
|
|
2737
2754
|
return ka < kb ? -1 : ka > kb ? 1 : 0;
|
|
2738
2755
|
});
|
|
2739
2756
|
}
|
|
@@ -3967,6 +3984,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
3967
3984
|
const nestedSubPaths = [...new Set([...nestedUnordered ?? [], ...schema.unorderedObjectArrayPaths ?? []].filter((p) => p.startsWith(`${k}.`)).map((p) => p.slice(k.length + 1)))];
|
|
3968
3985
|
let declaredVal = v;
|
|
3969
3986
|
let liveVal = live[k];
|
|
3987
|
+
let declaredRemapSource;
|
|
3970
3988
|
if (subsetSpec && Array.isArray(v) && Array.isArray(live[k])) {
|
|
3971
3989
|
const { idField, normalizeId } = subsetSpec;
|
|
3972
3990
|
const idOf = (e) => {
|
|
@@ -4014,8 +4032,11 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
4014
4032
|
declaredVal = declaredSorted;
|
|
4015
4033
|
liveVal = liveAligned;
|
|
4016
4034
|
} else if (unorderedObjArray) {
|
|
4017
|
-
|
|
4018
|
-
|
|
4035
|
+
const declaredNestedSorted = nestedSubPaths.length > 0 ? sortNestedObjectArrays(v, nestedSubPaths) : v;
|
|
4036
|
+
const idField = UNORDERED_OBJECT_ARRAY_IDENTITY[resourceType]?.[k];
|
|
4037
|
+
declaredVal = sortUnorderedObjectArray(declaredNestedSorted, idField);
|
|
4038
|
+
liveVal = sortUnorderedObjectArray(nestedSubPaths.length > 0 ? sortNestedObjectArrays(live[k], nestedSubPaths) : live[k], idField);
|
|
4039
|
+
if (Array.isArray(declaredNestedSorted)) declaredRemapSource = declaredNestedSorted;
|
|
4019
4040
|
} else if (nestedSubPaths.length > 0) {
|
|
4020
4041
|
declaredVal = sortNestedObjectArrays(v, nestedSubPaths);
|
|
4021
4042
|
liveVal = sortNestedObjectArrays(live[k], nestedSubPaths);
|
|
@@ -4091,8 +4112,8 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
4091
4112
|
if (INTELLIGENT_TIERING_PATHS[resourceType]?.has(d.path) && isIntelligentTieringMatch(d.stateValue, d.awsValue)) continue;
|
|
4092
4113
|
if ((UNORDERED_ARRAY_PROPS[resourceType]?.has(d.path) || UNORDERED_ARRAY_PROPS[resourceType]?.has(d.path.replace(/\.\d+(?=\.|$)/g, ".*")) || schema.unorderedScalarPaths?.includes(d.path)) && isEqualUnorderedScalarSet(d.stateValue, d.awsValue)) continue;
|
|
4093
4114
|
if (isTrivialEmpty(d.stateValue) && d.path in knownDef && deepEqual(d.awsValue, knownDef[d.path])) continue;
|
|
4094
|
-
const unorderedExtra = unorderedObjArray && Array.isArray(declaredVal) &&
|
|
4095
|
-
path: remapSortedIndexToDeclared(d.path, k, declaredVal,
|
|
4115
|
+
const unorderedExtra = unorderedObjArray && Array.isArray(declaredVal) && declaredRemapSource ? {
|
|
4116
|
+
path: remapSortedIndexToDeclared(d.path, k, declaredVal, declaredRemapSource),
|
|
4096
4117
|
wholeArrayRevert: {
|
|
4097
4118
|
path: k,
|
|
4098
4119
|
value: v
|
|
@@ -6551,6 +6572,37 @@ const readDaxParameterGroup = async ({ physicalId, region }) => {
|
|
|
6551
6572
|
if (Object.keys(values).length > 0) model.ParameterNameValues = values;
|
|
6552
6573
|
return model;
|
|
6553
6574
|
};
|
|
6575
|
+
const readElastiCacheParameterGroup = async ({ physicalId, region }) => {
|
|
6576
|
+
const name = str$1(physicalId);
|
|
6577
|
+
if (!name) return void 0;
|
|
6578
|
+
const c = new ElastiCacheClient({
|
|
6579
|
+
region,
|
|
6580
|
+
...READ_RETRY
|
|
6581
|
+
});
|
|
6582
|
+
const g = (await c.send(new DescribeCacheParameterGroupsCommand({ CacheParameterGroupName: name }))).CacheParameterGroups?.[0];
|
|
6583
|
+
if (!g) throw new ResourceGoneError(`ElastiCache ParameterGroup ${name} absent`);
|
|
6584
|
+
const model = {};
|
|
6585
|
+
if (str$1(g.CacheParameterGroupName)) model.CacheParameterGroupName = g.CacheParameterGroupName;
|
|
6586
|
+
if (str$1(g.CacheParameterGroupFamily)) model.CacheParameterGroupFamily = g.CacheParameterGroupFamily;
|
|
6587
|
+
if (str$1(g.Description)) model.Description = g.Description;
|
|
6588
|
+
const values = {};
|
|
6589
|
+
let marker;
|
|
6590
|
+
do {
|
|
6591
|
+
const p = await c.send(new DescribeCacheParametersCommand({
|
|
6592
|
+
CacheParameterGroupName: name,
|
|
6593
|
+
Source: "user",
|
|
6594
|
+
Marker: marker
|
|
6595
|
+
}));
|
|
6596
|
+
for (const param of p.Parameters ?? []) {
|
|
6597
|
+
const pName = str$1(param.ParameterName);
|
|
6598
|
+
const pValue = param.ParameterValue;
|
|
6599
|
+
if (pName !== void 0 && typeof pValue === "string") values[pName] = pValue;
|
|
6600
|
+
}
|
|
6601
|
+
marker = str$1(p.Marker);
|
|
6602
|
+
} while (marker !== void 0);
|
|
6603
|
+
if (Object.keys(values).length > 0) model.Properties = values;
|
|
6604
|
+
return model;
|
|
6605
|
+
};
|
|
6554
6606
|
const readDaxSubnetGroup = async ({ physicalId, region }) => {
|
|
6555
6607
|
const name = str$1(physicalId);
|
|
6556
6608
|
if (!name) return void 0;
|
|
@@ -7120,6 +7172,7 @@ const SDK_OVERRIDES = {
|
|
|
7120
7172
|
"AWS::EC2::ClientVpnTargetNetworkAssociation": readEc2ClientVpnTargetNetworkAssociation,
|
|
7121
7173
|
"AWS::DAX::Cluster": readDaxCluster,
|
|
7122
7174
|
"AWS::DAX::ParameterGroup": readDaxParameterGroup,
|
|
7175
|
+
"AWS::ElastiCache::ParameterGroup": readElastiCacheParameterGroup,
|
|
7123
7176
|
"AWS::DAX::SubnetGroup": readDaxSubnetGroup,
|
|
7124
7177
|
"AWS::CloudWatch::AnomalyDetector": readCloudWatchAnomalyDetector,
|
|
7125
7178
|
"AWS::CodeBuild::ReportGroup": readCodeBuildReportGroup,
|
|
@@ -9535,6 +9588,37 @@ const writeDaxParameterGroup = async (ctx, ops) => {
|
|
|
9535
9588
|
ParameterNameValues: values
|
|
9536
9589
|
}));
|
|
9537
9590
|
};
|
|
9591
|
+
const writeElastiCacheParameterGroup = async (ctx, ops) => {
|
|
9592
|
+
const name = str(ctx.physicalId) ?? str(ctx.declared["CacheParameterGroupName"]);
|
|
9593
|
+
if (!name) throw new Error("cannot resolve ElastiCache parameter-group name for revert");
|
|
9594
|
+
const desiredValues = (await desiredModel("AWS::ElastiCache::ParameterGroup", ctx, ops)).Properties ?? {};
|
|
9595
|
+
const modifyKeys = /* @__PURE__ */ new Set();
|
|
9596
|
+
const resetKeys = /* @__PURE__ */ new Set();
|
|
9597
|
+
for (const op of ops) {
|
|
9598
|
+
const segs = op.path.replace(/^\//, "").split("/");
|
|
9599
|
+
if (segs[0] !== "Properties") continue;
|
|
9600
|
+
const key = segs[1]?.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
9601
|
+
if (op.op === "remove") {
|
|
9602
|
+
if (key !== void 0) resetKeys.add(key);
|
|
9603
|
+
} else if (key !== void 0) modifyKeys.add(key);
|
|
9604
|
+
else for (const k of Object.keys(desiredValues)) modifyKeys.add(k);
|
|
9605
|
+
}
|
|
9606
|
+
const c = new ElastiCacheClient({ region: ctx.region });
|
|
9607
|
+
const modify = [...modifyKeys].filter((k) => typeof desiredValues[k] === "string").map((k) => ({
|
|
9608
|
+
ParameterName: k,
|
|
9609
|
+
ParameterValue: desiredValues[k]
|
|
9610
|
+
}));
|
|
9611
|
+
if (modify.length > 0) await c.send(new ModifyCacheParameterGroupCommand({
|
|
9612
|
+
CacheParameterGroupName: name,
|
|
9613
|
+
ParameterNameValues: modify
|
|
9614
|
+
}));
|
|
9615
|
+
const reset = [...resetKeys].map((k) => ({ ParameterName: k }));
|
|
9616
|
+
if (reset.length > 0) await c.send(new ResetCacheParameterGroupCommand({
|
|
9617
|
+
CacheParameterGroupName: name,
|
|
9618
|
+
ResetAllParameters: false,
|
|
9619
|
+
ParameterNameValues: reset
|
|
9620
|
+
}));
|
|
9621
|
+
};
|
|
9538
9622
|
const CLIENT_VPN_SCALAR_PARAMS = new Set([
|
|
9539
9623
|
"Description",
|
|
9540
9624
|
"SplitTunnel",
|
|
@@ -9909,6 +9993,7 @@ const SDK_WRITERS = {
|
|
|
9909
9993
|
"AWS::CodeBuild::ReportGroup": writeCodeBuildReportGroup,
|
|
9910
9994
|
"AWS::DAX::Cluster": writeDaxCluster,
|
|
9911
9995
|
"AWS::DAX::ParameterGroup": writeDaxParameterGroup,
|
|
9996
|
+
"AWS::ElastiCache::ParameterGroup": writeElastiCacheParameterGroup,
|
|
9912
9997
|
"AWS::EC2::ClientVpnEndpoint": writeEc2ClientVpnEndpoint,
|
|
9913
9998
|
"AWS::OpenSearchService::Domain": writeOpenSearchDomain,
|
|
9914
9999
|
"AWS::CloudFront::Distribution": writeCloudFrontDistribution,
|