# The machine itself: no public address, no agent, Secure Boot on, and read # access to one evidence bucket. data "oci_core_images" "ol" { compartment_id = var.compartment_ocid operating_system = "Oracle Linux" operating_system_version = var.operating_system_version shape = var.shape sort_by = "TIMECREATED" sort_order = "DESC" state = "AVAILABLE" # Platform images include GPU and Arm builds. Those carry drivers a Secure # Boot machine will not load, so the newest plain build is the one taken. filter { name = "display_name" values = ["^Oracle-Linux-[0-9.]+-20[0-9]{6}\\.[0-9]+$"] regex = true } lifecycle { postcondition { condition = length(self.images) > 0 error_message = "No Oracle Linux ${var.operating_system_version} platform image for ${var.shape} here. Set operating_system_version to one this region offers." } } } resource "oci_core_instance" "workstation" { compartment_id = var.compartment_ocid availability_domain = local.availability_domain display_name = "forensic-workstation" shape = var.shape freeform_tags = local.tags # Traffic between the machine and its boot volume is encrypted too. is_pv_encryption_in_transit_enabled = true shape_config { ocpus = var.ocpus memory_in_gbs = var.memory_in_gbs } source_details { source_type = "image" source_id = data.oci_core_images.ol.images[0].id boot_volume_size_in_gbs = tostring(var.boot_volume_size_in_gbs) kms_key_id = var.kms_key_id == "" ? null : var.kms_key_id } create_vnic_details { subnet_id = oci_core_subnet.forensics.id assign_public_ip = "false" display_name = "forensic-workstation" nsg_ids = [oci_core_network_security_group.workstation.id] freeform_tags = local.tags } # The bastion injects nothing on a port-forwarding session, so these keys # are the only way in. metadata = { ssh_authorized_keys = join("\n", var.analyst_ssh_keys) } # Nothing on Oracle's side runs commands here: no Run Command, no OS # Management, no scanning agent. A port-forwarding session needs none of # them, which is why it is the session type this template uses. agent_config { are_all_plugins_disabled = true is_management_disabled = true is_monitoring_disabled = true } instance_options { are_legacy_imds_endpoints_disabled = true } platform_config { type = "AMD_VM" is_secure_boot_enabled = true is_measured_boot_enabled = true is_trusted_platform_module_enabled = true } # Oracle replaces platform images as new ones are published. Replace the # workstation on purpose, never because a plan noticed a new image. lifecycle { ignore_changes = [source_details[0].source_id] } } resource "oci_identity_dynamic_group" "workstation" { compartment_id = var.tenancy_ocid name = "forensic-workstation" description = "The forensic workstation" matching_rule = "ALL {instance.id = '${oci_core_instance.workstation.id}'}" freeform_tags = local.tags } # Read means list and get. The machine cannot add, replace, or delete an # object, so nothing on it can reach the evidence. resource "oci_identity_policy" "read_evidence" { compartment_id = local.evidence_compartment name = "forensic-workstation-reads-evidence" description = "Lets the forensic workstation read one evidence bucket, and nothing else." freeform_tags = local.tags # Named, not by OCID, so a plan shows the statement a rule can read. statements = [ "Allow dynamic-group ${oci_identity_dynamic_group.workstation.name} to read objects in compartment id ${local.evidence_compartment} where target.bucket.name = '${var.evidence_bucket}'", ] depends_on = [oci_identity_dynamic_group.workstation] }