File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,13 +59,17 @@ data "archive_file" "puppetserver_files" {
5959 }
6060}
6161
62+ locals {
63+ bastion_host = length (var. configuration . bastions ) > 0 ? var. configuration . bastions [keys (var. configuration . bastions )[0 ]] : null
64+ }
65+
6266resource "terraform_data" "deploy_puppetserver_files" {
63- for_each = length (var . configuration . bastions ) > 0 ? var. configuration . puppetservers : {}
67+ for_each = local . bastion_host != null ? var. configuration . puppetservers : {}
6468
6569 connection {
6670 type = " ssh"
6771 agent = false
68- bastion_host = var . configuration . bastions [ keys (var . configuration . bastions )[ 0 ]] . public_ip
72+ bastion_host = contains (local . bastion_host . tags , " public " ) ? local . bastion_host . public_ip : local . bastion_host . local_ip
6973 bastion_user = " tf"
7074 bastion_private_key = var. configuration . ssh_key . private
7175 user = " tf"
You can’t perform that action at this time.
0 commit comments