From 1447af5e42dcdfdef6b51ff19b68440516dfa7e5 Mon Sep 17 00:00:00 2001 From: Ian Glover Date: Thu, 13 Aug 2015 14:58:15 +0100 Subject: [PATCH] Populate access and secret key for bundle_upload_command. --- builder/amazon/instance/step_upload_bundle.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/builder/amazon/instance/step_upload_bundle.go b/builder/amazon/instance/step_upload_bundle.go index 8e3a960b2..fc641e1c6 100644 --- a/builder/amazon/instance/step_upload_bundle.go +++ b/builder/amazon/instance/step_upload_bundle.go @@ -36,13 +36,24 @@ func (s *StepUploadBundle) Run(state multistep.StateBag) multistep.StepAction { return multistep.ActionHalt } + accessKey := config.AccessKey + secretKey := config.SecretKey + accessConfig, err := config.AccessConfig.Config() + if err == nil && accessKey == "" && secretKey == "" { + credentials, err := accessConfig.Credentials.Get() + if err == nil { + accessKey = credentials.AccessKeyID + secretKey = credentials.SecretAccessKey + } + } + config.ctx.Data = uploadCmdData{ - AccessKey: config.AccessKey, + AccessKey: accessKey, BucketName: config.S3Bucket, BundleDirectory: config.BundleDestination, ManifestPath: manifestPath, Region: region, - SecretKey: config.SecretKey, + SecretKey: secretKey, } config.BundleUploadCommand, err = interpolate.Render(config.BundleUploadCommand, &config.ctx) if err != nil {