From 9e28b2f5cf8c17716a2c3b7c5b4c1aad893dff89 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Mon, 16 Sep 2019 13:45:28 -0700 Subject: [PATCH] fix post-processor --- post-processor/amazon-import/post-processor.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/post-processor/amazon-import/post-processor.go b/post-processor/amazon-import/post-processor.go index 8799b0dc9..17302effc 100644 --- a/post-processor/amazon-import/post-processor.go +++ b/post-processor/amazon-import/post-processor.go @@ -273,11 +273,19 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact ui.Message(fmt.Sprintf("Starting rename of AMI (%s)", createdami)) - resp, err := ec2conn.CopyImage(&ec2.CopyImageInput{ + copyInput := &ec2.CopyImageInput{ Name: &p.config.Name, SourceImageId: &createdami, SourceRegion: config.Region, - }) + } + if p.config.Encrypt { + copyInput.Encrypted = aws.Bool(p.config.Encrypt) + if p.config.KMSKey != "" { + copyInput.KmsKeyId = &p.config.KMSKey + } + } + + resp, err := ec2conn.CopyImage(copyInput) if err != nil { return nil, false, false, fmt.Errorf("Error Copying AMI (%s): %s", createdami, err)