diff --git a/post-processor/amazon-import/post-processor.go b/post-processor/amazon-import/post-processor.go index 36a8f5844..6d7e357bb 100644 --- a/post-processor/amazon-import/post-processor.go +++ b/post-processor/amazon-import/post-processor.go @@ -34,6 +34,7 @@ type Config struct { Description string `mapstructure:"ami_description"` Users []string `mapstructure:"ami_users"` Groups []string `mapstructure:"ami_groups"` + LicenseType string `mapstructure:"license_type"` ctx interpolate.Context } @@ -63,6 +64,10 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { p.config.S3Key = "packer-import-{{timestamp}}.ova" } + if p.config.LicenseType == "" { + p.config.LicenseType = "BYOL" + } + errs := new(packer.MultiError) // Check and render s3_key_name @@ -158,7 +163,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac ui.Message(fmt.Sprintf("Completed upload of %s to s3://%s/%s", source, p.config.S3Bucket, p.config.S3Key)) // Call EC2 image import process - log.Printf("Calling EC2 to import from s3://%s/%s", p.config.S3Bucket, p.config.S3Key) + log.Printf("Calling EC2 to import from s3://%s/%s with license type '%s'", p.config.S3Bucket, p.config.S3Key, p.config.LicenseType) ec2conn := ec2.New(session) import_start, err := ec2conn.ImportImage(&ec2.ImportImageInput{ @@ -170,13 +175,14 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac }, }, }, + LicenseType: &p.config.LicenseType, }) if err != nil { return nil, false, fmt.Errorf("Failed to start import from s3://%s/%s: %s", p.config.S3Bucket, p.config.S3Key, err) } - ui.Message(fmt.Sprintf("Started import of s3://%s/%s, task id %s", p.config.S3Bucket, p.config.S3Key, *import_start.ImportTaskId)) + ui.Message(fmt.Sprintf("Started import of s3://%s/%s with license type %s, task id %s", p.config.S3Bucket, p.config.S3Key, p.config.LicenseType, *import_start.ImportTaskId)) // Wait for import process to complete, this takes a while ui.Message(fmt.Sprintf("Waiting for task %s to complete (may take a while)", *import_start.ImportTaskId))