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 #22 from arkahna/fix/firewall-rule-output-is-noisy
Browse files Browse the repository at this point in the history
Fixed firewall rules logging
  • Loading branch information
JakeGinnivan authored Aug 3, 2022
2 parents 04981c7 + c33ebb1 commit 0801fcf
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 59 deletions.
6 changes: 6 additions & 0 deletions libs/nx-terraform/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @arkahna/nx-terraform

## 0.34.5

### Patch Changes

- Removed output from cli commands adding / removing firewall rules, it's noisy

## 0.34.4

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/nx-terraform/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arkahna/nx-terraform",
"version": "0.34.4",
"version": "0.34.5",
"main": "src/index.js",
"generators": "./generators.json",
"executors": "./executors.json",
Expand Down
50 changes: 21 additions & 29 deletions libs/nx-terraform/src/common/addFirewallRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,18 @@ export async function addFirewallRules({
try {
console.log(`Adding firewall rule to ${storageAccountName}`)
storageAccountsToRemoveFirewallRules.push(storageAccountName)
await execa(
'az',
[
'storage',
'account',
'network-rule',
'add',
'-g',
resourceGroupName,
'--account-name',
storageAccountName,
'--ip-address',
publicIpv4,
],
{ stdio: 'inherit' },
)
await execa('az', [
'storage',
'account',
'network-rule',
'add',
'-g',
resourceGroupName,
'--account-name',
storageAccountName,
'--ip-address',
publicIpv4,
])
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
console.error('Failed to add network rule to storage', err)
Expand All @@ -78,19 +74,15 @@ export async function addFirewallRules({
try {
console.log(`Adding firewall rule to ${keyVaultName}`)
keyVaultsToRemoveFirewallRules.push(keyVaultName)
await execa(
'az',
[
'keyvault',
'network-rule',
'add',
'--name',
keyVaultName,
'--ip-address',
publicIpv4,
],
{ stdio: 'inherit' },
)
await execa('az', [
'keyvault',
'network-rule',
'add',
'--name',
keyVaultName,
'--ip-address',
publicIpv4,
])
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
console.error('Failed to add network rule to keyvault', err)
Expand Down
50 changes: 21 additions & 29 deletions libs/nx-terraform/src/common/removeFirewallRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,34 @@ export async function removeFirewallRules({
const ipWithCdir = `${publicIpv4}/32`
for (const keyVaultName of removeIpFromKeyVaults) {
try {
await execa(
'az',
[
'keyvault',
'network-rule',
'remove',
'--name',
keyVaultName,
'--ip-address',
ipWithCdir,
],
{ stdio: 'inherit' },
)
await execa('az', [
'keyvault',
'network-rule',
'remove',
'--name',
keyVaultName,
'--ip-address',
ipWithCdir,
])
} catch (err) {
console.error('Failed to remove network rule from keyvault', err)
}
}

for (const storageAccount of removeIpFromStorageAccounts) {
try {
await execa(
'az',
[
'storage',
'account',
'network-rule',
'remove',
'-g',
resourceGroupName,
'--account-name',
storageAccount,
'--ip-address',
publicIpv4,
],
{ stdio: 'inherit' },
)
await execa('az', [
'storage',
'account',
'network-rule',
'remove',
'-g',
resourceGroupName,
'--account-name',
storageAccount,
'--ip-address',
publicIpv4,
])
} catch (err) {
console.error(
`Failed to remove network rule from storage account ${storageAccount}`,
Expand Down

0 comments on commit 0801fcf

Please sign in to comment.