Skip to content

Commit

Permalink
Merge pull request #396 from lonegunmanb/robust-public-ip
Browse files Browse the repository at this point in the history
Use `lonegunmanb/public-ip/lonegunmanb` module to retrieve public ip
  • Loading branch information
jiaweitao001 authored Jun 20, 2023
2 parents 9542cac + d9cdbda commit 8cdf6db
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
10 changes: 4 additions & 6 deletions examples/named_cluster/key_vault.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ resource "random_string" "key_vault_prefix" {
upper = false
}

data "curl" "public_ip" {
count = var.key_vault_firewall_bypass_ip_cidr == null ? 1 : 0

http_method = "GET"
uri = "https://api.ipify.org?format=json"
module "public_ip" {
source = "lonegunmanb/public-ip/lonegunmanb"
version = "0.1.0"
}

locals {
# We cannot use coalesce here because it's not short-circuit and public_ip's index will cause error
public_ip = var.key_vault_firewall_bypass_ip_cidr == null ? jsondecode(data.curl.public_ip[0].response).ip : var.key_vault_firewall_bypass_ip_cidr
public_ip = var.key_vault_firewall_bypass_ip_cidr == null ? module.public_ip.public_ip : var.key_vault_firewall_bypass_ip_cidr
}

resource "azurerm_key_vault" "des_vault" {
Expand Down
10 changes: 4 additions & 6 deletions examples/startup/disk_encryption_set.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ resource "random_string" "key_vault_prefix" {
numeric = false
}

data "curl" "public_ip" {
count = var.key_vault_firewall_bypass_ip_cidr == null ? 1 : 0

http_method = "GET"
uri = "https://api.ipify.org?format=json"
module "public_ip" {
source = "lonegunmanb/public-ip/lonegunmanb"
version = "0.1.0"
}

locals {
# We cannot use coalesce here because it's not short-circuit and public_ip's index will cause error
public_ip = var.key_vault_firewall_bypass_ip_cidr == null ? jsondecode(data.curl.public_ip[0].response).ip : var.key_vault_firewall_bypass_ip_cidr
public_ip = var.key_vault_firewall_bypass_ip_cidr == null ? module.public_ip.public_ip : var.key_vault_firewall_bypass_ip_cidr
}

resource "azurerm_key_vault" "des_vault" {
Expand Down
10 changes: 4 additions & 6 deletions examples/without_monitor/disk_encryption_set.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ resource "random_string" "key_vault_prefix" {
upper = false
}

data "curl" "public_ip" {
count = var.key_vault_firewall_bypass_ip_cidr == null ? 1 : 0

http_method = "GET"
uri = "https://api.ipify.org?format=json"
module "public_ip" {
source = "lonegunmanb/public-ip/lonegunmanb"
version = "0.1.0"
}

locals {
# We cannot use coalesce here because it's not short-circuit and public_ip's index will cause error
public_ip = var.key_vault_firewall_bypass_ip_cidr == null ? jsondecode(data.curl.public_ip[0].response).ip : var.key_vault_firewall_bypass_ip_cidr
public_ip = var.key_vault_firewall_bypass_ip_cidr == null ? module.public_ip.public_ip : var.key_vault_firewall_bypass_ip_cidr
}

resource "azurerm_key_vault" "des_vault" {
Expand Down

0 comments on commit 8cdf6db

Please sign in to comment.