# The archive's key. Yours, in a vault of its own, so Oracle's key is not the # only thing between the archive and anyone who reaches the bucket's storage. # # Object Storage encrypts with the key as a service, per region, and that # service has to be named in a policy before it can use the key. On a first # apply the policy can take a minute to take effect and bucket creation can # fail. Running apply again is the fix. # # Deleting a vault or key schedules the deletion after a waiting period of at # least seven days, during which it can be cancelled. resource "oci_kms_vault" "archive" { count = local.archive ? 1 : 0 compartment_id = var.compartment_ocid display_name = "oke-audit-archive" vault_type = "DEFAULT" freeform_tags = local.tags } resource "oci_kms_key" "archive" { count = local.archive ? 1 : 0 compartment_id = var.compartment_ocid display_name = "oke-audit-archive" management_endpoint = oci_kms_vault.archive[0].management_endpoint protection_mode = "HSM" freeform_tags = local.tags key_shape { algorithm = "AES" length = 32 } } # Object Storage encrypts the archive with the key as itself, so the service # needs the right to use that one key. resource "oci_identity_policy" "storage_uses_key" { count = local.archive ? 1 : 0 compartment_id = var.compartment_ocid name = "oke-audit-archive-key" description = "Lets Object Storage in this region use the archive key." freeform_tags = local.tags statements = [ "Allow service objectstorage-${var.region} to use keys in compartment id ${var.compartment_ocid} where target.key.id = '${oci_kms_key.archive[0].id}'", ] }