resource "scaleway_object" "system_id_encryption_key" {
  bucket = scaleway_object_bucket.infra_assets.id
  key    = "keys/${var.system_id}"

  content_base64 = base64encode(var.encryption_key)
}

resource "scaleway_object" "system_id_encryption_aws_credentials" {
  bucket = scaleway_object_bucket.infra_assets.id
  key    = "keys/${var.system_id}-encryption-service-credentials.json"

  content = jsonencode({
    access_key = var.kms_access_key
    secret_key = var.kms_secret_key
    region     = "eu-west-1"
    key_arn    = var.kms_key_arn
  })
}
