# Customer-managed key, and the policy that lets Object Storage do its two jobs # here: encrypt with the key, and delete old versions on schedule. Lifecycle # rules run as the Object Storage service, so without the second statement they # are accepted and quietly do nothing. resource "oci_kms_vault" "state" { compartment_id = var.compartment_ocid display_name = "${var.name}-vault" vault_type = "DEFAULT" freeform_tags = local.tags } resource "oci_kms_key" "state" { compartment_id = var.compartment_ocid display_name = "${var.name}-storage" management_endpoint = oci_kms_vault.state.management_endpoint protection_mode = "HSM" freeform_tags = local.tags key_shape { algorithm = "AES" length = 32 } } resource "oci_identity_policy" "storage_service" { compartment_id = var.tenancy_ocid name = "${var.name}-storage-service" description = "Lets Object Storage use the state key and run the state bucket's lifecycle rules." 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.state.id}'", "Allow service objectstorage-${var.region} to manage object-family in compartment id ${var.compartment_ocid}", ] }