cdk-real-drift 0.12.86 → 0.12.87
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 +6 -0
- package/dist/cli.js +55 -1
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -293,6 +293,8 @@ needs `--remove-unrecorded`).
|
|
|
293
293
|
- **AppConfig**: application environments, configuration profiles
|
|
294
294
|
- **EFS**: file system mount targets
|
|
295
295
|
- **RDS**: database cluster instances
|
|
296
|
+
- **S3**: bucket resource policies (an out-of-band `put-bucket-policy` on a bucket
|
|
297
|
+
with no declared `AWS::S3::BucketPolicy`)
|
|
296
298
|
|
|
297
299
|
</details>
|
|
298
300
|
|
|
@@ -1008,6 +1010,10 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
|
|
|
1008
1010
|
`appconfig:ListConfigurationProfiles`
|
|
1009
1011
|
- `AWS::EFS::FileSystem`: `elasticfilesystem:DescribeMountTargets`
|
|
1010
1012
|
- `AWS::RDS::DBCluster`: `rds:DescribeDBClusters`, `rds:DescribeDBInstances`
|
|
1013
|
+
- `AWS::S3::Bucket`: `s3:GetBucketPolicy` (the same action listed as an SDK
|
|
1014
|
+
override-reader permission above — here it enumerates a bucket's out-of-band
|
|
1015
|
+
resource policy as a child `AWS::S3::BucketPolicy`, so it is required for the
|
|
1016
|
+
`added` tier too; `NoSuchBucketPolicy` is the normal no-policy case)
|
|
1011
1017
|
|
|
1012
1018
|
The `added` tier also needs `cloudformation:DescribeStackResources` (grouped with
|
|
1013
1019
|
the other CloudFormation actions above): before flagging a live child as
|
package/dist/cli.js
CHANGED
|
@@ -28,6 +28,7 @@ import { DescribeEventBusCommand, EventBridgeClient, ListRulesCommand, PutPermis
|
|
|
28
28
|
import { GetFunctionCommand, GetPolicyCommand, LambdaClient, ListAliasesCommand as ListAliasesCommand$1, ListEventSourceMappingsCommand, ListFunctionUrlConfigsCommand, ListVersionsByFunctionCommand } from "@aws-sdk/client-lambda";
|
|
29
29
|
import { DescribeDomainConfigCommand, DescribeDomainsCommand, ListDomainNamesCommand, OpenSearchClient, UpdateDomainConfigCommand } from "@aws-sdk/client-opensearch";
|
|
30
30
|
import { ChangeResourceRecordSetsCommand, ListResourceRecordSetsCommand, Route53Client } from "@aws-sdk/client-route-53";
|
|
31
|
+
import { DeleteBucketPolicyCommand, GetBucketPolicyCommand, GetObjectCommand, PutBucketPolicyCommand, S3Client } from "@aws-sdk/client-s3";
|
|
31
32
|
import { GetTopicAttributesCommand, ListSubscriptionsByTopicCommand, SNSClient, SetTopicAttributesCommand } from "@aws-sdk/client-sns";
|
|
32
33
|
import { ACMClient, DescribeCertificateCommand, ListTagsForCertificateCommand } from "@aws-sdk/client-acm";
|
|
33
34
|
import { BudgetsClient, DescribeBudgetCommand } from "@aws-sdk/client-budgets";
|
|
@@ -38,7 +39,6 @@ import { DescribeDBClustersCommand as DescribeDBClustersCommand$1, DescribeDBIns
|
|
|
38
39
|
import { DAXClient, DescribeClustersCommand, DescribeParameterGroupsCommand, DescribeParametersCommand as DescribeParametersCommand$1, DescribeSubnetGroupsCommand, ListTagsCommand, UpdateClusterCommand, UpdateParameterGroupCommand } from "@aws-sdk/client-dax";
|
|
39
40
|
import { GetClassifierCommand, GetConnectionCommand, GetJobCommand, GetSecurityConfigurationCommand, GetTableCommand, GetTagsCommand, GetWorkflowCommand, GlueClient, UpdateClassifierCommand, UpdateConnectionCommand, UpdateJobCommand, UpdateTableCommand, UpdateWorkflowCommand } from "@aws-sdk/client-glue";
|
|
40
41
|
import { AttachGroupPolicyCommand, AttachRolePolicyCommand, AttachUserPolicyCommand, CreatePolicyVersionCommand, DeletePolicyVersionCommand, DeleteRolePolicyCommand, DetachGroupPolicyCommand, DetachRolePolicyCommand, DetachUserPolicyCommand, GetGroupPolicyCommand, GetPolicyCommand as GetPolicyCommand$1, GetPolicyVersionCommand, GetRolePolicyCommand, GetUserPolicyCommand, IAMClient, ListAccessKeysCommand, ListEntitiesForPolicyCommand, ListPolicyVersionsCommand, PutGroupPolicyCommand, PutRolePolicyCommand, PutUserPolicyCommand } from "@aws-sdk/client-iam";
|
|
41
|
-
import { DeleteBucketPolicyCommand, GetBucketPolicyCommand, GetObjectCommand, PutBucketPolicyCommand, S3Client } from "@aws-sdk/client-s3";
|
|
42
42
|
import { DescribeCacheClustersCommand, DescribeCacheParameterGroupsCommand, DescribeCacheParametersCommand, DescribeReplicationGroupsCommand, DescribeUsersCommand, ElastiCacheClient, ListTagsForResourceCommand as ListTagsForResourceCommand$1, ModifyCacheParameterGroupCommand, ResetCacheParameterGroupCommand } from "@aws-sdk/client-elasticache";
|
|
43
43
|
import { DescribeParameterGroupsCommand as DescribeParameterGroupsCommand$1, DescribeParametersCommand as DescribeParametersCommand$2, DescribeUsersCommand as DescribeUsersCommand$1, MemoryDBClient, ResetParameterGroupCommand, UpdateParameterGroupCommand as UpdateParameterGroupCommand$1 } from "@aws-sdk/client-memorydb";
|
|
44
44
|
import { CloudWatchClient, DescribeAnomalyDetectorsCommand, PutAnomalyDetectorCommand } from "@aws-sdk/client-cloudwatch";
|
|
@@ -7416,6 +7416,7 @@ function lambdaFunctionRefMatches(declaredValue, ...candidates) {
|
|
|
7416
7416
|
return parentRefMatches(unqualifiedFunctionRef(declaredValue), ...candidates.map((c) => c === void 0 ? void 0 : unqualifiedFunctionRef(c)));
|
|
7417
7417
|
}
|
|
7418
7418
|
const CHILD_ENUMERATORS = {
|
|
7419
|
+
"AWS::S3::Bucket": enumerateS3BucketChildren,
|
|
7419
7420
|
"AWS::ApiGateway::RestApi": enumerateRestApiChildren,
|
|
7420
7421
|
"AWS::ApiGatewayV2::Api": enumerateHttpApiChildren,
|
|
7421
7422
|
"AWS::SNS::Topic": enumerateSnsTopicChildren,
|
|
@@ -8381,6 +8382,59 @@ async function enumerateLambdaFunctionChildren(ctx) {
|
|
|
8381
8382
|
...policyAdded
|
|
8382
8383
|
];
|
|
8383
8384
|
}
|
|
8385
|
+
function diffS3BucketPolicy(input) {
|
|
8386
|
+
if (input.hasDeclaredPolicy) return [];
|
|
8387
|
+
if (!input.livePolicy) return [];
|
|
8388
|
+
return [{
|
|
8389
|
+
resourceType: "AWS::S3::BucketPolicy",
|
|
8390
|
+
identifier: input.bucketName,
|
|
8391
|
+
siblingLookupId: input.bucketName,
|
|
8392
|
+
label: `bucket policy ${input.bucketName}`,
|
|
8393
|
+
live: {
|
|
8394
|
+
Bucket: input.bucketName,
|
|
8395
|
+
PolicyDocument: input.livePolicy
|
|
8396
|
+
}
|
|
8397
|
+
}];
|
|
8398
|
+
}
|
|
8399
|
+
async function readS3BucketPolicyDocument(client, bucket) {
|
|
8400
|
+
let policyJson;
|
|
8401
|
+
try {
|
|
8402
|
+
policyJson = (await client.send(new GetBucketPolicyCommand({ Bucket: bucket })))?.Policy;
|
|
8403
|
+
} catch (e) {
|
|
8404
|
+
if (e.name === "NoSuchBucketPolicy") return void 0;
|
|
8405
|
+
throw e;
|
|
8406
|
+
}
|
|
8407
|
+
if (!policyJson) return void 0;
|
|
8408
|
+
let parsed;
|
|
8409
|
+
try {
|
|
8410
|
+
parsed = JSON.parse(policyJson);
|
|
8411
|
+
} catch {
|
|
8412
|
+
return;
|
|
8413
|
+
}
|
|
8414
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
|
|
8415
|
+
}
|
|
8416
|
+
async function enumerateS3BucketChildren(ctx) {
|
|
8417
|
+
const { parent, desired, region } = ctx;
|
|
8418
|
+
const bucketName = parent.physicalId;
|
|
8419
|
+
if (!bucketName) return [];
|
|
8420
|
+
let hasDeclaredPolicy = false;
|
|
8421
|
+
for (const r of desired.resources) {
|
|
8422
|
+
if (r.resourceType !== "AWS::S3::BucketPolicy") continue;
|
|
8423
|
+
const b = r.declared.Bucket;
|
|
8424
|
+
if (typeof b === "string") {
|
|
8425
|
+
if (b === bucketName) hasDeclaredPolicy = true;
|
|
8426
|
+
} else if (b !== void 0 && hasUnresolved(b)) hasDeclaredPolicy = true;
|
|
8427
|
+
}
|
|
8428
|
+
const livePolicy = await readS3BucketPolicyDocument(new S3Client({
|
|
8429
|
+
region,
|
|
8430
|
+
...READ_RETRY
|
|
8431
|
+
}), bucketName);
|
|
8432
|
+
return diffS3BucketPolicy({
|
|
8433
|
+
bucketName,
|
|
8434
|
+
hasDeclaredPolicy,
|
|
8435
|
+
livePolicy
|
|
8436
|
+
});
|
|
8437
|
+
}
|
|
8384
8438
|
function diffEventBusChildren(input) {
|
|
8385
8439
|
const declared = new Set(input.declaredRuleNames);
|
|
8386
8440
|
const added = [];
|