cdk-real-drift 0.12.75 → 0.12.77
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 +2 -1
- package/dist/cli.js +79 -2
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -279,7 +279,8 @@ needs `--remove-unrecorded`).
|
|
|
279
279
|
validators, gateway responses, stages
|
|
280
280
|
- **API Gateway V2** (HTTP / WebSocket): routes, integrations, authorizers, stages
|
|
281
281
|
- **SNS**: topic subscriptions
|
|
282
|
-
- **Lambda**: event source mappings, function URLs, aliases, versions
|
|
282
|
+
- **Lambda**: event source mappings, function URLs, aliases, versions,
|
|
283
|
+
resource-policy statements (an out-of-band `add-permission`)
|
|
283
284
|
- **EventBridge**: bus rules
|
|
284
285
|
- **Cognito**: user pool clients, groups, resource servers
|
|
285
286
|
- **AppSync**: data sources, resolvers, functions
|
package/dist/cli.js
CHANGED
|
@@ -5506,7 +5506,9 @@ const MEANINGFUL_WHEN_OFF = {
|
|
|
5506
5506
|
"AWS::Cognito::UserPoolClient": { EnableTokenRevocation: () => true },
|
|
5507
5507
|
"AWS::CloudWatch::CompositeAlarm": { ActionsEnabled: () => true },
|
|
5508
5508
|
"AWS::ApplicationInsights::Application": { CWEMonitorEnabled: () => true },
|
|
5509
|
-
"AWS::GuardDuty::Detector": { DataSources: () => true }
|
|
5509
|
+
"AWS::GuardDuty::Detector": { DataSources: () => true },
|
|
5510
|
+
"AWS::Lambda::EventSourceMapping": { Enabled: () => true },
|
|
5511
|
+
"AWS::ElasticLoadBalancingV2::TargetGroup": { HealthCheckEnabled: ({ declared }) => declared["TargetType"] !== "lambda" }
|
|
5510
5512
|
};
|
|
5511
5513
|
const GUARDDUTY_DEFAULT_DISABLED_FEATURES = new Set(["AI_ANALYST"]);
|
|
5512
5514
|
function guardDutyFeaturesAllAtDefault(features) {
|
|
@@ -6538,6 +6540,10 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6538
6540
|
CreditSpecification: { CPUCredits: creditDefault }
|
|
6539
6541
|
};
|
|
6540
6542
|
}
|
|
6543
|
+
if (resourceType === "AWS::ElasticLoadBalancingV2::TargetGroup" && declared["TargetType"] === "lambda") knownDef = {
|
|
6544
|
+
...knownDef,
|
|
6545
|
+
HealthCheckEnabled: false
|
|
6546
|
+
};
|
|
6541
6547
|
if (resourceType === "AWS::EC2::Volume") {
|
|
6542
6548
|
const volumeType = declared["VolumeType"] ?? "gp2";
|
|
6543
6549
|
const size = declared["Size"];
|
|
@@ -8155,6 +8161,66 @@ async function pageLambdaVersions(client, functionName) {
|
|
|
8155
8161
|
} while (marker);
|
|
8156
8162
|
return out;
|
|
8157
8163
|
}
|
|
8164
|
+
function normalizeStatementPrincipal(p) {
|
|
8165
|
+
if (p && typeof p === "object") {
|
|
8166
|
+
const o = p;
|
|
8167
|
+
if (typeof o.Service === "string") return o.Service;
|
|
8168
|
+
if (typeof o.AWS === "string") return o.AWS;
|
|
8169
|
+
}
|
|
8170
|
+
return p;
|
|
8171
|
+
}
|
|
8172
|
+
function projectLambdaStatement(stmt) {
|
|
8173
|
+
const cond = stmt.Condition;
|
|
8174
|
+
const sourceArn = cond?.ArnLike?.["AWS:SourceArn"];
|
|
8175
|
+
const sourceAccount = cond?.StringEquals?.["AWS:SourceAccount"];
|
|
8176
|
+
const principalOrgId = cond?.StringEquals?.["aws:PrincipalOrgID"];
|
|
8177
|
+
const functionUrlAuthType = cond?.StringEquals?.["lambda:FunctionUrlAuthType"];
|
|
8178
|
+
return {
|
|
8179
|
+
...stmt.Sid !== void 0 && { Id: stmt.Sid },
|
|
8180
|
+
...stmt.Action !== void 0 && { Action: stmt.Action },
|
|
8181
|
+
...stmt.Principal !== void 0 && { Principal: normalizeStatementPrincipal(stmt.Principal) },
|
|
8182
|
+
...sourceArn !== void 0 && { SourceArn: sourceArn },
|
|
8183
|
+
...sourceAccount !== void 0 && { SourceAccount: sourceAccount },
|
|
8184
|
+
...principalOrgId !== void 0 && { PrincipalOrgID: principalOrgId },
|
|
8185
|
+
...functionUrlAuthType !== void 0 && { FunctionUrlAuthType: functionUrlAuthType }
|
|
8186
|
+
};
|
|
8187
|
+
}
|
|
8188
|
+
function diffLambdaResourcePolicy(input) {
|
|
8189
|
+
const declared = new Set(input.declaredPermissionSids);
|
|
8190
|
+
const added = [];
|
|
8191
|
+
for (const stmt of input.liveStatements) {
|
|
8192
|
+
const sid = typeof stmt.Sid === "string" && stmt.Sid !== "" ? stmt.Sid : void 0;
|
|
8193
|
+
if (!sid) continue;
|
|
8194
|
+
if (declared.has(sid)) continue;
|
|
8195
|
+
added.push({
|
|
8196
|
+
resourceType: "AWS::Lambda::Permission",
|
|
8197
|
+
identifier: `${input.functionName}|${sid}`,
|
|
8198
|
+
siblingLookupId: sid,
|
|
8199
|
+
label: `permission ${sid}`,
|
|
8200
|
+
live: projectLambdaStatement(stmt)
|
|
8201
|
+
});
|
|
8202
|
+
}
|
|
8203
|
+
return added;
|
|
8204
|
+
}
|
|
8205
|
+
async function readLambdaResourcePolicyStatements(client, functionName) {
|
|
8206
|
+
let policyJson;
|
|
8207
|
+
try {
|
|
8208
|
+
policyJson = (await client.send(new GetPolicyCommand({ FunctionName: functionName })))?.Policy;
|
|
8209
|
+
} catch (e) {
|
|
8210
|
+
if (e.name === "ResourceNotFoundException") return [];
|
|
8211
|
+
throw e;
|
|
8212
|
+
}
|
|
8213
|
+
if (!policyJson) return [];
|
|
8214
|
+
let parsed;
|
|
8215
|
+
try {
|
|
8216
|
+
parsed = JSON.parse(policyJson);
|
|
8217
|
+
} catch {
|
|
8218
|
+
return [];
|
|
8219
|
+
}
|
|
8220
|
+
const stmts = parsed?.Statement;
|
|
8221
|
+
if (!Array.isArray(stmts)) return [];
|
|
8222
|
+
return stmts.filter((s) => typeof s === "object" && s !== null && !Array.isArray(s));
|
|
8223
|
+
}
|
|
8158
8224
|
async function enumerateLambdaFunctionChildren(ctx) {
|
|
8159
8225
|
const { parent, desired, region } = ctx;
|
|
8160
8226
|
const functionName = parent.physicalId;
|
|
@@ -8218,11 +8284,22 @@ async function enumerateLambdaFunctionChildren(ctx) {
|
|
|
8218
8284
|
label: v.Version ? `v${v.Version}` : v.FunctionArn
|
|
8219
8285
|
}))
|
|
8220
8286
|
});
|
|
8287
|
+
const declaredPermissionSids = [];
|
|
8288
|
+
for (const r of desired.resources) {
|
|
8289
|
+
if (r.resourceType !== "AWS::Lambda::Permission" || !r.physicalId) continue;
|
|
8290
|
+
if (lambdaFunctionRefMatches(r.declared.FunctionName, functionName, fnArn)) declaredPermissionSids.push(r.physicalId);
|
|
8291
|
+
}
|
|
8292
|
+
const policyAdded = diffLambdaResourcePolicy({
|
|
8293
|
+
functionName,
|
|
8294
|
+
declaredPermissionSids,
|
|
8295
|
+
liveStatements: await readLambdaResourcePolicyStatements(client, functionName)
|
|
8296
|
+
});
|
|
8221
8297
|
return [
|
|
8222
8298
|
...esmAdded,
|
|
8223
8299
|
...urlAdded,
|
|
8224
8300
|
...aliasAdded,
|
|
8225
|
-
...versionAdded
|
|
8301
|
+
...versionAdded,
|
|
8302
|
+
...policyAdded
|
|
8226
8303
|
];
|
|
8227
8304
|
}
|
|
8228
8305
|
function diffEventBusChildren(input) {
|