cdk-real-drift 0.3.13 → 0.4.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
@@ -698,6 +698,11 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
698
698
  `ses:DescribeReceiptRuleSet`, `ses:DescribeReceiptRule`, `ses:ListReceiptFilters`
699
699
  (the SES inbound receipt-rule family — `ReceiptRuleSet` / `ReceiptRule` /
700
700
  `ReceiptFilter` — has no Cloud Control handlers),
701
+ `acm:DescribeCertificate` + `acm:ListTagsForCertificate` (read an
702
+ `AWS::CertificateManager::Certificate` — the ACM registry type ships no Cloud
703
+ Control read handler, so every cert was silently skipped, including an
704
+ out-of-band `Options.CertificateTransparencyLoggingPreference` flip or an
705
+ out-of-band deletion of a cert an ALB / CloudFront / API domain still references),
701
706
  `glue:GetTable`, `logs:DescribeMetricFilters`, `scheduler:GetSchedule`,
702
707
  `cloudwatch:DescribeAnomalyDetectors` (reads an
703
708
  `AWS::CloudWatch::AnomalyDetector` — NON_PROVISIONABLE, no Cloud Control
package/dist/cli.js CHANGED
@@ -21,6 +21,7 @@ import { DescribeEventBusCommand, EventBridgeClient, ListRulesCommand, PutPermis
21
21
  import { GetPolicyCommand, LambdaClient, ListAliasesCommand as ListAliasesCommand$1, ListEventSourceMappingsCommand, ListFunctionUrlConfigsCommand, ListVersionsByFunctionCommand } from "@aws-sdk/client-lambda";
22
22
  import { DescribeDBClustersCommand, DescribeDBInstancesCommand, RDSClient } from "@aws-sdk/client-rds";
23
23
  import { GetTopicAttributesCommand, ListSubscriptionsByTopicCommand, SNSClient, SetTopicAttributesCommand } from "@aws-sdk/client-sns";
24
+ import { ACMClient, DescribeCertificateCommand, ListTagsForCertificateCommand } from "@aws-sdk/client-acm";
24
25
  import { BudgetsClient, DescribeBudgetCommand } from "@aws-sdk/client-budgets";
25
26
  import { DescribeConfigurationSettingsCommand, ElasticBeanstalkClient, UpdateApplicationCommand, UpdateEnvironmentCommand } from "@aws-sdk/client-elastic-beanstalk";
26
27
  import { CognitoSyncClient, GetCognitoEventsCommand, SetCognitoEventsCommand } from "@aws-sdk/client-cognito-sync";
@@ -4295,7 +4296,10 @@ const CC_ALT_REPRESENTATION = {
4295
4296
  AvailabilityZoneId: "AvailabilityZone",
4296
4297
  AvailabilityZone: "AvailabilityZoneId"
4297
4298
  },
4298
- "AWS::ElasticLoadBalancingV2::LoadBalancer": { SubnetMappings: "Subnets" }
4299
+ "AWS::ElasticLoadBalancingV2::LoadBalancer": {
4300
+ SubnetMappings: "Subnets",
4301
+ Subnets: "SubnetMappings"
4302
+ }
4299
4303
  };
4300
4304
  const SHAPE_ECHO_TWIN = { "AWS::KinesisFirehose::DeliveryStream": { ExtendedS3DestinationConfiguration: "S3DestinationConfiguration" } };
4301
4305
  function twinOverlapEchoes(source, twin) {
@@ -4665,6 +4669,28 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
4665
4669
  };
4666
4670
  }
4667
4671
  }
