cdk-real-drift 0.12.96 → 0.12.97
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 +11 -4
- package/dist/cli.js +79 -8
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -291,7 +291,10 @@ needs `--remove-unrecorded`).
|
|
|
291
291
|
- **EC2**: VPC subnets, VPC endpoints, VPC route tables, VPC network ACLs, route
|
|
292
292
|
table routes
|
|
293
293
|
- **ECS**: cluster services
|
|
294
|
-
- **KMS**: key aliases
|
|
294
|
+
- **KMS**: key aliases, key grants (an out-of-band `kms create-grant` on a key —
|
|
295
|
+
grants are not a CloudFormation type, so cdkrd surfaces them as a synthetic
|
|
296
|
+
`AWS::KMS::Grant`; AWS-service-created grants, e.g. a Lambda env-encryption key's
|
|
297
|
+
grant, are folded so only a human/IAM-principal grant surfaces)
|
|
295
298
|
- **AppConfig**: application environments, configuration profiles
|
|
296
299
|
- **EFS**: file system mount targets
|
|
297
300
|
- **RDS**: database cluster instances
|
|
@@ -1024,7 +1027,10 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
|
|
|
1024
1027
|
`ecs:DescribeServices` override reader listed above)
|
|
1025
1028
|
- `AWS::KMS::Key`: `kms:ListAliases` (the same action listed as optional
|
|
1026
1029
|
above — here it enumerates a key's aliases as child resources, so it is
|
|
1027
|
-
required, not optional, for the `added` tier)
|
|
1030
|
+
required, not optional, for the `added` tier), `kms:ListGrants` (enumerates a
|
|
1031
|
+
key's out-of-band grants as synthetic `AWS::KMS::Grant` children; AWS-service
|
|
1032
|
+
grants are folded, so only a human/IAM-principal grant surfaces). Reverting a
|
|
1033
|
+
detected one also needs `kms:RevokeGrant` (the SDK deleter revokes the grant).
|
|
1028
1034
|
- `AWS::AppConfig::Application`: `appconfig:ListEnvironments`,
|
|
1029
1035
|
`appconfig:ListConfigurationProfiles`
|
|
1030
1036
|
- `AWS::EFS::FileSystem`: `elasticfilesystem:DescribeMountTargets`
|
|
@@ -1057,9 +1063,10 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
|
|
|
1057
1063
|
`cloudcontrol:UpdateResource` (which resolves to each type's own update
|
|
1058
1064
|
permissions), `cloudcontrol:DeleteResource` (to delete an out-of-band `added`
|
|
1059
1065
|
resource; a type Cloud Control cannot delete goes through its own SDK action
|
|
1060
|
-
instead — `appsync:DeleteApiKey` for an out-of-band `AWS::AppSync::ApiKey`,
|
|
1066
|
+
instead — `appsync:DeleteApiKey` for an out-of-band `AWS::AppSync::ApiKey`,
|
|
1061
1067
|
`route53:ChangeResourceRecordSets` (a DELETE change) for an out-of-band
|
|
1062
|
-
`AWS::Route53::RecordSet`
|
|
1068
|
+
`AWS::Route53::RecordSet`, or `kms:RevokeGrant` for an out-of-band
|
|
1069
|
+
`AWS::KMS::Grant`), and
|
|
1063
1070
|
`cloudcontrol:GetResourceRequestStatus` (to poll the async Cloud
|
|
1064
1071
|
Control request to completion). Plus, for the SDK-written types:
|
|
1065
1072
|
`s3:PutBucketPolicy` /
|
package/dist/cli.js
CHANGED
|
@@ -15,7 +15,7 @@ import { DescribeServicesCommand, ECSClient, ListAccountSettingsCommand, ListSer
|
|
|
15
15
|
import { DescribeCertificatesCommand, DescribeDBClustersCommand, DescribeDBInstancesCommand, DescribeOptionGroupOptionsCommand, RDSClient } from "@aws-sdk/client-rds";
|
|
16
16
|
import { DescribeParametersCommand, GetParametersCommand, GetServiceSettingCommand, SSMClient } from "@aws-sdk/client-ssm";
|
|
17
17
|
import jsonata from "jsonata";
|
|
18
|
-
import { KMSClient, ListAliasesCommand } from "@aws-sdk/client-kms";
|
|
18
|
+
import { KMSClient, ListAliasesCommand, ListGrantsCommand, RevokeGrantCommand } from "@aws-sdk/client-kms";
|
|
19
19
|
import { APIGatewayClient, GetAuthorizersCommand, GetGatewayResponsesCommand, GetModelsCommand, GetRequestValidatorsCommand, GetResourcesCommand, GetStagesCommand, UpdateIntegrationCommand, UpdateIntegrationResponseCommand, UpdateMethodResponseCommand, UpdateRestApiCommand } from "@aws-sdk/client-api-gateway";
|
|
20
20
|
import { AppConfigClient, ListConfigurationProfilesCommand, ListEnvironmentsCommand } from "@aws-sdk/client-appconfig";
|
|
21
21
|
import { AppSyncClient, DeleteApiKeyCommand, ListApiKeysCommand, ListDataSourcesCommand, ListFunctionsCommand, ListResolversCommand, ListTypesCommand } from "@aws-sdk/client-appsync";
|
|
@@ -7301,6 +7301,18 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
7301
7301
|
});
|
|
7302
7302
|
continue;
|
|
7303
7303
|
}
|
|
7304
|
+
if (resourceType === "AWS::Kinesis::Stream" && k === "ShardCount") {
|
|
7305
|
+
if ((declared.StreamModeDetails?.StreamMode ?? live.StreamModeDetails?.StreamMode) === "ON_DEMAND") {
|
|
7306
|
+
findings.push({
|
|
7307
|
+
tier: "atDefault",
|
|
7308
|
+
logicalId,
|
|
7309
|
+
resourceType,
|
|
7310
|
+
path: k,
|
|
7311
|
+
actual: v
|
|
7312
|
+
});
|
|
7313
|
+
continue;
|
|
7314
|
+
}
|
|
7315
|
+
}
|
|
7304
7316
|
const namePattern = DEFAULT_MANAGED_NAME_PATHS[resourceType]?.[k];
|
|
7305
7317
|
if (namePattern !== void 0 && typeof v === "string" && namePattern.test(v)) {
|
|
7306
7318
|
findings.push({
|
|
@@ -9917,13 +9929,59 @@ async function enumerateKmsKeyChildren(ctx) {
|
|
|
9917
9929
|
const name = typeof r.declared.AliasName === "string" ? r.declared.AliasName : r.physicalId;
|
|
9918
9930
|
if (name) declaredAliasNames.push(name);
|
|
9919
9931
|
}
|
|
9932
|
+
const client = new KMSClient({
|
|
9933
|
+
region,
|
|
9934
|
+
...READ_RETRY
|
|
9935
|
+
});
|
|
9936
|
+
const liveAliases = (await pageAliases(client, keyId)).filter((a) => typeof a.AliasName === "string").map((a) => ({ name: a.AliasName }));
|
|
9937
|
+
const liveGrants = (await pageGrants(client, keyId)).filter((g) => typeof g.GrantId === "string").map((g) => ({
|
|
9938
|
+
grantId: g.GrantId,
|
|
9939
|
+
name: g.Name,
|
|
9940
|
+
granteePrincipal: g.GranteePrincipal,
|
|
9941
|
+
retiringPrincipal: g.RetiringPrincipal,
|
|
9942
|
+
operations: g.Operations
|
|
9943
|
+
}));
|
|
9920
9944
|
return diffKmsKeyChildren({
|
|
9921
9945
|
declaredAliasNames,
|
|
9922
|
-
liveAliases
|
|
9923
|
-
|
|
9924
|
-
|
|
9925
|
-
|
|
9926
|
-
|
|
9946
|
+
liveAliases
|
|
9947
|
+
}).concat(diffKmsKeyGrants({ liveGrants }));
|
|
9948
|
+
}
|
|
9949
|
+
function isAwsServicePrincipal(principal) {
|
|
9950
|
+
if (typeof principal !== "string" || principal.startsWith("arn:")) return false;
|
|
9951
|
+
return /^[a-z0-9-]+(\.[a-z0-9-]+)*\.amazonaws\.com$/.test(principal);
|
|
9952
|
+
}
|
|
9953
|
+
function diffKmsKeyGrants(input) {
|
|
9954
|
+
const added = [];
|
|
9955
|
+
for (const g of input.liveGrants) {
|
|
9956
|
+
if (isAwsServicePrincipal(g.granteePrincipal) || isAwsServicePrincipal(g.retiringPrincipal)) continue;
|
|
9957
|
+
added.push({
|
|
9958
|
+
resourceType: "AWS::KMS::Grant",
|
|
9959
|
+
identifier: g.grantId,
|
|
9960
|
+
siblingLookupId: g.grantId,
|
|
9961
|
+
label: g.name ? `grant ${g.name} (${g.grantId.slice(0, 12)}…)` : `grant ${g.grantId}`,
|
|
9962
|
+
live: {
|
|
9963
|
+
GrantId: g.grantId,
|
|
9964
|
+
...g.name !== void 0 ? { GrantName: g.name } : {},
|
|
9965
|
+
...g.granteePrincipal !== void 0 ? { GranteePrincipal: g.granteePrincipal } : {},
|
|
9966
|
+
...g.retiringPrincipal !== void 0 ? { RetiringPrincipal: g.retiringPrincipal } : {},
|
|
9967
|
+
...g.operations !== void 0 ? { Operations: g.operations } : {}
|
|
9968
|
+
}
|
|
9969
|
+
});
|
|
9970
|
+
}
|
|
9971
|
+
return added;
|
|
9972
|
+
}
|
|
9973
|
+
async function pageGrants(client, keyId) {
|
|
9974
|
+
const out = [];
|
|
9975
|
+
let marker;
|
|
9976
|
+
do {
|
|
9977
|
+
const res = await client.send(new ListGrantsCommand({
|
|
9978
|
+
KeyId: keyId,
|
|
9979
|
+
Marker: marker
|
|
9980
|
+
}));
|
|
9981
|
+
out.push(...res.Grants ?? []);
|
|
9982
|
+
marker = res.NextMarker;
|
|
9983
|
+
} while (marker);
|
|
9984
|
+
return out;
|
|
9927
9985
|
}
|
|
9928
9986
|
function diffAppConfigApplicationChildren(input) {
|
|
9929
9987
|
const { applicationId, declaredEnvironmentIds, liveEnvironments } = input;
|
|
@@ -13124,7 +13182,8 @@ const CC_GET_UNSUPPORTED_ADDED_TYPES = new Set([
|
|
|
13124
13182
|
"AWS::Route53::RecordSet",
|
|
13125
13183
|
"AWS::SQS::QueuePolicy",
|
|
13126
13184
|
"AWS::SecretsManager::ResourcePolicy",
|
|
13127
|
-
"AWS::SNS::TopicPolicy"
|
|
13185
|
+
"AWS::SNS::TopicPolicy",
|
|
13186
|
+
"AWS::KMS::Grant"
|
|
13128
13187
|
]);
|
|
13129
13188
|
async function readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds) {
|
|
13130
13189
|
const normalizeWith = async (raw) => {
|
|
@@ -17363,12 +17422,24 @@ const deleteSnsTopicPolicy = async (ctx) => {
|
|
|
17363
17422
|
AttributeValue: defaultPolicy
|
|
17364
17423
|
}));
|
|
17365
17424
|
};
|
|
17425
|
+
const deleteKmsGrant = async (ctx) => {
|
|
17426
|
+
const keyId = ctx.parentPhysicalId;
|
|
17427
|
+
if (!keyId) throw new Error("cannot resolve the parent KMS Key id for the grant revoke");
|
|
17428
|
+
await new KMSClient({
|
|
17429
|
+
region: ctx.region,
|
|
17430
|
+
...CLIENT_TIMEOUTS
|
|
17431
|
+
}).send(new RevokeGrantCommand({
|
|
17432
|
+
KeyId: keyId,
|
|
17433
|
+
GrantId: ctx.physicalId
|
|
17434
|
+
}));
|
|
17435
|
+
};
|
|
17366
17436
|
const SDK_DELETERS = {
|
|
17367
17437
|
"AWS::AppSync::ApiKey": deleteAppSyncApiKey,
|
|
17368
17438
|
"AWS::Route53::RecordSet": deleteRoute53RecordSet,
|
|
17369
17439
|
"AWS::SQS::QueuePolicy": deleteSqsQueuePolicy,
|
|
17370
17440
|
"AWS::SecretsManager::ResourcePolicy": deleteSecretsManagerResourcePolicy,
|
|
17371
|
-
"AWS::SNS::TopicPolicy": deleteSnsTopicPolicy
|
|
17441
|
+
"AWS::SNS::TopicPolicy": deleteSnsTopicPolicy,
|
|
17442
|
+
"AWS::KMS::Grant": deleteKmsGrant
|
|
17372
17443
|
};
|
|
17373
17444
|
|
|
17374
17445
|
//#endregion
|