cdk-real-drift 0.3.8 → 0.3.9

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 CHANGED
@@ -7084,7 +7084,7 @@ const readIamAccessKey = async ({ declared, physicalId, region }) => {
7084
7084
  region,
7085
7085
  ...READ_RETRY
7086
7086
  }).send(new ListAccessKeysCommand({ UserName: userName }))).AccessKeyMetadata ?? []).find((m) => m.AccessKeyId === physicalId);
7087
- if (!meta) return void 0;
7087
+ if (!meta) throw new ResourceGoneError(`AccessKey ${physicalId} absent from user ${userName}`);
7088
7088
  return {
7089
7089
  UserName: userName,
7090
7090
  Status: meta.Status
@@ -8112,8 +8112,12 @@ const readAppSyncApiKey = async ({ physicalId, declared, region }) => {
8112
8112
  if (keyId) k = keys.find((x) => x.id === keyId);
8113
8113
  nextToken = r.nextToken;
8114
8114
  } while (!k && nextToken);
8115
- if (!keyId) k = keys[0];
8116
- if (!k) return void 0;
8115
+ if (keyId) {
8116
+ if (!k) throw new ResourceGoneError(`AppSync ApiKey ${keyId} absent from API ${apiId}`);
8117
+ } else {
8118
+ k = keys[0];
8119
+ if (!k) return void 0;
8120
+ }
8117
8121
  const model = { ApiId: apiId };
8118
8122
  if (k.description !== void 0 && k.description !== "") model.Description = k.description;
8119
8123
  if (k.expires !== void 0) model.Expires = k.expires;
@@ -9017,7 +9021,16 @@ const CC_IDENTIFIER_ADAPTERS = {
9017
9021
  const integrationId = declared.IntegrationId;
9018
9022
  return typeof apiId === "string" && apiId.length > 0 && typeof integrationId === "string" && integrationId.length > 0 ? `${apiId}|${integrationId}|${pid}` : void 0;
9019
9023
  },
9020
- "AWS::GuardDuty::Filter": compositeWith("DetectorId")
9024
+ "AWS::GuardDuty::Filter": compositeWith("DetectorId"),
9025
+ "AWS::Events::Rule": (pid, declared, region, account) => {
9026
+ const bar = pid.lastIndexOf("|");
9027
+ if (bar < 0) return pid;
9028
+ const busName = pid.slice(0, bar);
9029
+ const ruleName = pid.slice(bar + 1);
9030
+ const busArn = declared.EventBusName;
9031
+ if (typeof busArn === "string" && busArn.includes(":event-bus/")) return `${busArn.replace(":event-bus/", ":rule/")}/${ruleName}`;
9032
+ if (region && account) return `arn:${region.startsWith("cn-") ? "aws-cn" : region.startsWith("us-gov-") ? "aws-us-gov" : "aws"}:events:${region}:${account}:rule/${busName}/${ruleName}`;
9033
+ }
9021
9034
  };
