@@ -110,7 +110,7 @@ func (p *AWS) CreateImage(ctx *lepton.Context, imagePath string) error {
110110 key := c .CloudConfig .ImageName
111111
112112 ctx .Logger ().Info ("Creating snapshot" )
113- snapshotID , err := p .createSnapshot (imagePath )
113+ snapshotID , err := p .createSnapshot (imagePath , c . CloudConfig . KMS )
114114 if err != nil {
115115 return err
116116 }
@@ -227,7 +227,7 @@ func (p *AWS) MirrorImage(ctx *lepton.Context, imageName, srcRegion, dstRegion s
227227
228228// createSnapshot process create Snapshot to EBS
229229// Returns snapshotID and err
230- func (p * AWS ) createSnapshot (imagePath string ) (string , error ) {
230+ func (p * AWS ) createSnapshot (imagePath string , kms string ) (string , error ) {
231231 // Open file first
232232 f , err := os .Open (imagePath )
233233 if err != nil {
@@ -250,10 +250,20 @@ func (p *AWS) createSnapshot(imagePath string) (string, error) {
250250 maxBar := (snapshotSize / int64 (SnapshotBlockDataLength ))* 2 + 2
251251 bar := progressbar .Default (maxBar )
252252
253- snapshotOutput , err := p . volumeService . StartSnapshot ( & ebs.StartSnapshotInput {
253+ esi := & ebs.StartSnapshotInput {
254254 Tags : []* ebs.Tag {},
255255 VolumeSize : aws .Int64 (sizeInGb ),
256- })
256+ }
257+
258+ if kms != "" {
259+ esi .Encrypted = aws .Bool (true )
260+
261+ if kms != "default" {
262+ esi .KmsKeyArn = aws .String (kms )
263+ }
264+ }
265+
266+ snapshotOutput , err := p .volumeService .StartSnapshot (esi )
257267 if err != nil {
258268 return "" , err
259269 }
0 commit comments