17 lines
581 B
JavaScript
Executable File
17 lines
581 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
import YAML from "yaml";
|
|
|
|
const policy = YAML.parse(readFileSync("iam_policy.yaml", "utf8"));
|
|
|
|
// Replace the Cloud Storage entry, if any, and keep the other audit configs.
|
|
policy.auditConfigs = (policy.auditConfigs ?? []).filter(
|
|
(c) => c.service !== "storage.googleapis.com",
|
|
);
|
|
policy.auditConfigs.push({
|
|
service: "storage.googleapis.com",
|
|
auditLogConfigs: [{ logType: "DATA_READ" }, { logType: "DATA_WRITE" }],
|
|
});
|
|
|
|
writeFileSync("iam_policy.yaml", YAML.stringify(policy, { indentSeq: false }));
|