cdk-real-drift 0.12.87 → 0.12.89

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
@@ -295,6 +295,8 @@ needs `--remove-unrecorded`).
295
295
  - **RDS**: database cluster instances
296
296
  - **S3**: bucket resource policies (an out-of-band `put-bucket-policy` on a bucket
297
297
  with no declared `AWS::S3::BucketPolicy`)
298
+ - **SQS**: queue access policies (an out-of-band `set-queue-attributes Policy` on a
299
+ queue with no declared `AWS::SQS::QueuePolicy`)
298
300
 
299
301
  </details>
300
302
 
@@ -1014,6 +1016,10 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
1014
1016
  override-reader permission above — here it enumerates a bucket's out-of-band
1015
1017
  resource policy as a child `AWS::S3::BucketPolicy`, so it is required for the
1016
1018
  `added` tier too; `NoSuchBucketPolicy` is the normal no-policy case)
1019
+ - `AWS::SQS::Queue`: `sqs:GetQueueAttributes` (enumerates a queue's out-of-band
1020
+ access policy as a child `AWS::SQS::QueuePolicy`; a queue with no policy simply
1021
+ returns no `Policy` attribute). Reverting a detected one also needs
1022
+ `sqs:SetQueueAttributes` (the SDK deleter clears the `Policy`).
1017
1023
 
1018
1024
  The `added` tier also needs `cloudformation:DescribeStackResources` (grouped with
1019
1025
  the other CloudFormation actions above): before flagging a live child as
