Commit ef142ce8 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/amazon: region copy must go before modify attributes

/cc @jmassara - This has to go before the modify attributes so that
the attributes are properly modified on all resulting AMIs.
parent a4f674f8
...@@ -8,12 +8,12 @@ import ( ...@@ -8,12 +8,12 @@ import (
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
) )
type StepAMIRegionCopyAttributes struct { type StepAMIRegionCopy struct {
Regions []string Regions []string
Tags map[string]string Tags map[string]string
} }
func (s *StepAMIRegionCopyAttributes) Run(state map[string]interface{}) multistep.StepAction { func (s *StepAMIRegionCopy) Run(state map[string]interface{}) multistep.StepAction {
ec2conn := state["ec2"].(*ec2.EC2) ec2conn := state["ec2"].(*ec2.EC2)
ui := state["ui"].(packer.Ui) ui := state["ui"].(packer.Ui)
amis := state["amis"].(map[string]string) amis := state["amis"].(map[string]string)
...@@ -74,6 +74,6 @@ func (s *StepAMIRegionCopyAttributes) Run(state map[string]interface{}) multiste ...@@ -74,6 +74,6 @@ func (s *StepAMIRegionCopyAttributes) Run(state map[string]interface{}) multiste
return multistep.ActionContinue return multistep.ActionContinue
} }
func (s *StepAMIRegionCopyAttributes) Cleanup(state map[string]interface{}) { func (s *StepAMIRegionCopy) Cleanup(state map[string]interface{}) {
// No cleanup... // No cleanup...
} }
...@@ -130,16 +130,16 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe ...@@ -130,16 +130,16 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&common.StepProvision{}, &common.StepProvision{},
&stepStopInstance{}, &stepStopInstance{},
&stepCreateAMI{}, &stepCreateAMI{},
&awscommon.StepAMIRegionCopy{
Regions: b.config.AMIRegions,
Tags: b.config.Tags,
},
&awscommon.StepCreateTags{Tags: b.config.Tags}, &awscommon.StepCreateTags{Tags: b.config.Tags},
&awscommon.StepModifyAMIAttributes{ &awscommon.StepModifyAMIAttributes{
Description: b.config.AMIDescription, Description: b.config.AMIDescription,
Users: b.config.AMIUsers, Users: b.config.AMIUsers,
Groups: b.config.AMIGroups, Groups: b.config.AMIGroups,
}, },
&awscommon.StepAMIRegionCopyAttributes{
Regions: b.config.AMIRegions,
Tags: b.config.Tags,
},
} }
// Run! // Run!
......
...@@ -211,6 +211,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe ...@@ -211,6 +211,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&StepBundleVolume{}, &StepBundleVolume{},
&StepUploadBundle{}, &StepUploadBundle{},
&StepRegisterAMI{}, &StepRegisterAMI{},
&awscommon.StepAMIRegionCopy{
Regions: b.config.AMIRegions,
Tags: b.config.Tags,
},
&awscommon.StepCreateTags{Tags: b.config.Tags}, &awscommon.StepCreateTags{Tags: b.config.Tags},
&awscommon.StepModifyAMIAttributes{ &awscommon.StepModifyAMIAttributes{
Description: b.config.AMIDescription, Description: b.config.AMIDescription,
...@@ -218,10 +222,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe ...@@ -218,10 +222,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
Groups: b.config.AMIGroups, Groups: b.config.AMIGroups,
ProductCodes: b.config.AMIProductCodes, ProductCodes: b.config.AMIProductCodes,
}, },
&awscommon.StepAMIRegionCopyAttributes{
Regions: b.config.AMIRegions,
Tags: b.config.Tags,
},
} }
// Run! // Run!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment