Skip to content

Commit

Permalink
Added varString as CLi argument (#281)
Browse files Browse the repository at this point in the history
Terraform CLi expects a "--var" argument to be passed when a variable is
defined dynamically with no default value. The new variable serves the
same purpose of "varFile" but expects a string value rather than a file
path
  • Loading branch information
TriPSs authored Jun 14, 2024
2 parents c51f4f8 + 7bd73e9 commit 4ef8d3f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/terraform/src/utils/create-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface ExecutorOptions {
migrateState: boolean
lock: boolean
varFile: string
varString: string

[key: string]: string | unknown
}
Expand All @@ -27,7 +28,7 @@ export function createExecutor(command: string) {
}

const { sourceRoot } = context.workspace.projects[context.projectName]
const { backendConfig = [], planFile, ciMode, autoApproval, formatWrite, upgrade, migrateState, lock, varFile } = options
const { backendConfig = [], planFile, ciMode, autoApproval, formatWrite, upgrade, migrateState, lock, varFile, varString } = options

let env = {}
if (ciMode) {
Expand All @@ -46,15 +47,18 @@ export function createExecutor(command: string) {
),
command === 'plan' && planFile && `-out ${planFile}`,
command === 'plan' && varFile && `--var-file ${varFile}`,
command === 'plan' && varString && `--var ${varString}`,
command === 'destroy' && autoApproval && '-auto-approve',
command === 'apply' && autoApproval && '-auto-approve',
command === 'apply' && planFile,
command === 'apply' && varString && `--var ${varString}`,
command === 'fmt' && '--recursive',
command === 'fmt' && !formatWrite && '--check --list',
command === 'init' && upgrade && '-upgrade',
command === 'init' && migrateState && '-migrate-state',
command === 'providers' && lock && 'lock',
command === 'test' && varFile && `--var-file ${varFile}`,
command === 'test' && varString && `--var ${varString}`,
]),
{
cwd: sourceRoot,
Expand Down

0 comments on commit 4ef8d3f

Please sign in to comment.