skeet
Version:
Full-stack TypeScript Serverless Framework
30 lines (28 loc) • 724 B
text/typescript
import { execSyncCmd } from '@/lib/execSyncCmd'
import { getNetworkConfig } from '@/lib/getNetworkConfig'
export const updateSecurityPolicyRule = async (
projectId: string,
appName: string,
priority: string = '1000',
options: { [key: string]: string } = {}
) => {
const appConf = await getNetworkConfig(projectId, appName)
const shCmd = [
'gcloud',
'compute',
'security-policies',
'rules',
'update',
priority,
'--security-policy',
appConf.securityPolicyName,
'--project',
projectId,
]
if (Object.keys(options).length !== 0) {
for await (const [key, value] of Object.entries(options)) {
shCmd.push(`--${key}=${value}`)
}
}
await execSyncCmd(shCmd)
}