33
44data "oci_core_app_catalog_listings" "autonomous_linux" {
55 display_name = " Oracle Autonomous Linux"
6+ count = var. oci_bastion . use_autonomous == true ? 1 : 0
67}
78
89data "oci_core_app_catalog_listing_resource_versions" "autonomous_linux" {
910 # Required
10- listing_id = lookup (data. oci_core_app_catalog_listings . autonomous_linux . app_catalog_listings [0 ], " listing_id" )
11+ listing_id = lookup (data. oci_core_app_catalog_listings . autonomous_linux [0 ]. app_catalog_listings [0 ], " listing_id" )
12+ count = var. oci_bastion . use_autonomous == true ? 1 : 0
1113}
1214
1315# Gets the Autonomous Linux image id
@@ -16,27 +18,53 @@ data "oci_core_app_catalog_subscriptions" "autonomous_linux" {
1618 compartment_id = var. oci_base_identity . compartment_id
1719
1820 # Optional
19- listing_id = lookup (data. oci_core_app_catalog_listing_resource_versions . autonomous_linux . app_catalog_listing_resource_versions [0 ], " listing_id" )
21+ listing_id = lookup (data. oci_core_app_catalog_listing_resource_versions . autonomous_linux [0 ]. app_catalog_listing_resource_versions [0 ], " listing_id" )
22+ count = var. oci_bastion . use_autonomous == true ? 1 : 0
2023}
2124
22- data "template_file" "bastion_template " {
23- template = file (" ${ path . module } /scripts/bastion .template.sh" )
25+ data "template_file" "autonomous_template " {
26+ template = file (" ${ path . module } /scripts/notification .template.sh" )
2427
2528 vars = {
2629 notification_enabled = var.oci_bastion_notification.enable_notification
27- topic_id = var.oci_bastion_notification.enable_notification == true ? oci_ons_notification_topic.bastion_notification[0 ].topic_id : " null"
30+ topic_id = var.oci_bastion_notification.enable_notification == true ? oci_ons_notification_topic.bastion_notification[0 ].topic_id : " null"
2831 }
29- count = var. oci_bastion . create_bastion == true ? 1 : 0
32+ count = var. oci_bastion . create_bastion == true && var . oci_bastion . use_autonomous == true ? 1 : 0
3033}
3134
32- data "template_file" "bastion_cloud_init_file " {
33- template = file (" ${ path . module } /cloudinit/bastion .template.yaml" )
35+ data "template_file" "autonomous_cloud_init_file " {
36+ template = file (" ${ path . module } /cloudinit/autonomous .template.yaml" )
3437
3538 vars = {
36- notification_sh_content = base64gzip (data. template_file . bastion_template [0 ]. rendered )
39+ notification_sh_content = base64gzip (data. template_file . autonomous_template [0 ]. rendered )
3740 timezone = var.oci_bastion.timezone
3841 }
39- count = var. oci_bastion . create_bastion == true ? 1 : 0
42+ count = var. oci_bastion . create_bastion == true && var. oci_bastion . use_autonomous == true ? 1 : 0
43+ }
44+
45+ data "oci_core_images" "oracle_images" {
46+ compartment_id = var. oci_base_identity . compartment_id
47+ operating_system = " Oracle Linux"
48+ operating_system_version = " 7.7"
49+ shape = var. oci_bastion . bastion_shape
50+ sort_by = " TIMECREATED"
51+ count = var. oci_bastion . create_bastion == true && var. oci_bastion . use_autonomous == false ? 1 : 0
52+ }
53+
54+ data "template_file" "oracle_template" {
55+ template = file (" ${ path . module } /scripts/oracle.template.sh" )
56+ count = var. oci_bastion . create_bastion == true && var. oci_bastion . use_autonomous == false ? 1 : 0
57+ }
58+
59+ data "template_file" "oracle_cloud_init_file" {
60+ template = file (" ${ path . module } /cloudinit/oracle.template.yaml" )
61+
62+ vars = {
63+ bastion_sh_content = base64gzip (data. template_file . oracle_template [0 ]. rendered )
64+ bastion_package_upgrade = var.oci_bastion.bastion_upgrade
65+ timezone = var.oci_bastion.timezone
66+ }
67+ count = var. oci_bastion . create_bastion == true && var. oci_bastion . use_autonomous == false ? 1 : 0
4068}
4169
4270# cloud init for bastion
@@ -47,7 +75,7 @@ data "template_cloudinit_config" "bastion" {
4775 part {
4876 filename = " bastion.yaml"
4977 content_type = " text/cloud-config"
50- content = data. template_file . bastion_cloud_init_file [0 ]. rendered
78+ content = var . oci_bastion . use_autonomous == true ? data. template_file . autonomous_cloud_init_file [ 0 ] . rendered : data . template_file . oracle_cloud_init_file [0 ]. rendered
5179 }
5280 count = var. oci_bastion . create_bastion == true ? 1 : 0
5381}
@@ -62,14 +90,13 @@ data "oci_core_vnic_attachments" "bastion_vnics_attachments" {
6290}
6391
6492# Gets the OCID of the first (default) VNIC on the bastion instance
65- data "oci_core_vnic" "bastion_vnic " {
93+ data "oci_core_vnic" "bastion_vnic_1 " {
6694 vnic_id = lookup (data. oci_core_vnic_attachments . bastion_vnics_attachments [0 ]. vnic_attachments [0 ], " vnic_id" )
6795 depends_on = [" oci_core_instance.bastion" ]
6896 count = var. oci_bastion . create_bastion == true ? 1 : 0
6997}
7098
7199data "oci_core_instance" "bastion" {
72- # Required
73100 instance_id = oci_core_instance. bastion [0 ]. id
74101 depends_on = [" oci_core_instance.bastion" ]
75102 count = var. oci_bastion . create_bastion == true ? 1 : 0
0 commit comments