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}} " + "-s {{.SecretKey}} " +
"-d {{.BundleDirectory}} " + "-d {{.BundleDirectory}} " +
"--batch " + "--batch " +
"--location {{.Region}} " +
"--retry" "--retry"
} }

View File

@ -11,6 +11,7 @@ type uploadCmdData struct {
BucketName string BucketName string
BundleDirectory string BundleDirectory string
ManifestPath string ManifestPath string
Region string
SecretKey string SecretKey string
} }
@ -23,12 +24,20 @@ func (s *StepUploadBundle) Run(state multistep.StateBag) multistep.StepAction {
manifestPath := state.Get("manifest_path").(string) manifestPath := state.Get("manifest_path").(string)
ui := state.Get("ui").(packer.Ui) 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{ config.BundleUploadCommand, err = config.tpl.Process(config.BundleUploadCommand, uploadCmdData{
AccessKey: config.AccessKey, AccessKey: config.AccessKey,
BucketName: config.S3Bucket, BucketName: config.S3Bucket,
BundleDirectory: config.BundleDestination, BundleDirectory: config.BundleDestination,
ManifestPath: manifestPath, ManifestPath: manifestPath,
Region: region.Name,
SecretKey: config.SecretKey, SecretKey: config.SecretKey,
}) })
if err != nil { if err != nil {

View File

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