I am trying to create IPSEC tunnels on Palo Alto using Terraform. The code would the be pushed via a pipeline. I want all information of the tunnels to be readable, except for the pre_shared_key. I understand how I could encrypt it for one instance, but as there is going to be several tunnel, how can encrypt the key, and map it to its instance?
vpns.yml:
vpns:
- name: "Test"
template: "template_name"
ip_type: "IP"
ip_remote: "1.1.1.1"
firewall_interface: "vlan.xxxx"
local_ip: "public_ip/24"
ikev2_profile: "VerySecure"
tunnel_interface: "tunnel1"
pre_shared_key: "*******"
The module for the tunnel on which I iterate looks like this:
locals {
tunnel = yamldecode(file(var.vpn_file))
}
resource "panos_panorama_ike_gateway" "gateway" {
for_each = { for e in local.tunnel : e.Name => e }
name = each.value.name
template = each.value.template
version = "ikev2-preferred"
peer_ip_type = each.value.ip_type
peer_ip_value = each.value.ip_remote
interface = each.value.firewall_interface
local_ip_address_type = "ip"
local_ip_address_value = each.value.local_ip
pre_shared_key = each.value.pre_shared_key
ikev2_crypto_profile = each.value.ikev2_profile
enable_dead_peer_detection = true
dead_peer_detection_interval = "10"
dead_peer_detection_retry = "3"
liveness_check_interval = "5"
}