# Customer-managed key for the evidence bucket. # # 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 in OCI schedules the deletion after a waiting period # of at least seven days, during which it can be cancelled. resource "oci_kms_vault" "evidence" { compartment_id = local.evidence_compartment display_name = "container-evidence-${random_id.suffix.hex}" vault_type = "DEFAULT" freeform_tags = local.tags } resource "oci_kms_key" "evidence" { compartment_id = local.evidence_compartment display_name = "container-evidence-${random_id.suffix.hex}" management_endpoint = oci_kms_vault.evidence.management_endpoint protection_mode = "HSM" freeform_tags = local.tags key_shape { algorithm = "AES" length = 32 } } resource "oci_identity_policy" "storage_uses_key" { compartment_id = local.evidence_compartment name = "container-evidence-${random_id.suffix.hex}-key" description = "Lets Object Storage in this region use the evidence key, and only that key." freeform_tags = local.tags statements = [ "Allow service objectstorage-${var.region} to use keys in compartment id ${local.evidence_compartment} where target.key.id = '${oci_kms_key.evidence.id}'", ] }