cdk-real-drift 0.14.1 → 0.16.0

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 CHANGED
@@ -878,6 +878,15 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
878
878
  resource name, and `ListTagsForResource` reads each resource's tags, which the
879
879
  `Get*` responses omit — without it a declared `Tags` false-flagged as drift on
880
880
  every tagged MediaConvert resource),
881
+ `config:DescribeConfigurationRecorders` + `config:DescribeDeliveryChannels`
882
+ (read an `AWS::Config::ConfigurationRecorder` /
883
+ `AWS::Config::DeliveryChannel` — the account/region compliance-baseline
884
+ SINGLETONS a large fraction of accounts deploy, NON_PROVISIONABLE with Cloud
885
+ Control `UnsupportedActionException`; the physical id IS the recorder / channel
886
+ name, and the reader projects the CFn-declarable surface — the recorder's
887
+ undeclared `RecordingGroup.RecordingStrategy` mirror and `RecordingMode` default
888
+ fold to atDefault, so a fresh recorder is clean while a recording-scope change
889
+ still surfaces),
881
890
  `ssm:DescribeParameters` (supplements the Cloud Control read of an
882
891
  `AWS::SSM::Parameter` with its writeOnly `Description` / `AllowedPattern`),
883
892
  `elasticache:DescribeReplicationGroups` + `elasticache:DescribeCacheClusters`
@@ -1112,6 +1121,10 @@ Description / State / ExecutionRoleArn / PolicyDetails shape is re-supplied in
1112
1121
  place, since Cloud Control has no handler for the type),
1113
1122
  `docdb:ModifyDBCluster` / `ModifyDBInstance`,
1114
1123
  `config:DescribeConfigRules` / `config:PutConfigRule`,
1124
+ `config:PutConfigurationRecorder` (reverts an
1125
+ `AWS::Config::ConfigurationRecorder` — a whole-recorder upsert re-supplying the
1126
+ declared RecordingGroup / RecordingMode / RoleARN, since Cloud Control cannot
1127
+ write the type),
1115
1128
  `ecs:UpdateService` (reverts an `AWS::ECS::Service` `ServiceConnectConfiguration` /
1116
1129
  `VolumeConfigurations` drift — the whole writeOnly prop is re-supplied, since Cloud
1117
1130
  Control cannot sub-path patch it),
package/dist/cli.js CHANGED
@@ -49,6 +49,7 @@ import { DLMClient, GetLifecyclePolicyCommand, UpdateLifecyclePolicyCommand } fr
49
49
  import { DatabaseMigrationServiceClient, DescribeEndpointsCommand, DescribeReplicationInstancesCommand, DescribeReplicationSubnetGroupsCommand, DescribeReplicationTasksCommand, ListTagsForResourceCommand as ListTagsForResourceCommand$2 } from "@aws-sdk/client-database-migration-service";
50
50
  import { DescribeResourceCommand, EntityNotFoundException, LakeFormationClient } from "@aws-sdk/client-lakeformation";
51
51
  import { GetJobTemplateCommand, GetQueueCommand, ListTagsForResourceCommand as ListTagsForResourceCommand$3, MediaConvertClient } from "@aws-sdk/client-mediaconvert";
52
+ import { ConfigServiceClient, DescribeConfigRulesCommand, DescribeConfigurationRecordersCommand, DescribeDeliveryChannelsCommand, PutConfigRuleCommand, PutConfigurationRecorderCommand } from "@aws-sdk/client-config-service";
52
53
  import { DescribeConfigurationCommand, DescribeConfigurationRevisionCommand, KafkaClient, UpdateConfigurationCommand } from "@aws-sdk/client-kafka";
53
54
  import { GetWorkgroupCommand, RedshiftServerlessClient } from "@aws-sdk/client-redshift-serverless";
