cdk-real-drift 0.12.91 → 0.12.93
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 +7 -0
- package/dist/cli.js +82 -5
- package/dist/cli.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -297,6 +297,8 @@ needs `--remove-unrecorded`).
|
|
|
297
297
|
with no declared `AWS::S3::BucketPolicy`)
|
|
298
298
|
- **SQS**: queue access policies (an out-of-band `set-queue-attributes Policy` on a
|
|
299
299
|
queue with no declared `AWS::SQS::QueuePolicy`)
|
|
300
|
+
- **Secrets Manager**: secret resource policies (an out-of-band `put-resource-policy`
|
|
301
|
+
on a secret with no declared `AWS::SecretsManager::ResourcePolicy`)
|
|
300
302
|
|
|
301
303
|
</details>
|
|
302
304
|
|
|
@@ -1027,6 +1029,11 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
|
|
|
1027
1029
|
access policy as a child `AWS::SQS::QueuePolicy`; a queue with no policy simply
|
|
1028
1030
|
returns no `Policy` attribute). Reverting a detected one also needs
|
|
1029
1031
|
`sqs:SetQueueAttributes` (the SDK deleter clears the `Policy`).
|
|
1032
|
+
- `AWS::SecretsManager::Secret`: `secretsmanager:GetResourcePolicy` (enumerates a
|
|
1033
|
+
secret's out-of-band resource policy as a child
|
|
1034
|
+
`AWS::SecretsManager::ResourcePolicy`; a secret with no policy returns none).
|
|
1035
|
+
Reverting a detected one also needs `secretsmanager:DeleteResourcePolicy` (the
|
|
1036
|
+
SDK deleter detaches the policy).
|
|
1030
1037
|
|
|
1031
1038
|
The `added` tier also needs `cloudformation:DescribeStackResources` (grouped with
|
|
1032
1039
|
the other CloudFormation actions above): before flagging a live child as
|
package/dist/cli.js
CHANGED
|
@@ -29,6 +29,7 @@ import { GetFunctionCommand, GetPolicyCommand, LambdaClient, ListAliasesCommand
|
|
|
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
31
|
import { DeleteBucketPolicyCommand, GetBucketPolicyCommand, GetObjectCommand, PutBucketPolicyCommand, S3Client } from "@aws-sdk/client-s3";
|
|
32
|
+
import { DeleteResourcePolicyCommand, GetResourcePolicyCommand, SecretsManagerClient } from "@aws-sdk/client-secrets-manager";
|
|
32
33
|
import { GetTopicAttributesCommand, ListSubscriptionsByTopicCommand, SNSClient, SetTopicAttributesCommand } from "@aws-sdk/client-sns";
|
|
33
34
|
import { GetQueueAttributesCommand, SQSClient, SetQueueAttributesCommand } from "@aws-sdk/client-sqs";
|
|
34
35
|
import { ACMClient, DescribeCertificateCommand, ListTagsForCertificateCommand } from "@aws-sdk/client-acm";
|
|
@@ -3016,6 +3017,18 @@ const KNOWN_DEFAULT_PATHS = {
|
|
|
3016
3017
|
InCluster: true
|
|
3017
3018
|
}
|
|
3018
3019
|
},
|
|
3020
|
+
"AWS::ElasticBeanstalk::Application": { "ResourceLifecycleConfig.VersionLifecycleConfig": {
|
|
3021
|
+
MaxCountRule: {
|
|
3022
|
+
DeleteSourceFromS3: false,
|
|
3023
|
+
Enabled: false,
|
|
3024
|
+
MaxCount: 200
|
|
3025
|
+
},
|
|
3026
|
+
MaxAgeRule: {
|
|
3027
|
+
DeleteSourceFromS3: false,
|
|
3028
|
+
MaxAgeInDays: 180,
|
|
3029
|
+
Enabled: false
|
|
3030
|
+
}
|
|
3031
|
+
} },
|
|
3019
3032
|
"AWS::Batch::JobDefinition": {
|
|
3020
3033
|
"ContainerProperties.RuntimePlatform.CpuArchitecture": "X86_64",
|
|
3021
3034
|
"ContainerProperties.RuntimePlatform.OperatingSystemFamily": "LINUX",
|
|
@@ -3187,7 +3200,8 @@ const DESCEND_UNDECLARED_OBJECT_PATHS = {
|
|
|
3187
3200
|
"AWS::EKS::Cluster": new Set(["KubernetesNetworkConfig"]),
|
|
3188
3201
|
"AWS::Athena::WorkGroup": new Set(["WorkGroupConfiguration"]),
|
|
3189
3202
|
"AWS::KinesisVideo::Stream": new Set(["StreamStorageConfiguration"]),
|
|
3190
|
-
"AWS::MSK::Cluster": new Set(["EncryptionInfo"])
|
|
3203
|
+
"AWS::MSK::Cluster": new Set(["EncryptionInfo"]),
|
|
3204
|
+
"AWS::ElasticBeanstalk::Application": new Set(["ResourceLifecycleConfig"])
|
|
3191
3205
|
};
|
|
3192
3206
|
const GENERATED_LOGICALID_PREFIX_PATHS = {
|
|
3193
3207
|
"AWS::Cognito::UserPoolClient": new Set(["ClientName"]),
|
|
@@ -3211,7 +3225,8 @@ const GENERATED_NESTED_PATHS = {
|
|
|
3211
3225
|
"AWS::DynamoDB::Table": new Set(["SSESpecification.KMSMasterKeyId"]),
|
|
3212
3226
|
"AWS::DynamoDB::GlobalTable": new Set(["Replicas.*.SSESpecification.KMSMasterKeyId"]),
|
|
3213
3227
|
"AWS::AutoScaling::AutoScalingGroup": new Set(["LaunchTemplate.LaunchTemplateName"]),
|
|
3214
|
-
"AWS::MSK::Cluster": new Set(["EncryptionInfo.EncryptionAtRest", "BrokerNodeGroupInfo.SecurityGroups"])
|
|
3228
|
+
"AWS::MSK::Cluster": new Set(["EncryptionInfo.EncryptionAtRest", "BrokerNodeGroupInfo.SecurityGroups"]),
|
|
3229
|
+
"AWS::ElasticBeanstalk::Application": new Set(["ResourceLifecycleConfig.ServiceRole"])
|
|
3215
3230
|
};
|
|
3216
3231
|
const EB_OPTION_DEFAULTS = {
|
|
3217
3232
|
"aws:autoscaling:asg|Availability Zones": "Any",
|
|
@@ -7500,6 +7515,7 @@ function lambdaFunctionRefMatches(declaredValue, ...candidates) {
|
|
|
7500
7515
|
const CHILD_ENUMERATORS = {
|
|
7501
7516
|
"AWS::S3::Bucket": enumerateS3BucketChildren,
|
|
7502
7517
|
"AWS::SQS::Queue": enumerateSqsQueueChildren,
|
|
7518
|
+
"AWS::SecretsManager::Secret": enumerateSecretsManagerSecretChildren,
|
|
7503
7519
|
"AWS::ApiGateway::RestApi": enumerateRestApiChildren,
|
|
7504
7520
|
"AWS::ApiGatewayV2::Api": enumerateHttpApiChildren,
|
|
7505
7521
|
"AWS::SNS::Topic": enumerateSnsTopicChildren,
|
|
@@ -8569,6 +8585,53 @@ async function enumerateSqsQueueChildren(ctx) {
|
|
|
8569
8585
|
livePolicy
|
|
8570
8586
|
});
|
|
8571
8587
|
}
|
|
8588
|
+
function diffSecretsManagerResourcePolicy(input) {
|
|
8589
|
+
if (input.hasDeclaredPolicy) return [];
|
|
8590
|
+
if (!input.livePolicy) return [];
|
|
8591
|
+
return [{
|
|
8592
|
+
resourceType: "AWS::SecretsManager::ResourcePolicy",
|
|
8593
|
+
identifier: input.secretId,
|
|
8594
|
+
siblingLookupId: input.secretId,
|
|
8595
|
+
label: `secret resource policy ${input.secretId}`,
|
|
8596
|
+
live: {
|
|
8597
|
+
SecretId: input.secretId,
|
|
8598
|
+
ResourcePolicy: input.livePolicy
|
|
8599
|
+
}
|
|
8600
|
+
}];
|
|
8601
|
+
}
|
|
8602
|
+
async function readSecretsManagerResourcePolicyDocument(client, secretId) {
|
|
8603
|
+
const policyJson = (await client.send(new GetResourcePolicyCommand({ SecretId: secretId }))).ResourcePolicy;
|
|
8604
|
+
if (!policyJson) return void 0;
|
|
8605
|
+
let parsed;
|
|
8606
|
+
try {
|
|
8607
|
+
parsed = JSON.parse(policyJson);
|
|
8608
|
+
} catch {
|
|
8609
|
+
return;
|
|
8610
|
+
}
|
|
8611
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
|
|
8612
|
+
}
|
|
8613
|
+
async function enumerateSecretsManagerSecretChildren(ctx) {
|
|
8614
|
+
const { parent, desired, region } = ctx;
|
|
8615
|
+
const secretId = parent.physicalId;
|
|
8616
|
+
if (!secretId) return [];
|
|
8617
|
+
let hasDeclaredPolicy = false;
|
|
8618
|
+
for (const r of desired.resources) {
|
|
8619
|
+
if (r.resourceType !== "AWS::SecretsManager::ResourcePolicy") continue;
|
|
8620
|
+
const sid = r.declared.SecretId;
|
|
8621
|
+
if (typeof sid === "string") {
|
|
8622
|
+
if (sid === secretId) hasDeclaredPolicy = true;
|
|
8623
|
+
} else if (sid !== void 0 && hasUnresolved(sid)) hasDeclaredPolicy = true;
|
|
8624
|
+
}
|
|
8625
|
+
const livePolicy = await readSecretsManagerResourcePolicyDocument(new SecretsManagerClient({
|
|
8626
|
+
region,
|
|
8627
|
+
...READ_RETRY
|
|
8628
|
+
}), secretId);
|
|
8629
|
+
return diffSecretsManagerResourcePolicy({
|
|
8630
|
+
secretId,
|
|
8631
|
+
hasDeclaredPolicy,
|
|
8632
|
+
livePolicy
|
|
8633
|
+
});
|
|
8634
|
+
}
|
|
8572
8635
|
function diffEventBusChildren(input) {
|
|
8573
8636
|
const declared = new Set(input.declaredRuleNames);
|
|
8574
8637
|
const added = [];
|
|
@@ -12960,7 +13023,11 @@ function addedFinding(parent, c, read) {
|
|
|
12960
13023
|
...read.ok ? {} : { modelReadFailed: true }
|
|
12961
13024
|
};
|
|
12962
13025
|
}
|
|
12963
|
-
const CC_GET_UNSUPPORTED_ADDED_TYPES = new Set([
|
|
13026
|
+
const CC_GET_UNSUPPORTED_ADDED_TYPES = new Set([
|
|
13027
|
+
"AWS::Route53::RecordSet",
|
|
13028
|
+
"AWS::SQS::QueuePolicy",
|
|
13029
|
+
"AWS::SecretsManager::ResourcePolicy"
|
|
13030
|
+
]);
|
|
12964
13031
|
async function readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds) {
|
|
12965
13032
|
const normalizeWith = async (raw) => {
|
|
12966
13033
|
let schema = schemas.get(c.resourceType);
|
|
@@ -16758,7 +16825,10 @@ const writeElasticBeanstalkApplication = async (ctx, ops) => {
|
|
|
16758
16825
|
if (top && EB_APPLICATION_MODIFY_PARAMS.has(top)) {
|
|
16759
16826
|
input[top] = op.op === "remove" ? "" : str(ctx.declared[top]) ?? "";
|
|
16760
16827
|
any = true;
|
|
16761
|
-
} else if (top === "ResourceLifecycleConfig")
|
|
16828
|
+
} else if (top === "ResourceLifecycleConfig") {
|
|
16829
|
+
const targetsWholeObject = op.path.replace(/^\//, "") === "ResourceLifecycleConfig";
|
|
16830
|
+
lifecycle = op.op === "remove" ? EB_APPLICATION_DEFAULT_RESOURCE_LIFECYCLE : asObject(ctx.declared["ResourceLifecycleConfig"]) ?? (targetsWholeObject ? asObject(op.value) : void 0) ?? EB_APPLICATION_DEFAULT_RESOURCE_LIFECYCLE;
|
|
16831
|
+
}
|
|
16762
16832
|
}
|
|
16763
16833
|
if (any) await client.send(new UpdateApplicationCommand(input));
|
|
16764
16834
|
if (lifecycle !== void 0) await client.send(new UpdateApplicationResourceLifecycleCommand({
|
|
@@ -17154,10 +17224,17 @@ const deleteSqsQueuePolicy = async (ctx) => {
|
|
|
17154
17224
|
Attributes: { Policy: "" }
|
|
17155
17225
|
}));
|
|
17156
17226
|
};
|
|
17227
|
+
const deleteSecretsManagerResourcePolicy = async (ctx) => {
|
|
17228
|
+
await new SecretsManagerClient({
|
|
17229
|
+
region: ctx.region,
|
|
17230
|
+
...CLIENT_TIMEOUTS
|
|
17231
|
+
}).send(new DeleteResourcePolicyCommand({ SecretId: ctx.physicalId }));
|
|
17232
|
+
};
|
|
17157
17233
|
const SDK_DELETERS = {
|
|
17158
17234
|
"AWS::AppSync::ApiKey": deleteAppSyncApiKey,
|
|
17159
17235
|
"AWS::Route53::RecordSet": deleteRoute53RecordSet,
|
|
17160
|
-
"AWS::SQS::QueuePolicy": deleteSqsQueuePolicy
|
|
17236
|
+
"AWS::SQS::QueuePolicy": deleteSqsQueuePolicy,
|
|
17237
|
+
"AWS::SecretsManager::ResourcePolicy": deleteSecretsManagerResourcePolicy
|
|
17161
17238
|
};
|
|
17162
17239
|
|
|
17163
17240
|
//#endregion
|