Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #78 from arkahna/fix/force-unlock
Browse files Browse the repository at this point in the history
Fix force unlock
  • Loading branch information
JakeGinnivan authored Nov 16, 2022
2 parents 210ba0a + 9aad13f commit bc80413
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-pants-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@arkahna/nx-terraform': patch
---

Fix force-unlock passing too many args
11 changes: 6 additions & 5 deletions libs/nx-terraform/src/executors/force-unlock/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,20 @@ export default async function runExecutor(options: StateExecutorSchema, context:
success: false,
}
}

const config = await readConfigFromEnvFile(
repoConfig.terraformStateType,
options.environment,
context.projectName,
)

if (!config) {
console.warn('Skipped state command, no terragrunt file for environment')
return {
success: true,
}
}

const { resourceGroupName, terraformStorageAccount, terragruntConfigFile, subscriptionId } =
config

Expand Down Expand Up @@ -73,13 +76,11 @@ export default async function runExecutor(options: StateExecutorSchema, context:
const terragruntCliArgs = createTerragruntCliArgs([
...getTfEnvVars(context.projectName, config, repoConfig),
])

const terragruntStateArgs = [
const terragruntForceUnlockArgs = [
'force-unlock',
options.lockId,
'--terragrunt-config',
terragruntConfigFile,
...terragruntCliArgs,
]

await initEnvironmentWorkspaceWithFirewallRuleRetry({
Expand All @@ -90,8 +91,8 @@ export default async function runExecutor(options: StateExecutorSchema, context:
retryDelay: options.firewallRetryDelay,
})

console.log(`${projectRoot}> ${getEscapedCommand(`terragrunt`, terragruntStateArgs)}`)
await execa('terragrunt', terragruntStateArgs, {
console.log(`${projectRoot}> ${getEscapedCommand(`terragrunt`, terragruntForceUnlockArgs)}`)
await execa('terragrunt', terragruntForceUnlockArgs, {
stdio: 'inherit',
cwd: projectRoot,
})
Expand Down

0 comments on commit bc80413

Please sign in to comment.