54
55
  import { BuildBotLocaleCommand, CreateIntentCommand, CreateSlotCommand, CreateSlotTypeCommand, DeleteIntentCommand, DeleteSlotCommand, DeleteSlotTypeCommand, DescribeBotLocaleCommand, DescribeIntentCommand, DescribeSlotCommand, DescribeSlotTypeCommand, LexModelsV2Client, ListBotLocalesCommand, ListIntentsCommand, ListSlotTypesCommand, ListSlotsCommand, UpdateBotLocaleCommand, UpdateIntentCommand, UpdateSlotCommand, UpdateSlotTypeCommand } from "@aws-sdk/client-lex-models-v2";
@@ -63,7 +64,6 @@ import { MultiSelectPrompt, Prompt, isCancel as isCancel$1 } from "@clack/core";
63
64
  import { CloudFrontClient, GetDistributionConfigCommand, UpdateDistributionCommand } from "@aws-sdk/client-cloudfront";
64
65
  import { DescribeSignalingChannelCommand, DescribeStreamCommand, KinesisVideoClient, UpdateDataRetentionCommand, UpdateSignalingChannelCommand, UpdateStreamStorageConfigurationCommand } from "@aws-sdk/client-kinesis-video";
65
66
  import { GetWebACLCommand, UpdateWebACLCommand, WAFV2Client } from "@aws-sdk/client-wafv2";
66
- import { ConfigServiceClient, DescribeConfigRulesCommand, PutConfigRuleCommand } from "@aws-sdk/client-config-service";
67
67
 
68
68
  //#region src/exit.ts