9022
9035
  function scalingPolicyComposite(pid, declared) {
9023
9036
  if (pid.includes("|")) return pid;
@@ -9060,7 +9073,7 @@ async function readLive(cc, resource, region, accountId) {
9060
9073
  return { skippedReason: `SDK override (${resourceType}): ${e.name}` };
9061
9074
  }
9062
9075
  try {
9063
- const identifier = CC_IDENTIFIER_ADAPTERS[resourceType]?.(physicalId ?? "", declared) ?? physicalId ?? "";
9076
+ const identifier = CC_IDENTIFIER_ADAPTERS[resourceType]?.(physicalId ?? "", declared, region, accountId) ?? physicalId ?? "";
9064
9077
  const g = await cc.send(new GetResourceCommand({
9065
9078
  TypeName: resourceType,
9066
9079
  Identifier: identifier
@@ -10399,10 +10412,11 @@ const writeDocDbCluster = async (ctx, ops) => {
10399
10412
  let any = false;
10400
10413
  for (const op of ops) {
10401
10414
  const top = op.path.replace(/^\//, "").split("/")[0];
10402
- if (top && DOCDB_CLUSTER_MODIFY_PARAMS.has(top) && desired[top] !== void 0) {
10403
- input[top] = desired[top];
10404
- any = true;
10405
- }
10415
+ if (!top || !DOCDB_CLUSTER_MODIFY_PARAMS.has(top)) continue;
10416
+ if (desired[top] !== void 0) input[top] = desired[top];
10417
+ else if (top === "DeletionProtection") input.DeletionProtection = false;
10418
+ else throw new Error(`DocDB DBCluster ${top} cannot be cleared via ModifyDBCluster (its unset state is AWS-assigned/required, not expressible in a selective modify); update it manually`);
10419
+ any = true;
10406
10420
  }
10407
10421
  if (!any) return;
10408
10422
  await new DocDBClient({ region: ctx.region }).send(new ModifyDBClusterCommand(input));
@@ -10424,10 +10438,11 @@ const writeDocDbInstance = async (ctx, ops) => {
10424
10438
  let any = false;
10425
10439
  for (const op of ops) {
10426
10440
  const top = op.path.replace(/^\//, "").split("/")[0];
10427
- if (top && DOCDB_INSTANCE_MODIFY_PARAMS.has(top) && desired[top] !== void 0) {
10428
- input[top] = desired[top];
10429
- any = true;
10430
- }
10441
+ if (!top || !DOCDB_INSTANCE_MODIFY_PARAMS.has(top)) continue;
10442
+ if (desired[top] !== void 0) input[top] = desired[top];
10443
+ else if (top === "EnablePerformanceInsights") input.EnablePerformanceInsights = false;
10444
+ else throw new Error(`DocDB DBInstance ${top} cannot be cleared via ModifyDBInstance (its unset state is AWS-assigned/required, not expressible in a selective modify); update it manually`);
10445
+ any = true;
10431
10446
  }
10432
10447
  if (!any) return;
10433
10448
  await new DocDBClient({ region: ctx.region }).send(new ModifyDBInstanceCommand(input));
@@ -11070,12 +11085,23 @@ const writeEc2ClientVpnEndpoint = async (ctx, ops) => {
11070
11085
  const input = { ClientVpnEndpointId: id };
11071
11086
  let any = false;
11072
11087
  const tops = new Set(ops.map((op) => op.path.replace(/^\//, "").split("/")[0] ?? ""));
11073
- for (const top of tops) if (CLIENT_VPN_SCALAR_PARAMS.has(top) && desired[top] !== void 0) {
11074
- input[top] = desired[top];
11075
- any = true;
11076
- } else if (top === "ConnectionLogOptions" && desired.ConnectionLogOptions !== void 0) {
11077
- input.ConnectionLogOptions = desired.ConnectionLogOptions;
11078
- any = true;
11088
+ const removed = (field) => ops.some((o) => o.op === "remove" && (o.path.replace(/^\//, "").split("/")[0] ?? "") === field);
11089
+ for (const top of tops) if (CLIENT_VPN_SCALAR_PARAMS.has(top)) {
11090
+ if (desired[top] !== void 0) {
11091
+ input[top] = desired[top];
11092
+ any = true;
11093
+ } else if (removed(top)) {
11094
+ if (top === "Description") input.Description = "";
11095
+ else if (top === "SplitTunnel") input.SplitTunnel = false;
11096
+ else if (top === "DisconnectOnSessionTimeout") input.DisconnectOnSessionTimeout = false;
11097
+ else throw new Error(`EC2 ClientVpnEndpoint ${top} cannot be cleared via ModifyClientVpnEndpoint (its unset state is not expressible in a selective modify); update it manually`);
11098
+ any = true;
11099
+ }
11100
+ } else if (top === "ConnectionLogOptions") {
11101
+ if (desired.ConnectionLogOptions !== void 0) {
11102
+ input.ConnectionLogOptions = desired.ConnectionLogOptions;
11103
+ any = true;
11104
+ } else if (removed("ConnectionLogOptions")) throw new Error("EC2 ClientVpnEndpoint ConnectionLogOptions cannot be cleared via ModifyClientVpnEndpoint (its unset state is not expressible in a selective modify); update it manually");
11079
11105
  } else if (top === "DnsServers") {
11080
11106
  const list = desired.DnsServers;
11081
11107
  input.DnsServers = Array.isArray(list) && list.length > 0 ? {
@@ -11090,7 +11116,7 @@ const writeEc2ClientVpnEndpoint = async (ctx, ops) => {
11090
11116
  input.SecurityGroupIds = list;
11091
11117
  input.VpcId = vpcId;
11092
11118
  any = true;
11093
- }
11119
+ } else if (removed("SecurityGroupIds")) throw new Error("EC2 ClientVpnEndpoint SecurityGroupIds cannot be cleared via ModifyClientVpnEndpoint (an endpoint cannot revert to no security group in a selective modify); update it manually");
11094
11120
  }
11095
11121
  if (!any) return;
11096
11122
  await new EC2Client({ region: ctx.region }).send(new ModifyClientVpnEndpointCommand(input));