4672
+ if (resourceType === "AWS::CodeBuild::Project") {
4673
+ const name = declared["Name"];
4674
+ if (typeof name === "string") knownDefPaths = {
4675
+ ...knownDefPaths,
4676
+ "Artifacts.Name": name
4677
+ };
4678
+ }
4679
+ if (resourceType === "AWS::SecretsManager::RotationSchedule") {
4680
+ const expr = declared["RotationRules"]?.["ScheduleExpression"];
4681
+ const m = typeof expr === "string" ? /^rate\((\d+)\s+days?\)$/.exec(expr.trim()) : null;
4682
+ if (m) knownDefPaths = {
4683
+ ...knownDefPaths,
4684
+ "RotationRules.AutomaticallyAfterDays": Number(m[1])
4685
+ };
4686
+ }
4687
+ if (resourceType === "AWS::AmazonMQ::Broker") {
4688
+ const engineType = declared["EngineType"];
4689
+ if (typeof engineType === "string" && engineType.toUpperCase() === "ACTIVEMQ") knownDef = {
4690
+ ...knownDef,
4691
+ StorageType: "EFS"
4692
+ };
4693
+ }
4668
4694
  if (resourceType === "AWS::Lambda::EventSourceMapping") {
4669
4695
  const arn = declared["EventSourceArn"];
4670
4696
  const service = typeof arn === "string" ? arn.split(":")[2] : void 0;
@@ -4983,14 +5009,20 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
4983
5009
  if (nvSubsetSpec?.re.test(d.path)) {
4984
5010
  const liveOnly = alignNameValueSubset(d.stateValue, d.awsValue, nvSubsetSpec);
4985
5011
  if (liveOnly) {
4986
- for (const lo of liveOnly) findings.push({
4987
- tier: "undeclared",
4988
- logicalId,
4989
- resourceType,
4990
- path: `${d.path}[${String(lo[nvSubsetSpec.nameField])}]`,
4991
- actual: lo,
4992
- nested: true
4993
- });
5012
+ for (const lo of liveOnly) {
5013
+ const loRec = lo;
5014
+ const loName = String(loRec[nvSubsetSpec.nameField]);
5015
+ const loValue = loRec[nvSubsetSpec.valueField];
5016
+ const isFirehoseRetriesDefault = resourceType === "AWS::KinesisFirehose::DeliveryStream" && loName === "NumberOfRetries" && loValue === "3";
5017
+ findings.push({
5018
+ tier: isFirehoseRetriesDefault ? "atDefault" : "undeclared",
5019
+ logicalId,
5020
+ resourceType,
5021
+ path: `${d.path}[${loName}]`,
5022
+ actual: lo,
5023
+ nested: true
5024
+ });
5025
+ }
4994
5026
  continue;
4995
5027
  }
4996
5028
  }
@@ -8265,7 +8297,36 @@ const readSesReceiptFilter = async ({ physicalId, declared, region }) => {
8265
8297
  } }
8266
8298
  } };
8267
8299
  };
8300
+ const ACM_DEFAULT_TRANSPARENCY = "ENABLED";
8301
+ const readAcmCertificate = async ({ physicalId, declared, region }) => {
8302
+ const arn = str$1(physicalId);
8303
+ if (!arn || !arn.startsWith("arn:")) return void 0;
8304
+ const c = new ACMClient({
8305
+ region,
8306
+ ...READ_RETRY
8307
+ });
8308
+ const cert = (await c.send(new DescribeCertificateCommand({ CertificateArn: arn }))).Certificate;
8309
+ if (!cert) return void 0;
8310
+ const model = {};
8311
+ if (str$1(cert.DomainName)) model.DomainName = cert.DomainName;
8312
+ if (str$1(cert.KeyAlgorithm)) model.KeyAlgorithm = cert.KeyAlgorithm;
8313
+ const declaresSans = Array.isArray(declared.SubjectAlternativeNames) && declared.SubjectAlternativeNames.length > 0;
8314
+ const sans = (cert.SubjectAlternativeNames ?? []).filter((s) => str$1(s) !== void 0);
8315
+ if (declaresSans && sans.length > 0) model.SubjectAlternativeNames = sans;
8316
+ const pref = str$1(cert.Options?.CertificateTransparencyLoggingPreference);
8317
+ const declaresOptions = declared.Options !== void 0 && declared.Options !== null && typeof declared.Options === "object";
8318
+ if (pref && (declaresOptions || pref !== ACM_DEFAULT_TRANSPARENCY)) model.Options = { CertificateTransparencyLoggingPreference: pref };
8319
+ try {
8320
+ const tags = ((await c.send(new ListTagsForCertificateCommand({ CertificateArn: arn }))).Tags ?? []).filter((tag) => str$1(tag.Key) !== void 0).map((tag) => ({
8321
+ Key: tag.Key,
8322
+ Value: tag.Value ?? ""
8323
+ }));
8324
+ if (tags.length > 0) model.Tags = tags;
8325
+ } catch {}
8326
+ return model;
8327
+ };
8268
8328
  const SDK_OVERRIDES = {
8329
+ "AWS::CertificateManager::Certificate": readAcmCertificate,
8269
8330
  "AWS::SES::ReceiptRuleSet": readSesReceiptRuleSet,
8270
8331
  "AWS::SES::ReceiptRule": readSesReceiptRule,
8271
8332
  "AWS::SES::ReceiptFilter": readSesReceiptFilter,