package/dist/cli.js CHANGED
@@ -30,6 +30,7 @@ import { DescribeDomainConfigCommand, DescribeDomainsCommand, ListDomainNamesCom
30
30
  import { ChangeResourceRecordSetsCommand, ListResourceRecordSetsCommand, Route53Client } from "@aws-sdk/client-route-53";
31
31
  import { DeleteBucketPolicyCommand, GetBucketPolicyCommand, GetObjectCommand, PutBucketPolicyCommand, S3Client } from "@aws-sdk/client-s3";
32
32
  import { GetTopicAttributesCommand, ListSubscriptionsByTopicCommand, SNSClient, SetTopicAttributesCommand } from "@aws-sdk/client-sns";
33
+ import { GetQueueAttributesCommand, SQSClient, SetQueueAttributesCommand } from "@aws-sdk/client-sqs";
33
34
  import { ACMClient, DescribeCertificateCommand, ListTagsForCertificateCommand } from "@aws-sdk/client-acm";
34
35
  import { BudgetsClient, DescribeBudgetCommand } from "@aws-sdk/client-budgets";
35
36
  import { DescribeConfigurationSettingsCommand, ElasticBeanstalkClient, UpdateApplicationCommand, UpdateApplicationResourceLifecycleCommand, UpdateEnvironmentCommand } from "@aws-sdk/client-elastic-beanstalk";
@@ -53,7 +54,6 @@ import { GetScheduleCommand, SchedulerClient } from "@aws-sdk/client-scheduler";
53
54
  import { DescribeReceiptRuleCommand, DescribeReceiptRuleSetCommand, ListReceiptFiltersCommand, SESClient, UpdateReceiptRuleCommand } from "@aws-sdk/client-ses";
54
55
  import { DescribeEndpointConfigCommand, ListTagsCommand as ListTagsCommand$1, SageMakerClient } from "@aws-sdk/client-sagemaker";
55
56
  import { GetNamespaceCommand, GetServiceCommand, ListTagsForResourceCommand as ListTagsForResourceCommand$4, ServiceDiscoveryClient, UpdateHttpNamespaceCommand } from "@aws-sdk/client-servicediscovery";
56
- import { GetQueueAttributesCommand, SQSClient, SetQueueAttributesCommand } from "@aws-sdk/client-sqs";
57
57
  import { createHash } from "node:crypto";
58
58
  import { S_BAR, S_BAR_END, S_BAR_START, S_CHECKBOX_INACTIVE, S_CHECKBOX_SELECTED, confirm, isCancel, select, spinner } from "@clack/prompts";
59
59
  import pc from "picocolors";
@@ -2517,6 +2517,7 @@ const KNOWN_DEFAULTS = {
2517
2517
  ManageMasterUserPassword: false,
2518
2518
  MultiAZ: false,
2519
2519
  StorageEncrypted: false,
2520
+ BackupRetentionPeriod: 1,
2520
2521
  CACertificateIdentifier: "rds-ca-rsa2048-g1"
2521
2522
  },
2522
2523
  "AWS::RDS::DBCluster": {
@@ -3124,7 +3125,7 @@ const CONTEXT_ARN_DEFAULTS = {
3124
3125
  };
3125
3126
  const ENGINE_DEFAULTS = {
3126
3127
  "AWS::RDS::DBInstance": {
3127
- StorageType: (e) => e.startsWith("aurora") ? "aurora" : void 0,
3128
+ StorageType: (e) => e.startsWith("aurora") ? "aurora" : "gp2",
3128
3129
  AllocatedStorage: (e) => e.startsWith("aurora") ? 1 : void 0,
3129
3130
  Port: rdsDefaultPort,
3130
3131
  LicenseModel: rdsDefaultLicense
@@ -3367,6 +3368,7 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
3367
3368
  "AWS::ApiGateway::Authorizer": new Set(["AuthType"]),
3368
3369
  "AWS::RDS::DBCluster": new Set([
3369
3370
  "KmsKeyId",
3371
+ "EngineVersion",
3370
3372
  "PerformanceInsightsKmsKeyId",
3371
3373
  "AvailabilityZones",
3372
3374
  "PreferredMaintenanceWindow",
@@ -3375,6 +3377,7 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
3375
3377
  ]),
3376
3378
  "AWS::RDS::DBInstance": new Set([
3377
3379
  "KmsKeyId",
3380
+ "EngineVersion",
3378
3381
  "PerformanceInsightsKMSKeyId",
3379
3382
  "AvailabilityZone",
3380
3383
  "PreferredMaintenanceWindow",
@@ -3423,7 +3426,11 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
3423
3426
  "AWS::EC2::Instance": new Set([
3424
3427
  "PrivateIpAddress",
3425
3428
  "CpuOptions",
3426
- "SubnetId"
3429
+ "SubnetId",
3430
+ "AvailabilityZone",
3431
+ "SecurityGroups",
3432
+ "Volumes",
3433
+ "BlockDeviceMappings"
3427
3434
  ]),
3428
3435
  "AWS::EC2::NetworkInterface": new Set(["PrivateIpAddress", "PrivateIpAddresses"]),
3429
3436
  "AWS::EC2::Volume": new Set(["KmsKeyId", "AvailabilityZoneId"]),
@@ -7138,6 +7145,17 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7138
7145
  });
7139
7146
  continue;
7140
7147
  }
7148
+ if (resourceType === "AWS::EC2::Instance" && k === "NetworkInterfaces" && Array.isArray(v)) {
7149
+ const allPrimary = v.every((el) => el != null && typeof el === "object" && String(el.DeviceIndex) === "0");
7150
+ findings.push({
7151
+ tier: allPrimary ? "atDefault" : "undeclared",
7152
+ logicalId,
7153
+ resourceType,
7154
+ path: k,
7155
+ actual: v
7156
+ });
7157
+ continue;
7158
+ }
7141
7159
  const ctxKind = CONTEXT_DEFAULTS[resourceType]?.[k];
7142
7160
  if (ctxKind !== void 0 && opts.region !== void 0) {
7143
7161
  if (deepEqual(v, ctxKind === "region" ? opts.region : [opts.region])) {
@@ -7417,6 +7435,7 @@ function lambdaFunctionRefMatches(declaredValue, ...candidates) {
7417
7435
  }
7418
7436
  const CHILD_ENUMERATORS = {
7419
7437
  "AWS::S3::Bucket": enumerateS3BucketChildren,
7438
+ "AWS::SQS::Queue": enumerateSqsQueueChildren,
7420
7439
  "AWS::ApiGateway::RestApi": enumerateRestApiChildren,
7421
7440
  "AWS::ApiGatewayV2::Api": enumerateHttpApiChildren,
7422
7441
  "AWS::SNS::Topic": enumerateSnsTopicChildren,
@@ -8435,6 +8454,57 @@ async function enumerateS3BucketChildren(ctx) {
8435
8454
  livePolicy
8436
8455
  });
8437
8456
  }
8457
+ function diffSqsQueuePolicy(input) {
8458
+ if (input.hasDeclaredPolicy) return [];
8459
+ if (!input.livePolicy) return [];
8460
+ return [{
8461
+ resourceType: "AWS::SQS::QueuePolicy",
8462
+ identifier: input.queueUrl,
8463
+ siblingLookupId: input.queueUrl,
8464
+ label: `queue policy ${input.queueUrl}`,
8465
+ live: {
8466
+ Queues: [input.queueUrl],
8467
+ PolicyDocument: input.livePolicy
8468
+ }
8469
+ }];
8470
+ }
8471
+ async function readSqsQueuePolicyDocument(client, queueUrl) {
8472
+ const policyJson = (await client.send(new GetQueueAttributesCommand({
8473
+ QueueUrl: queueUrl,
8474
+ AttributeNames: ["Policy"]
8475
+ }))).Attributes?.Policy;
8476
+ if (!policyJson) return void 0;
8477
+ let parsed;
8478
+ try {
8479
+ parsed = JSON.parse(policyJson);
8480
+ } catch {
8481
+ return;
8482
+ }
8483
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
8484
+ }
8485
+ async function enumerateSqsQueueChildren(ctx) {
8486
+ const { parent, desired, region } = ctx;
8487
+ const queueUrl = parent.physicalId;
8488
+ if (!queueUrl) return [];
8489
+ let hasDeclaredPolicy = false;
8490
+ for (const r of desired.resources) {
8491
+ if (r.resourceType !== "AWS::SQS::QueuePolicy") continue;
8492
+ const queues = r.declared.Queues;
8493
+ if (Array.isArray(queues)) {
8494
+ if (queues.some((q) => q === queueUrl)) hasDeclaredPolicy = true;
8495
+ else if (queues.some((q) => hasUnresolved(q))) hasDeclaredPolicy = true;
8496
+ } else if (queues !== void 0 && hasUnresolved(queues)) hasDeclaredPolicy = true;
8497
+ }
8498
+ const livePolicy = await readSqsQueuePolicyDocument(new SQSClient({
8499
+ region,
8500
+ ...READ_RETRY
8501
+ }), queueUrl);
8502
+ return diffSqsQueuePolicy({
8503
+ queueUrl,
8504
+ hasDeclaredPolicy,
8505
+ livePolicy
8506
+ });
8507
+ }
8438
8508
  function diffEventBusChildren(input) {
8439
8509
  const declared = new Set(input.declaredRuleNames);
8440
8510
  const added = [];
@@ -12826,7 +12896,7 @@ function addedFinding(parent, c, read) {
12826
12896
  ...read.ok ? {} : { modelReadFailed: true }
12827
12897
  };
12828
12898
  }
12829
- const CC_GET_UNSUPPORTED_ADDED_TYPES = new Set(["AWS::Route53::RecordSet"]);
12899
+ const CC_GET_UNSUPPORTED_ADDED_TYPES = new Set(["AWS::Route53::RecordSet", "AWS::SQS::QueuePolicy"]);
12830
12900
  async function readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds) {
12831
12901
  const normalizeWith = async (raw) => {
12832
12902
  let schema = schemas.get(c.resourceType);
@@ -16932,9 +17002,19 @@ const deleteRoute53RecordSet = async (ctx) => {
16932
17002
  }] }
16933
17003
  }));
16934
17004
  };
17005
+ const deleteSqsQueuePolicy = async (ctx) => {
17006
+ await new SQSClient({
17007
+ region: ctx.region,
17008
+ ...CLIENT_TIMEOUTS
17009
+ }).send(new SetQueueAttributesCommand({
17010
+ QueueUrl: ctx.physicalId,
17011
+ Attributes: { Policy: "" }
17012
+ }));
17013
+ };
16935
17014
  const SDK_DELETERS = {
16936
17015
  "AWS::AppSync::ApiKey": deleteAppSyncApiKey,
16937
- "AWS::Route53::RecordSet": deleteRoute53RecordSet
17016
+ "AWS::Route53::RecordSet": deleteRoute53RecordSet,
17017
+ "AWS::SQS::QueuePolicy": deleteSqsQueuePolicy
16938
17018
  };
16939
17019
 
16940
17020
  //#endregion