builder/amazon/instance: add location to upload command [GH-679]

This commit is contained in:
Mitchell Hashimoto 2013-12-06 19:04:40 -08:00
parent 48fb1f9dfb
commit f7b1c2dbc6
3 changed files with 12 additions and 1 deletions

View File

@ -74,6 +74,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
"-s {{.SecretKey}} " +
"-d {{.BundleDirectory}} " +
"--batch " +
"--location {{.Region}} " +
"--retry"
}

View File

@ -11,6 +11,7 @@ type uploadCmdData struct {
BucketName string
BundleDirectory string
ManifestPath string
Region string
SecretKey string
}
@ -23,12 +24,20 @@ func (s *StepUploadBundle) Run(state multistep.StateBag) multistep.StepAction {
manifestPath := state.Get("manifest_path").(string)
ui := state.Get("ui").(packer.Ui)
var err error
region, err := config.Region()
if err != nil {
err := fmt.Errorf("Error retrieving region: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
config.BundleUploadCommand, err = config.tpl.Process(config.BundleUploadCommand, uploadCmdData{
AccessKey: config.AccessKey,
BucketName: config.S3Bucket,
BundleDirectory: config.BundleDestination,
ManifestPath: manifestPath,
Region: region.Name,
SecretKey: config.SecretKey,
})
if err != nil {

View File

@ -273,6 +273,7 @@ sudo -n ec2-upload-bundle \
-s {{.SecretKey}} \
-d {{.BundleDirectory}} \
--batch \
--location {{.Region}} \
--retry
```