@@ -403,12 +403,31 @@ resource "oci_bastion_bastion" "bastion-service" {
403
403
bastion_type = " STANDARD"
404
404
compartment_id = var. compartment_ocid
405
405
target_subnet_id = var. joomla_subnet_id
406
- # target_subnet_id = var.bastion_subnet_id
407
406
client_cidr_block_allow_list = [" 0.0.0.0/0" ]
408
407
name = " BastionService4Joomla"
409
408
max_session_ttl_in_seconds = 10800
410
409
}
411
410
411
+ data "oci_computeinstanceagent_instance_agent_plugins" "joomla_agent_plugin_bastion" {
412
+ count = var. numberOfNodes > 1 && var. use_bastion_service ? 1 : 0
413
+ compartment_id = var. compartment_ocid
414
+ instanceagent_id = oci_core_instance. Joomla . id
415
+ name = " Bastion"
416
+ status = " RUNNING"
417
+ }
418
+
419
+ resource "time_sleep" "joomla_agent_checker" {
420
+ depends_on = [oci_core_instance . Joomla ]
421
+ count = var. numberOfNodes > 1 && var. use_bastion_service ? 1 : 0
422
+ create_duration = " 60s"
423
+
424
+ triggers = {
425
+ changed_time_stamp = length (data. oci_computeinstanceagent_instance_agent_plugins . joomla_agent_plugin_bastion ) != 0 ? 0 : timestamp ()
426
+ instance_ocid = oci_core_instance.Joomla.id
427
+ private_ip = oci_core_instance.Joomla.private_ip
428
+ }
429
+ }
430
+
412
431
resource "oci_bastion_session" "ssh_via_bastion_service" {
413
432
depends_on = [oci_core_instance . Joomla ]
414
433
count = var. numberOfNodes > 1 && var. use_bastion_service ? 1 : 0
@@ -420,10 +439,10 @@ resource "oci_bastion_session" "ssh_via_bastion_service" {
420
439
421
440
target_resource_details {
422
441
session_type = " MANAGED_SSH"
423
- target_resource_id = oci_core_instance . Joomla . id
442
+ target_resource_id = time_sleep . joomla_agent_checker [ count . index ] . triggers [ " instance_ocid " ]
424
443
target_resource_operating_system_user_name = " opc"
425
444
target_resource_port = 22
426
- target_resource_private_ip_address = oci_core_instance . Joomla . private_ip
445
+ target_resource_private_ip_address = time_sleep . joomla_agent_checker [ count . index ] . triggers [ " private_ip" ]
427
446
}
428
447
429
448
display_name = " ssh_via_bastion_service_to_Joomla1"
@@ -801,6 +820,26 @@ resource "oci_core_instance" "Joomla_from_image" {
801
820
}
802
821
}
803
822
823
+ data "oci_computeinstanceagent_instance_agent_plugins" "joomla2plus_agent_plugin_bastion" {
824
+ count = var. numberOfNodes > 1 && var. use_bastion_service ? var. numberOfNodes - 1 : 0
825
+ compartment_id = var. compartment_ocid
826
+ instanceagent_id = oci_core_instance. Joomla_from_image [count . index ]. id
827
+ name = " Bastion"
828
+ status = " RUNNING"
829
+ }
830
+
831
+ resource "time_sleep" "joomla2plus_agent_checker" {
832
+ depends_on = [oci_core_instance . Joomla_from_image ]
833
+ count = var. numberOfNodes > 1 && var. use_bastion_service ? var. numberOfNodes - 1 : 0
834
+ create_duration = " 60s"
835
+
836
+ triggers = {
837
+ changed_time_stamp = length (data. oci_computeinstanceagent_instance_agent_plugins . joomla2plus_agent_plugin_bastion ) != 0 ? 0 : timestamp ()
838
+ instance_ocid = oci_core_instance.Joomla_from_image[count.index].id
839
+ private_ip = oci_core_instance.Joomla_from_image[count.index].private_ip
840
+ }
841
+ }
842
+
804
843
resource "oci_bastion_session" "ssh_via_bastion_service2plus" {
805
844
depends_on = [oci_core_instance . Joomla ]
806
845
count = var. numberOfNodes > 1 && var. use_bastion_service ? var. numberOfNodes - 1 : 0
@@ -812,10 +851,10 @@ resource "oci_bastion_session" "ssh_via_bastion_service2plus" {
812
851
813
852
target_resource_details {
814
853
session_type = " MANAGED_SSH"
815
- target_resource_id = oci_core_instance . Joomla_from_image [count . index ]. id
854
+ target_resource_id = time_sleep . joomla2plus_agent_checker [count . index ]. triggers [ " instance_ocid " ]
816
855
target_resource_operating_system_user_name = " opc"
817
856
target_resource_port = 22
818
- target_resource_private_ip_address = oci_core_instance . Joomla_from_image [count . index ]. private_ip
857
+ target_resource_private_ip_address = time_sleep . joomla2plus_agent_checker [count . index ]. triggers [ " private_ip" ]
819
858
}
820
859
821
860
display_name = " ssh_via_bastion_service_to_Joomla${ count . index + 2 } "
0 commit comments