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

Commit

Permalink
Fixed error when running apply and the environment doesn't exist for …
Browse files Browse the repository at this point in the history
…a project
  • Loading branch information
JakeGinnivan committed Nov 1, 2022
1 parent ee2a371 commit 6999fa8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/grumpy-turkeys-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@arkahna/nx-terraform': patch
---

Fixed apply erroring when an environment doesn't exist for a project
8 changes: 8 additions & 0 deletions libs/nx-terraform/src/executors/apply/executor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ExecutorContext } from '@nrwl/devkit'
import execa from 'execa'
import { getEscapedCommand } from 'execa/lib/command'
import { existsSync } from 'fs'
import publicIp from 'public-ip'
import { addFirewallRulesWithRetry } from '../../common/addFirewallRulesWithRetry'
import { createTerragruntCliArgs } from '../../common/createTerragruntCliArgs'
Expand Down Expand Up @@ -50,6 +51,13 @@ export default async function runExecutor(options: ApplyExecutorSchema, context:
subscriptionId,
} = config

if (!existsSync(terragruntConfigFile)) {
console.log('No terragrunt config file found, skipping apply')
return {
success: true,
}
}

const currentAccount = await getCurrentAzAccount()

if (subscriptionId !== currentAccount.id) {
Expand Down

0 comments on commit 6999fa8

Please sign in to comment.