Merge pull request #40 from justincampbell/amazon-env-vars

builder/amazonebs: Default to AWS env vars for key and secret
This commit is contained in:
Mitchell Hashimoto 2013-07-01 15:11:19 -07:00
commit 94e2999b89
1 changed files with 17 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import (
"github.com/mitchellh/packer/builder/common"
"github.com/mitchellh/packer/packer"
"log"
"os"
"text/template"
"time"
)
@ -57,6 +58,22 @@ func (b *Builder) Prepare(raws ...interface{}) error {
}
}
if b.config.AccessKey == "" {
b.config.AccessKey = os.Getenv("AWS_ACCESS_KEY_ID")
}
if b.config.AccessKey == "" {
b.config.AccessKey = os.Getenv("AWS_ACCESS_KEY")
}
if b.config.SecretKey == "" {
b.config.SecretKey = os.Getenv("AWS_SECRET_ACCESS_KEY")
}
if b.config.SecretKey == "" {
b.config.SecretKey = os.Getenv("AWS_SECRET_KEY")
}
if b.config.SSHPort == 0 {
b.config.SSHPort = 22
}