From 4bc8e7de3da46e35bc1d3f248a7310ff08840455 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Mon, 28 Aug 2017 11:51:37 -0700 Subject: [PATCH] add token variable to upload bundle command template --- builder/amazon/instance/step_upload_bundle.go | 4 ++++ website/source/docs/builders/amazon-instance.html.md | 3 +++ 2 files changed, 7 insertions(+) diff --git a/builder/amazon/instance/step_upload_bundle.go b/builder/amazon/instance/step_upload_bundle.go index ef4aed5e0..8e9a5f283 100644 --- a/builder/amazon/instance/step_upload_bundle.go +++ b/builder/amazon/instance/step_upload_bundle.go @@ -15,6 +15,7 @@ type uploadCmdData struct { ManifestPath string Region string SecretKey string + Token string } type StepUploadBundle struct { @@ -40,11 +41,13 @@ func (s *StepUploadBundle) Run(state multistep.StateBag) multistep.StepAction { secretKey := config.SecretKey session, err := config.AccessConfig.Session() accessConfig := session.Config + var token string if err == nil && accessKey == "" && secretKey == "" { credentials, err := accessConfig.Credentials.Get() if err == nil { accessKey = credentials.AccessKeyID secretKey = credentials.SecretAccessKey + token = credentials.SessionToken } } @@ -55,6 +58,7 @@ func (s *StepUploadBundle) Run(state multistep.StateBag) multistep.StepAction { ManifestPath: manifestPath, Region: region, SecretKey: secretKey, + Token: token, } config.BundleUploadCommand, err = interpolate.Render(config.BundleUploadCommand, &config.ctx) if err != nil { diff --git a/website/source/docs/builders/amazon-instance.html.md b/website/source/docs/builders/amazon-instance.html.md index c63e537a5..42b025b02 100644 --- a/website/source/docs/builders/amazon-instance.html.md +++ b/website/source/docs/builders/amazon-instance.html.md @@ -457,3 +457,6 @@ sudo -i -n ec2-upload-bundle \ The available template variables should be self-explanatory based on the parameters they're used to satisfy the `ec2-upload-bundle` command. +Additionally, `{{.Token}}` is available when overriding this command. You must +create your own bundle command with the addition of `-t {{.Token}} ` if you are +assuming a role.