Support session token in AWS credentials

Session tokens are necessary to utilize temporary credentials.
http://docs.aws.amazon.com/STS/latest/UsingSTS/Welcome.html
This commit is contained in:
Phil Frost 2015-04-20 14:26:59 -04:00
parent 97482f8b0c
commit d4c8c528e0
1 changed files with 13 additions and 0 deletions

View File

@ -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),
}