diff --git a/drivers/volume/csi/csi.go b/drivers/volume/csi/csi.go index 367606b62f..93fbf3f104 100644 --- a/drivers/volume/csi/csi.go +++ b/drivers/volume/csi/csi.go @@ -7,6 +7,7 @@ import ( "path/filepath" "strings" + "github.com/aws/aws-sdk-go/service/s3/s3manager" kSnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1" kSnapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1beta1" kSnapshotClient "github.com/kubernetes-csi/external-snapshotter/client/v4/clientset/versioned" @@ -27,6 +28,7 @@ import ( "github.com/portworx/sched-ops/k8s/core" storkops "github.com/portworx/sched-ops/k8s/stork" "github.com/sirupsen/logrus" + "gocloud.dev/blob" "gocloud.dev/gcerrors" v1 "k8s.io/api/core/v1" storagev1 "k8s.io/api/storage/v1" @@ -576,8 +578,23 @@ func (c *csi) uploadObject( } } + var options blob.WriterOptions + if backupLocation.Location.S3Config != nil { + sseType := backupLocation.Location.S3Config.SSE + if len(sseType) != 0 { + beforeWrite := func(asFunc func(interface{}) bool) error { + var input *s3manager.UploadInput + if asFunc(&input) { + input.ServerSideEncryption = &sseType + } + return nil + } + options = blob.WriterOptions{BeforeWrite: beforeWrite} + } + } + objectPath := controllers.GetObjectPath(backup) - writer, err := bucket.NewWriter(context.TODO(), filepath.Join(objectPath, objectName), nil) + writer, err := bucket.NewWriter(context.TODO(), filepath.Join(objectPath, objectName), &options) if err != nil { return err }