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