From d4c8c528e0e15cc2de554c07617f958ce7444e1d Mon Sep 17 00:00:00 2001 From: Phil Frost Date: Mon, 20 Apr 2015 14:26:59 -0400 Subject: [PATCH] Support session token in AWS credentials Session tokens are necessary to utilize temporary credentials. http://docs.aws.amazon.com/STS/latest/UsingSTS/Welcome.html --- builtin/providers/aws/provider.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/builtin/providers/aws/provider.go b/builtin/providers/aws/provider.go index 50596512e..b420fa89a 100644 --- a/builtin/providers/aws/provider.go +++ b/builtin/providers/aws/provider.go @@ -32,6 +32,15 @@ func Provider() terraform.ResourceProvider { Description: descriptions["secret_key"], }, + "token": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.MultiEnvDefaultFunc([]string{ + "AWS_SESSION_TOKEN", + }, ""), + Description: descriptions["token"], + }, + "region": &schema.Schema{ Type: schema.TypeString, Required: true, @@ -87,6 +96,9 @@ func init() { "secret_key": "The secret key for API operations. You can retrieve this\n" + "from the 'Security & Credentials' section of the AWS console.", + + "token": "session token. A session token is only required if you are\n" + + "using temporary security credentials.", } } @@ -94,6 +106,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { config := Config{ AccessKey: d.Get("access_key").(string), SecretKey: d.Get("secret_key").(string), + Token: d.Get("token").(string), Region: d.Get("region").(string), }