(opts: DeployOptions)
| 78 | |
| 79 | /** Run `sam deploy` non-interactively. Returns when SAM exits 0; throws on non-zero. */ |
| 80 | export function samDeploy(opts: DeployOptions): void { |
| 81 | assertSamAvailable(); |
| 82 | const paramOverrides = [ |
| 83 | `ChromeSource=${opts.chromeSource ?? "sparticuz"}`, |
| 84 | `ReservedConcurrency=${opts.reservedConcurrency ?? -1}`, |
| 85 | ]; |
| 86 | if (opts.lambdaMemoryMb !== undefined) { |
| 87 | paramOverrides.push(`LambdaMemoryMb=${opts.lambdaMemoryMb}`); |
| 88 | } |
| 89 | const args = [ |
| 90 | "deploy", |
| 91 | "--stack-name", |
| 92 | opts.stackName, |
| 93 | "--region", |
| 94 | opts.region, |
| 95 | "--resolve-s3", |
| 96 | "--capabilities", |
| 97 | "CAPABILITY_IAM", |
| 98 | "--no-confirm-changeset", |
| 99 | "--no-fail-on-empty-changeset", |
| 100 | "--parameter-overrides", |
| 101 | ...paramOverrides, |
| 102 | ]; |
| 103 | if (opts.awsProfile) { |
| 104 | args.push("--profile", opts.awsProfile); |
| 105 | } |
| 106 | const samDir = join(opts.repoRoot, "examples", "aws-lambda"); |
| 107 | const result = spawnSync("sam", args, { cwd: samDir, stdio: opts.stdio ?? "inherit" }); |
| 108 | if (result.status !== 0) { |
| 109 | throw new Error(`[lambda] sam deploy exited with code ${result.status ?? "unknown"}`); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | /** Run `sam delete` non-interactively. */ |
| 114 | export function samDelete(opts: { |
no test coverage detected