cdk-real-drift 0.12.75 → 0.12.76
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 +72 -1
- 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
|
@@ -8155,6 +8155,66 @@ async function pageLambdaVersions(client, functionName) {
|
|
|
8155
8155
|
} while (marker);
|
|
8156
8156
|
return out;
|
|
8157
8157
|
}
|
|
8158
|
+
function normalizeStatementPrincipal(p) {
|
|
8159
|
+
if (p && typeof p === "object") {
|
|
8160
|
+
const o = p;
|
|
8161
|
+
if (typeof o.Service === "string") return o.Service;
|
|
8162
|
+
if (typeof o.AWS === "string") return o.AWS;
|
|
8163
|
+
}
|
|
8164
|
+
return p;
|
|
8165
|
+
}
|
|
8166
|
+
function projectLambdaStatement(stmt) {
|
|
8167
|
+
const cond = stmt.Condition;
|
|
8168
|
+
const sourceArn = cond?.ArnLike?.["AWS:SourceArn"];
|
|
8169
|
+
const sourceAccount = cond?.StringEquals?.["AWS:SourceAccount"];
|
|
8170
|
+
const principalOrgId = cond?.StringEquals?.["aws:PrincipalOrgID"];
|
|
8171
|
+
const functionUrlAuthType = cond?.StringEquals?.["lambda:FunctionUrlAuthType"];
|
|
8172
|
+
return {
|
|
8173
|
+
...stmt.Sid !== void 0 && { Id: stmt.Sid },
|
|
8174
|
+
...stmt.Action !== void 0 && { Action: stmt.Action },
|
|
8175
|
+
...stmt.Principal !== void 0 && { Principal: normalizeStatementPrincipal(stmt.Principal) },
|
|
8176
|
+
...sourceArn !== void 0 && { SourceArn: sourceArn },
|
|
8177
|
+
...sourceAccount !== void 0 && { SourceAccount: sourceAccount },
|
|
8178
|
+
...principalOrgId !== void 0 && { PrincipalOrgID: principalOrgId },
|
|
8179
|
+
...functionUrlAuthType !== void 0 && { FunctionUrlAuthType: functionUrlAuthType }
|
|
8180
|
+
};
|
|
8181
|
+
}
|
|
8182
|
+
function diffLambdaResourcePolicy(input) {
|
|
8183
|
+
const declared = new Set(input.declaredPermissionSids);
|
|
8184
|
+
const added = [];
|
|
8185
|
+
for (const stmt of input.liveStatements) {
|
|
8186
|
+
const sid = typeof stmt.Sid === "string" && stmt.Sid !== "" ? stmt.Sid : void 0;
|
|
8187
|
+
if (!sid) continue;
|
|
8188
|
+
if (declared.has(sid)) continue;
|
|
8189
|
+
added.push({
|
|
8190
|
+
resourceType: "AWS::Lambda::Permission",
|
|
8191
|
+
identifier: `${input.functionName}|${sid}`,
|
|
8192
|
+
siblingLookupId: sid,
|
|
8193
|
+
label: `permission ${sid}`,
|
|
8194
|
+
live: projectLambdaStatement(stmt)
|
|
8195
|
+
});
|
|
8196
|
+
}
|
|
8197
|
+
return added;
|
|
8198
|
+
}
|
|
8199
|
+
async function readLambdaResourcePolicyStatements(client, functionName) {
|
|
8200
|
+
let policyJson;
|
|
8201
|
+
try {
|
|
8202
|
+
policyJson = (await client.send(new GetPolicyCommand({ FunctionName: functionName })))?.Policy;
|
|
8203
|
+
} catch (e) {
|
|
8204
|
+
if (e.name === "ResourceNotFoundException") return [];
|
|
8205
|
+
throw e;
|
|
8206
|
+
}
|
|
8207
|
+
if (!policyJson) return [];
|
|
8208
|
+
let parsed;
|
|
8209
|
+
try {
|
|
8210
|
+
parsed = JSON.parse(policyJson);
|
|
8211
|
+
} catch {
|
|
8212
|
+
return [];
|
|
8213
|
+
}
|
|
8214
|
+
const stmts = parsed?.Statement;
|
|
8215
|
+
if (!Array.isArray(stmts)) return [];
|
|
8216
|
+
return stmts.filter((s) => typeof s === "object" && s !== null && !Array.isArray(s));
|
|
8217
|
+
}
|
|
8158
8218
|
async function enumerateLambdaFunctionChildren(ctx) {
|
|
8159
8219
|
const { parent, desired, region } = ctx;
|
|
8160
8220
|
const functionName = parent.physicalId;
|
|
@@ -8218,11 +8278,22 @@ async function enumerateLambdaFunctionChildren(ctx) {
|
|
|
8218
8278
|
label: v.Version ? `v${v.Version}` : v.FunctionArn
|
|
8219
8279
|
}))
|
|
8220
8280
|
});
|
|
8281
|
+
const declaredPermissionSids = [];
|
|
8282
|
+
for (const r of desired.resources) {
|
|
8283
|
+
if (r.resourceType !== "AWS::Lambda::Permission" || !r.physicalId) continue;
|
|
8284
|
+
if (lambdaFunctionRefMatches(r.declared.FunctionName, functionName, fnArn)) declaredPermissionSids.push(r.physicalId);
|
|
8285
|
+
}
|
|
8286
|
+
const policyAdded = diffLambdaResourcePolicy({
|
|
8287
|
+
functionName,
|
|
8288
|
+
declaredPermissionSids,
|
|
8289
|
+
liveStatements: await readLambdaResourcePolicyStatements(client, functionName)
|
|
8290
|
+
});
|
|
8221
8291
|
return [
|
|
8222
8292
|
...esmAdded,
|
|
8223
8293
|
...urlAdded,
|
|
8224
8294
|
...aliasAdded,
|
|
8225
|
-
...versionAdded
|
|
8295
|
+
...versionAdded,
|
|
8296
|
+
...policyAdded
|
|
8226
8297
|
];
|
|
8227
8298
|
}
|
|
8228
8299
|
function diffEventBusChildren(input) {
|