|
|
@ -194,14 +194,19 @@ export const testRequiredVariables = <TVars extends TerraformVariables>(
|
|
|
|
export const runTerraformApply = async <TVars extends TerraformVariables>(
|
|
|
|
export const runTerraformApply = async <TVars extends TerraformVariables>(
|
|
|
|
dir: string,
|
|
|
|
dir: string,
|
|
|
|
vars: Readonly<TVars>,
|
|
|
|
vars: Readonly<TVars>,
|
|
|
|
env?: Record<string, string>,
|
|
|
|
customEnv?: Record<string, string>,
|
|
|
|
): Promise<TerraformState> => {
|
|
|
|
): Promise<TerraformState> => {
|
|
|
|
const stateFile = `${dir}/${crypto.randomUUID()}.tfstate`;
|
|
|
|
const stateFile = `${dir}/${crypto.randomUUID()}.tfstate`;
|
|
|
|
|
|
|
|
|
|
|
|
const combinedEnv = env === undefined ? {} : { ...env };
|
|
|
|
const combinedEnv: Record<string, string | undefined> = {
|
|
|
|
|
|
|
|
...process.env,
|
|
|
|
|
|
|
|
...(customEnv ?? {}),
|
|
|
|
|
|
|
|
};
|
|
|
|
for (const [key, value] of Object.entries(vars)) {
|
|
|
|
for (const [key, value] of Object.entries(vars)) {
|
|
|
|
|
|
|
|
if (value !== null) {
|
|
|
|
combinedEnv[`TF_VAR_${key}`] = String(value);
|
|
|
|
combinedEnv[`TF_VAR_${key}`] = String(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const proc = spawn(
|
|
|
|
const proc = spawn(
|
|
|
|
[
|
|
|
|
[
|
|
|
|