69
69
  function drain(stream) {
@@ -2066,6 +2066,7 @@ const KNOWN_DEFAULTS = {
2066
2066
  Description: ""
2067
2067
  },
2068
2068
  "AWS::SageMaker::DataQualityJobDefinition": { StoppingCondition: { MaxRuntimeInSeconds: 3600 } },
2069
+ "AWS::Config::ConfigurationRecorder": { RecordingMode: { RecordingFrequency: "CONTINUOUS" } },
2069
2070
  "AWS::IAM::ServerCertificate": { Path: "/" },
2070
2071
  "AWS::CertificateManager::Certificate": { KeyAlgorithm: "RSA_2048" },
2071
2072
  "AWS::AppRunner::Service": {
@@ -6115,6 +6116,16 @@ function dynamoGsiWarmThroughputAtDefault(resourceType, path, value, live, decla
6115
6116
  const declaredGsi = gsiByName(declared, m[1]);
6116
6117
  return liveGsi !== void 0 && deepEqual(value, warmThroughputDefault(liveGsi.ProvisionedThroughput)) || declaredGsi !== void 0 && deepEqual(value, warmThroughputDefault(declaredGsi.ProvisionedThroughput));
6117
6118
  }
6119
+ function configRecordingStrategyAtDefault(resourceType, schemaPath, value, live) {
6120
+ if (resourceType !== "AWS::Config::ConfigurationRecorder") return false;
6121
+ if (schemaPath !== "RecordingGroup.RecordingStrategy") return false;
6122
+ const rg = live.RecordingGroup;
6123
+ if (!isNestedObject(rg)) return false;
6124
+ const group = rg;
6125
+ const excl = isNestedObject(group.ExclusionByResourceTypes) ? group.ExclusionByResourceTypes.ResourceTypes : void 0;
6126
+ const useOnly = group.AllSupported === true ? "ALL_SUPPORTED_RESOURCE_TYPES" : Array.isArray(excl) && excl.length > 0 ? "EXCLUSION_BY_RESOURCE_TYPES" : Array.isArray(group.ResourceTypes) && group.ResourceTypes.length > 0 ? "INCLUSION_BY_RESOURCE_TYPES" : void 0;
6127
+ return useOnly !== void 0 && deepEqual(value, { UseOnly: useOnly });
6128
+ }
6118
6129
  const CLB_DEFAULT_SSL_POLICY_NAME = "ELBSecurityPolicy-2016-08";
6119
6130
  function clbDefaultSslPoliciesAtDefault(resourceType, key, value) {
6120
6131
  if (resourceType !== "AWS::ElasticLoadBalancing::LoadBalancer" || key !== "Policies") return false;
@@ -6994,7 +7005,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6994
7005
  const parentKey = (path.split(".").pop() ?? "").replace(/\[.*$/, "");
6995
7006
  if (!isObjectForm || /tags$/i.test(parentKey)) return;
6996
7007
  }
6997
- const tier = schemaPath in schema.defaultPaths && matchesKnownDefault(value, schema.defaultPaths[schemaPath]) || schemaPath in knownDefPaths && matchesKnownDefault(value, knownDefPaths[schemaPath]) || (KNOWN_DEFAULT_ONE_OF_PATHS[resourceType]?.[schemaPath]?.some((d) => matchesKnownDefault(value, d)) ?? false) || VALUE_INDEPENDENT_DEFAULT_NESTED_PATHS[resourceType]?.has(schemaPath) && !(schemaPath in knownDefPaths) || dynamoGsiWarmThroughputAtDefault(resourceType, path, value, live, declared) || resourceType === "AWS::Events::EventBusPolicy" && schemaPath === "Statement.*.Sid" && typeof value === "string" && value === declared["StatementId"] ? "atDefault" : generatedPaths.includes(schemaPath) && isPhysicalIdSegment(value, physicalId) || generatedNestedPaths?.has(schemaPath) && !(schemaPath in knownDefPaths) && (!(schemaPath in (MANAGED_KEY_ALIAS_PATHS[resourceType] ?? {})) || shouldFoldManagedServiceKey(resourceType, schemaPath, value, opts.kmsAliasTargets)) ? "generated" : "undeclared";
7008
+ const tier = schemaPath in schema.defaultPaths && matchesKnownDefault(value, schema.defaultPaths[schemaPath]) || schemaPath in knownDefPaths && matchesKnownDefault(value, knownDefPaths[schemaPath]) || (KNOWN_DEFAULT_ONE_OF_PATHS[resourceType]?.[schemaPath]?.some((d) => matchesKnownDefault(value, d)) ?? false) || VALUE_INDEPENDENT_DEFAULT_NESTED_PATHS[resourceType]?.has(schemaPath) && !(schemaPath in knownDefPaths) || dynamoGsiWarmThroughputAtDefault(resourceType, path, value, live, declared) || resourceType === "AWS::Events::EventBusPolicy" && schemaPath === "Statement.*.Sid" && typeof value === "string" && value === declared["StatementId"] || configRecordingStrategyAtDefault(resourceType, schemaPath, value, live) ? "atDefault" : generatedPaths.includes(schemaPath) && isPhysicalIdSegment(value, physicalId) || generatedNestedPaths?.has(schemaPath) && !(schemaPath in knownDefPaths) && (!(schemaPath in (MANAGED_KEY_ALIAS_PATHS[resourceType] ?? {})) || shouldFoldManagedServiceKey(resourceType, schemaPath, value, opts.kmsAliasTargets)) ? "generated" : "undeclared";
6998
7009
  const freeFormKey = tier === "undeclared" && underFreeFormMap(schemaPath);
6999
7010
  findings.push({
7000
7011
  tier,
@@ -12718,6 +12729,59 @@ const readAcmCertificate = async ({ physicalId, declared, region }) => {
12718
12729
  }
12719
12730
  return model;
12720
12731
  };
12732
+ const readConfigConfigurationRecorder = async ({ physicalId, region }) => {
12733
+ const name = str$1(physicalId);
12734
+ if (!name) return void 0;
12735
+ const r = (await new ConfigServiceClient({
12736
+ region,
12737
+ ...READ_RETRY
12738
+ }).send(new DescribeConfigurationRecordersCommand({ ConfigurationRecorderNames: [name] }))).ConfigurationRecorders?.[0];
12739
+ if (!r) throw new ResourceGoneError(`Config ConfigurationRecorder ${name} absent`);
12740
+ const model = {};
12741
+ if (str$1(r.name)) model.Name = r.name;
12742
+ if (str$1(r.roleARN)) model.RoleARN = r.roleARN;
12743
+ if (r.recordingGroup) {
12744
+ const g = r.recordingGroup;
12745
+ const rg = {};
12746
+ if (typeof g.allSupported === "boolean") rg.AllSupported = g.allSupported;
12747
+ if (typeof g.includeGlobalResourceTypes === "boolean") rg.IncludeGlobalResourceTypes = g.includeGlobalResourceTypes;
12748
+ if (Array.isArray(g.resourceTypes)) rg.ResourceTypes = g.resourceTypes;
12749
+ const excl = g.exclusionByResourceTypes?.resourceTypes;
12750
+ if (Array.isArray(excl) && excl.length > 0) rg.ExclusionByResourceTypes = { ResourceTypes: excl };
12751
+ if (str$1(g.recordingStrategy?.useOnly)) rg.RecordingStrategy = { UseOnly: g.recordingStrategy?.useOnly };
12752
+ model.RecordingGroup = rg;
12753
+ }
12754
+ if (r.recordingMode) {
12755
+ const m = r.recordingMode;
12756
+ const rm = {};
12757
+ if (str$1(m.recordingFrequency)) rm.RecordingFrequency = m.recordingFrequency;
12758
+ if (Array.isArray(m.recordingModeOverrides) && m.recordingModeOverrides.length > 0) rm.RecordingModeOverrides = m.recordingModeOverrides.map((o) => ({
12759
+ ResourceTypes: o.resourceTypes,
12760
+ RecordingFrequency: o.recordingFrequency,
12761
+ ...str$1(o.description) ? { Description: o.description } : {}
12762
+ }));
12763
+ if (Object.keys(rm).length > 0) model.RecordingMode = rm;
12764
+ }
12765
+ return model;
12766
+ };
12767
+ const readConfigDeliveryChannel = async ({ physicalId, region }) => {
12768
+ const name = str$1(physicalId);
12769
+ if (!name) return void 0;
12770
+ const d = (await new ConfigServiceClient({
12771
+ region,
12772
+ ...READ_RETRY
12773
+ }).send(new DescribeDeliveryChannelsCommand({ DeliveryChannelNames: [name] }))).DeliveryChannels?.[0];
12774
+ if (!d) throw new ResourceGoneError(`Config DeliveryChannel ${name} absent`);
12775
+ const model = {};
12776
+ if (str$1(d.name)) model.Name = d.name;
12777
+ if (str$1(d.s3BucketName)) model.S3BucketName = d.s3BucketName;
12778
+ if (str$1(d.s3KeyPrefix)) model.S3KeyPrefix = d.s3KeyPrefix;
12779
+ if (str$1(d.s3KmsKeyArn)) model.S3KmsKeyArn = d.s3KmsKeyArn;
12780
+ if (str$1(d.snsTopicARN)) model.SnsTopicARN = d.snsTopicARN;
12781
+ const freq = d.configSnapshotDeliveryProperties?.deliveryFrequency;
12782
+ if (str$1(freq)) model.ConfigSnapshotDeliveryProperties = { DeliveryFrequency: freq };
12783
+ return model;
12784
+ };
12721
12785
  const SDK_OVERRIDES = {
12722
12786
  "AWS::CertificateManager::Certificate": readAcmCertificate,
12723
12787
  "AWS::SES::ReceiptRuleSet": readSesReceiptRuleSet,
@@ -12769,7 +12833,9 @@ const SDK_OVERRIDES = {
12769
12833
  "AWS::SageMaker::EndpointConfig": readSageMakerEndpointConfig,
12770
12834
  "AWS::SageMaker::MonitoringSchedule": readSageMakerMonitoringSchedule,
12771
12835
  "AWS::Logs::MetricFilter": readMetricFilter,
12772
- "AWS::Scheduler::Schedule": readSchedulerSchedule
12836
+ "AWS::Scheduler::Schedule": readSchedulerSchedule,
12837
+ "AWS::Config::ConfigurationRecorder": readConfigConfigurationRecorder,
12838
+ "AWS::Config::DeliveryChannel": readConfigDeliveryChannel
12773
12839
  };
12774
12840
  const supplementSsmParameter = async ({ physicalId, declared, region }) => {
12775
12841
  const name = str$1(declared.Name) ?? str$1(physicalId);
@@ -17004,6 +17070,45 @@ const writeConfigRuleInputParameters = async (ctx, ops) => {
17004
17070
  InputParameters: configInputParametersString(op.value)
17005
17071
  } }));
17006
17072
  };
17073
+ const writeConfigConfigurationRecorder = async (ctx, ops) => {
17074
+ const desired = await desiredModel("AWS::Config::ConfigurationRecorder", ctx, ops);
17075
+ const name = str(desired.Name) ?? str(ctx.physicalId);
17076
+ const roleARN = str(desired.RoleARN);
17077
+ if (!name) throw new Error("cannot resolve Config recorder name for revert");
17078
+ if (!roleARN) throw new Error("cannot resolve Config recorder RoleARN for revert");
17079
+ const recorder = {
17080
+ name,
17081
+ roleARN
17082
+ };
17083
+ const rg = desired.RecordingGroup;
17084
+ if (rg) {
17085
+ const group = {};
17086
+ if (typeof rg.AllSupported === "boolean") group.allSupported = rg.AllSupported;
17087
+ if (typeof rg.IncludeGlobalResourceTypes === "boolean") group.includeGlobalResourceTypes = rg.IncludeGlobalResourceTypes;
17088
+ if (Array.isArray(rg.ResourceTypes)) group.resourceTypes = rg.ResourceTypes;
17089
+ const excl = rg.ExclusionByResourceTypes;
17090
+ if (excl && Array.isArray(excl.ResourceTypes) && excl.ResourceTypes.length > 0) group.exclusionByResourceTypes = { resourceTypes: excl.ResourceTypes };
17091
+ recorder.recordingGroup = group;
17092
+ }
17093
+ const rm = desired.RecordingMode;
17094
+ if (rm && str(rm.RecordingFrequency)) {
17095
+ const mode = { recordingFrequency: rm.RecordingFrequency };
17096
+ const overrides = rm.RecordingModeOverrides;
17097
+ if (Array.isArray(overrides) && overrides.length > 0) mode.recordingModeOverrides = overrides.map((o) => {
17098
+ const oo = o;
17099
+ return {
17100
+ resourceTypes: oo.ResourceTypes,
17101
+ recordingFrequency: oo.RecordingFrequency,
17102
+ ...str(oo.Description) ? { description: oo.Description } : {}
17103
+ };
17104
+ });
17105
+ recorder.recordingMode = mode;
17106
+ }
17107
+ await new ConfigServiceClient({
17108
+ region: ctx.region,
17109
+ ...CLIENT_TIMEOUTS
17110
+ }).send(new PutConfigurationRecorderCommand({ ConfigurationRecorder: recorder }));
17111
+ };
17007
17112
  const OS_UPDATABLE_OPTIONS = new Set([
17008
17113
  "ClusterConfig",
17009
17114
  "EBSOptions",
@@ -17997,7 +18102,8 @@ const SDK_WRITERS = {
17997
18102
  "AWS::SQS::QueuePolicy": writeSqsQueuePolicy,
17998
18103
  "AWS::Events::EventBusPolicy": writeEventBusPolicy,
17999
18104
  "AWS::IAM::Policy": writeIamPolicy,
18000
- "AWS::IAM::ManagedPolicy": writeIamManagedPolicy
18105
+ "AWS::IAM::ManagedPolicy": writeIamManagedPolicy,
18106
+ "AWS::Config::ConfigurationRecorder": writeConfigConfigurationRecorder
18001
18107
  };
18002
18108
  const SDK_PROP_WRITERS = {
18003
18109
  "AWS::Cognito::IdentityPool": { CognitoEvents: writeCognitoIdentityPoolEvents },