cdk-real-drift 0.4.6 → 0.4.7

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
@@ -11,7 +11,7 @@ import { KMSClient, ListAliasesCommand } from "@aws-sdk/client-kms";
11
11
  import { APIGatewayClient, GetAuthorizersCommand, GetGatewayResponsesCommand, GetModelsCommand, GetRequestValidatorsCommand, GetResourcesCommand, UpdateIntegrationCommand, UpdateIntegrationResponseCommand, UpdateMethodResponseCommand, UpdateRestApiCommand } from "@aws-sdk/client-api-gateway";
12
12
  import { AppConfigClient, ListConfigurationProfilesCommand, ListEnvironmentsCommand } from "@aws-sdk/client-appconfig";
13
13
  import { AppSyncClient, ListApiKeysCommand, ListDataSourcesCommand, ListFunctionsCommand, ListResolversCommand, ListTypesCommand } from "@aws-sdk/client-appsync";
14
- import { ApiGatewayV2Client, GetAuthorizersCommand as GetAuthorizersCommand$1, GetIntegrationsCommand, GetRoutesCommand, GetStagesCommand, UpdateStageCommand } from "@aws-sdk/client-apigatewayv2";
14
+ import { ApiGatewayV2Client, DeleteAccessLogSettingsCommand, DeleteRouteSettingsCommand, GetAuthorizersCommand as GetAuthorizersCommand$1, GetIntegrationsCommand, GetRoutesCommand, GetStagesCommand, UpdateStageCommand } from "@aws-sdk/client-apigatewayv2";
15
15
  import { CloudWatchLogsClient, DescribeMetricFiltersCommand, DescribeSubscriptionFiltersCommand, PutBearerTokenAuthenticationCommand, PutMetricFilterCommand } from "@aws-sdk/client-cloudwatch-logs";
16
16
  import { CognitoIdentityProviderClient, ListGroupsCommand, ListResourceServersCommand, ListUserPoolClientsCommand } from "@aws-sdk/client-cognito-identity-provider";
17
17
  import { DescribeAddressesCommand, DescribeClientVpnAuthorizationRulesCommand, DescribeClientVpnEndpointsCommand, DescribeClientVpnTargetNetworksCommand, DescribeLaunchTemplateVersionsCommand, DescribeNetworkAclsCommand, DescribeRouteTablesCommand, DescribeSubnetsCommand, EC2Client, ModifyClientVpnEndpointCommand } from "@aws-sdk/client-ec2";
@@ -11808,16 +11808,46 @@ const writeApiGatewayV2Stage = async (ctx, ops) => {
11808
11808
  if (!apiId || !stageName) throw new Error("cannot resolve ApiId|StageName for ApiGatewayV2 Stage revert");
11809
11809
  const desired = applyOps({ ...ctx.declared }, ops);
11810
11810
  const touched = new Set(ops.map((o) => o.path.replace(/^\//, "").split("/")[0]).filter((p) => !!p));
11811
+ const isCleared = (field) => desired[field] === void 0 && ops.some((o) => o.op === "remove" && o.path.replace(/^\//, "").split("/")[0] === field);
11812
+ const clearedSubKeys = (field) => {
11813
+ const keys = /* @__PURE__ */ new Set();
11814
+ for (const o of ops) {
11815
+ if (o.op !== "remove") continue;
11816
+ const segs = o.path.replace(/^\//, "").split("/");
11817
+ if (segs[0] !== field) continue;
11818
+ if (segs.length >= 2 && segs[1]) keys.add(segs[1]);
11819
+ else for (const k of Object.keys(asRecord(o.prior))) keys.add(k);
11820
+ }
11821
+ return [...keys];
11822
+ };
11823
+ const client = new ApiGatewayV2Client({ region: ctx.region });
11824
+ if (touched.has("AccessLogSettings") && isCleared("AccessLogSettings")) await client.send(new DeleteAccessLogSettingsCommand({
11825
+ ApiId: apiId,
11826
+ StageName: stageName
11827
+ }));
11828
+ if (touched.has("RouteSettings") && isCleared("RouteSettings")) for (const routeKey of clearedSubKeys("RouteSettings")) await client.send(new DeleteRouteSettingsCommand({
11829
+ ApiId: apiId,
11830
+ StageName: stageName,
11831
+ RouteKey: routeKey
11832
+ }));
11811
11833
  const input = {
11812
11834
  ApiId: apiId,
11813
11835
  StageName: stageName
11814
11836
  };
11815
11837
  for (const p of touched) {
11816
11838
  if (!APIGWV2_STAGE_UPDATE_FIELDS.has(p)) continue;
11839
+ if (p === "AccessLogSettings" && isCleared("AccessLogSettings")) continue;
11840
+ if (p === "RouteSettings" && isCleared("RouteSettings")) continue;
11841
+ if (p === "StageVariables" && isCleared("StageVariables")) {
11842
+ const tombstones = {};
11843
+ for (const k of clearedSubKeys("StageVariables")) tombstones[k] = "";
11844
+ if (Object.keys(tombstones).length > 0) input.StageVariables = tombstones;
11845
+ continue;
11846
+ }
11847
+ if (isCleared(p)) continue;
11817
11848
  input[p] = desired[p];
11818
11849
  }
11819
- if (Object.keys(input).length <= 2) return;
11820
- await new ApiGatewayV2Client({ region: ctx.region }).send(new UpdateStageCommand(input));
11850
+ if (Object.keys(input).length > 2) await client.send(new UpdateStageCommand(input));
11821
11851
  };
11822
11852
  const writeApiGatewayRestApiPolicy = async (ctx) => {
11823
11853
  const restApiId = str(ctx.physicalId) ?? str(ctx.declared["RestApiId"]);