@@ -124,7 +124,7 @@ resource "enos_file" "controller_config" {
124
124
}
125
125
126
126
resource "enos_boundary_init" "controller" {
127
- count = local. is_restored_db ? 0 : 1 // init not required when we restore from a snapshot
127
+ count = ! local. is_restored_db && var . controller_count > 0 ? 1 : 0 // init not required when we restore from a snapshot
128
128
129
129
bin_name = var. boundary_binary_name
130
130
bin_path = var. boundary_install_dir
@@ -133,7 +133,7 @@ resource "enos_boundary_init" "controller" {
133
133
134
134
transport = {
135
135
ssh = {
136
- host = aws_instance.controller[0 ].public_ip
136
+ host = try ( aws_instance. controller [0 ]. public_ip , null )
137
137
}
138
138
}
139
139
@@ -217,14 +217,15 @@ resource "enos_file" "worker_config" {
217
217
depends_on = [enos_bundle_install . worker ]
218
218
destination = " /etc/boundary/boundary.hcl"
219
219
content = templatefile (" ${ path . module } /${ var . worker_config_file_path } " , {
220
- id = each.value
221
- kms_key_id = data.aws_kms_key.kms_key.id,
222
- controller_ips = jsonencode (aws_instance. controller . * . private_ip ),
223
- public_addr = aws_instance.worker[tonumber (each. value )].public_ip
224
- region = var.aws_region
225
- type = jsonencode (var. worker_type_tags )
226
- recording_storage_path = var.recording_storage_path
227
- audit_log_dir = local.audit_log_directory
220
+ id = each.value
221
+ kms_key_id = data.aws_kms_key.kms_key.id,
222
+ controller_ips = jsonencode (aws_instance. controller . * . private_ip ),
223
+ public_addr = aws_instance.worker[tonumber (each. value )].public_ip
224
+ region = var.aws_region
225
+ type = jsonencode (var. worker_type_tags )
226
+ recording_storage_path = var.recording_storage_path
227
+ audit_log_dir = local.audit_log_directory
228
+ hcp_boundary_cluster_id = var.hcp_boundary_cluster_id
228
229
})
229
230
for_each = toset ([for idx in range (var. worker_count ) : tostring (idx)])
230
231
@@ -271,3 +272,15 @@ resource "enos_remote_exec" "create_worker_audit_log_dir" {
271
272
}
272
273
}
273
274
}
275
+
276
+ resource "enos_remote_exec" "get_worker_token" {
277
+ depends_on = [enos_boundary_start . worker_start ]
278
+ for_each = var. hcp_boundary_cluster_id != " " ? toset ([for idx in range (var. worker_count ) : tostring (idx)]) : []
279
+
280
+ inline = [" timeout 10s bash -c 'set -eo pipefail; until journalctl -u boundary.service | cat | grep \" Worker Auth Registration Request: .*\" | rev | cut -d \" \" -f 1 | rev | xargs; do sleep 2; done'" ]
281
+ transport = {
282
+ ssh = {
283
+ host = aws_instance.worker[tonumber (each. value )].public_ip
284
+ }
285
+ }
286
+ }
0 commit comments