cdk-real-drift 0.12.88 → 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";
@@ -7435,6 +7435,7 @@ function lambdaFunctionRefMatches(declaredValue, ...candidates) {
7435
7435
  }
7436
7436
  const CHILD_ENUMERATORS = {
7437
7437
  "AWS::S3::Bucket": enumerateS3BucketChildren,
7438
+ "AWS::SQS::Queue": enumerateSqsQueueChildren,
7438
7439
  "AWS::ApiGateway::RestApi": enumerateRestApiChildren,
7439
7440
  "AWS::ApiGatewayV2::Api": enumerateHttpApiChildren,
7440
7441
  "AWS::SNS::Topic": enumerateSnsTopicChildren,
@@ -8453,6 +8454,57 @@ async function enumerateS3BucketChildren(ctx) {
8453
8454
  livePolicy
8454
8455
  });
8455
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
+ }
8456
8508
  function diffEventBusChildren(input) {
8457
8509
  const declared = new Set(input.declaredRuleNames);
8458
8510
  const added = [];
@@ -12844,7 +12896,7 @@ function addedFinding(parent, c, read) {
12844
12896
  ...read.ok ? {} : { modelReadFailed: true }
12845
12897
  };
12846
12898
  }
12847
- 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"]);
12848
12900
  async function readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds) {
12849
12901
  const normalizeWith = async (raw) => {
12850
12902
  let schema = schemas.get(c.resourceType);
@@ -16950,9 +17002,19 @@ const deleteRoute53RecordSet = async (ctx) => {
16950
17002
  }] }
16951
17003
  }));
16952
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
+ };
16953
17014
  const SDK_DELETERS = {
16954
17015
  "AWS::AppSync::ApiKey": deleteAppSyncApiKey,
16955
- "AWS::Route53::RecordSet": deleteRoute53RecordSet
17016
+ "AWS::Route53::RecordSet": deleteRoute53RecordSet,
17017
+ "AWS::SQS::QueuePolicy": deleteSqsQueuePolicy
16956
17018
  };
16957
17019
 
16958
17020
  //#endregion