Skip to content

Cannot create/use repository in S3 with S3 Object Lock enabled #2202

@eriksw

Description

@eriksw

Output of restic version

restic 0.9.4 compiled with go1.11.4 on linux/amd64

How did you run restic exactly?

RESTIC_REPOSITORY=s3:s3.amazonaws.com/[myBucketName]/[myPrefixInBucket] \
RESTIC_PASSWORD_FILE=/home/me/.resticpassword \
./restic init --json

What backend/server/service did you use to store the repository?

S3, with S3 Object Lock enabled and configured to apply to all objects.

Expected behavior

Restic should have initialized the repository.

Actual behavior

Fatal: create key in repository at s3:s3.amazonaws.com/[myBucketName]/[myPrefixInBucket] failed: client.PutObject: Content-MD5 HTTP header is required for Put Object requests with Object Lock parameters

Steps to reproduce the behavior

Create a bucket with s3 object lock enabled and configured to apply to all objects. Here's some (partial) terraform code:

resource "aws_s3_bucket" "bucket" {
  bucket = "${var.name}"

  versioning {
    enabled = true
  }

  lifecycle_rule {
    enabled = true
    prefix  = ""

    abort_incomplete_multipart_upload_days = "7"

    noncurrent_version_expiration {
      days = "${var.noncurrent_version_expiration_days}"
    }
  }

  object_lock_configuration {
    object_lock_enabled = "Enabled"

    rule {
      default_retention {
        mode = "COMPLIANCE"
        days = "${var.object_lock_days}"
      }
    }
  }
}

variable "name" {
  type    = "string"
  default = "myBucketName"
}

variable "noncurrent_version_expiration_days" {
  type        = "string"
  description = "In reality, this would be large, like 30-90."
  default     = "1"
}

variable "object_lock_days" {
  type        = "string"
  description = "In reality this would be large, like 180. Don't make this big when testing!"
  default     = "3"
}

Do you have any idea what may have caused this?

Restic is attempting to PUT to S3 without computing Content-MD5 and including that in the request.

Do you have an idea how to solve the issue?

Compute Content-MD5 and set the header when making requests to s3.

Did restic help you or made you happy in any way?

😐

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions