builder/amazon: modifying more than one AMI attribute type works
This commit is contained in:
parent
9e01b5a478
commit
b49fe4971a
|
@ -29,6 +29,8 @@ BUG FIXES:
|
||||||
|
|
||||||
* windows: file URLs are easier to get right as Packer
|
* windows: file URLs are easier to get right as Packer
|
||||||
has better parsing and error handling for Windows file paths. [GH-284]
|
has better parsing and error handling for Windows file paths. [GH-284]
|
||||||
|
* builder/amazon/all: Modifying more than one AMI attribute type no longer
|
||||||
|
crashes.
|
||||||
* builder/amazon-instance: send IAM instance profile data. [GH-294]
|
* builder/amazon-instance: send IAM instance profile data. [GH-294]
|
||||||
* builder/virtualbox: dowload progress won't be shown until download
|
* builder/virtualbox: dowload progress won't be shown until download
|
||||||
actually starts. [GH-288]
|
actually starts. [GH-288]
|
||||||
|
|
|
@ -31,20 +31,44 @@ func (s *StepModifyAMIAttributes) Run(state map[string]interface{}) multistep.St
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
options := &ec2.ModifyImageAttribute{
|
// Construct the modify image attribute requests we're going to make.
|
||||||
Description: s.Description,
|
// We need to make each separately since the EC2 API only allows changing
|
||||||
AddUsers: s.Users,
|
// one type at a kind currently.
|
||||||
AddGroups: s.Groups,
|
options := make(map[string]*ec2.ModifyImageAttribute)
|
||||||
ProductCodes: s.ProductCodes,
|
if s.Description != "" {
|
||||||
|
options["description"] = &ec2.ModifyImageAttribute{
|
||||||
|
Description: s.Description,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(s.Groups) > 0 {
|
||||||
|
options["groups"] = &ec2.ModifyImageAttribute{
|
||||||
|
AddGroups: s.Groups,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(s.Users) > 0 {
|
||||||
|
options["users"] = &ec2.ModifyImageAttribute{
|
||||||
|
AddUsers: s.Users,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(s.ProductCodes) > 0 {
|
||||||
|
options["product codes"] = &ec2.ModifyImageAttribute{
|
||||||
|
ProductCodes: s.ProductCodes,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.Say("Modifying AMI attributes...")
|
ui.Say("Modifying AMI attributes...")
|
||||||
_, err := ec2conn.ModifyImageAttribute(ami, options)
|
for name, opts := range options {
|
||||||
if err != nil {
|
ui.Message(fmt.Sprintf("Modifying: %s", name))
|
||||||
err := fmt.Errorf("Error modify AMI attributes: %s", err)
|
_, err := ec2conn.ModifyImageAttribute(ami, opts)
|
||||||
state["error"] = err
|
if err != nil {
|
||||||
ui.Error(err.Error())
|
err := fmt.Errorf("Error modify AMI attributes: %s", err)
|
||||||
return multistep.ActionHalt
|
state["error"] = err
|
||||||
|
ui.Error(err.Error())
|
||||||
|
return multistep.ActionHalt
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
|
|
Loading…
Reference in New Issue