<p>I'm trying to deploy a Kubernetes cluster in Oracle Cloud Infrastructure using Terraform.</p>
<p>I want that every node deployed (in private subnet) has the Bastion agent plugin activate in Cloud Agent.</p>
<p>But I cannot see how to define the details of the instance (setting agent_config in the node pool instances).</p>
<p>My code, until now is:</p>
<pre><code>

resource &quot;oci_containerengine_cluster&quot; &quot;generated_oci_containerengine_cluster&quot; {
    compartment_id = var.cluster_compartment
    endpoint_config {
        is_public_ip_enabled = &quot;true&quot;
        subnet_id = oci_core_subnet.oke_public_api.id
    }
    kubernetes_version = var.kubernetes_version
    name = &quot;josealbarran_labcloudnative_oke&quot;
    options {
        kubernetes_network_config {
            pods_cidr = &quot;10.244.0.0/16&quot;
            services_cidr = &quot;10.96.0.0/16&quot;
        }
        service_lb_subnet_ids = [oci_core_subnet.oke_public_lb.id]
    }
    vcn_id = var.cluster_vcn
}

# Check doc: https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/containerengine_node_pool
resource &quot;oci_containerengine_node_pool&quot; &quot;node_pool01&quot; {
    cluster_id = &quot;${oci_containerengine_cluster.generated_oci_containerengine_cluster.id}&quot;
    compartment_id = var.cluster_compartment
    initial_node_labels {
        key = &quot;name&quot;
        value = &quot;pool01&quot;
    }
    kubernetes_version = var.kubernetes_version
    name = &quot;lab_cloud_native_oke_pool01&quot;

    node_config_details {
        size = &quot;${length(data.oci_identity_availability_domains.ads.availability_domains)}&quot;
        dynamic &quot;placement_configs&quot; {
            for_each = data.oci_identity_availability_domains.ads.availability_domains[*].name
            content {
                availability_domain = placement_configs.value
                subnet_id = oci_core_subnet.oke_private_worker.id
            }
        }


    }
    node_shape = &quot;VM.Standard.A1.Flex&quot;
    node_shape_config {
        memory_in_gbs = &quot;16&quot;
        ocpus = &quot;1&quot;
    }
    node_source_details {
        image_id = &quot;ocid1.image.oc1.eu-frankfurt-1.aaaaaaaalgodii3qx3mfasp6ai22bja7mabfwsxiwkzxx7lhdfdbbuyqcznq&quot;
        source_type = &quot;IMAGE&quot;
    }
    ssh_public_key = &quot;ssh-rsa AAAAB3xxxxxxxx.......&quot;


  timeouts {
      create = &quot;60m&quot;
      delete = &quot;90m&quot;
    }
}

</code></pre>

<p>You can use the &quot;<strong>cloudinit_config</strong>&quot; to run the custom script in OKE node pool in OCI.</p>
<pre><code>second_script_template = templatefile(&quot;${path.module}/cloudinit/second.template.sh&quot;,{})
</code></pre>
<p>More scripts like</p>
<pre><code>data &quot;cloudinit_config&quot; &quot;worker&quot; {
  gzip          = false
  base64_encode = true

  part {
    filename     = &quot;worker.sh&quot;
    content_type = &quot;text/x-shellscript&quot;
    content      = local.worker_script_template
  }

  part {
    filename     = &quot;second.sh&quot;
    content_type = &quot;text/x-shellscript&quot;
    content      = local.second_script_template
  }

  part {
    filename     = &quot;third.sh&quot;
    content_type = &quot;text/x-shellscript&quot;
    content      = local.third_script_template
  }
}
</code></pre>
<p>Refer : <a href="https://github.com/oracle-terraform-modules/terraform-oci-oke/blob/main/docs/instructions.adoc#14-configuring-cloud-init-for-the-nodepools" rel="nofollow noreferrer">https://github.com/oracle-terraform-modules/terraform-oci-oke/blob/main/docs/instructions.adoc#14-configuring-cloud-init-for-the-nodepools</a></p>
<p>If you are looking forward to just edit the default script : <a href="https://github.com/oracle-terraform-modules/terraform-oci-oke/blob/main/docs/cloudinit.adoc" rel="nofollow noreferrer">https://github.com/oracle-terraform-modules/terraform-oci-oke/blob/main/docs/cloudinit.adoc</a></p>
