fix access_key NOT FOUND bug and nat_gateway diff bug (#15050)

This commit is contained in:
He Guimin 2017-06-05 05:06:58 +08:00 committed by Paul Stack
parent 92f5a99e6a
commit c70c54bd7e
2 changed files with 21 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import (
"github.com/hashicorp/terraform/helper/mutexkv"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
"os"
)
// Provider returns a schema.Provider for alicloud
@ -67,10 +68,26 @@ func Provider() terraform.ResourceProvider {
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
accesskey, ok := d.GetOk("access_key")
if !ok {
accesskey = os.Getenv("ALICLOUD_ACCESS_KEY")
}
secretkey, ok := d.GetOk("secret_key")
if !ok {
secretkey = os.Getenv("ALICLOUD_SECRET_KEY")
}
region, ok := d.GetOk("region")
if !ok {
region = os.Getenv("ALICLOUD_REGION")
if region == "" {
region = DEFAULT_REGION
}
}
config := Config{
AccessKey: d.Get("access_key").(string),
SecretKey: d.Get("secret_key").(string),
Region: common.Region(d.Get("region").(string)),
AccessKey: accesskey.(string),
SecretKey: secretkey.(string),
Region: common.Region(region.(string)),
}
client, err := config.Client()

View File

@ -70,6 +70,7 @@ func resourceAliyunNatGateway() *schema.Resource {
"zone": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"public_ip_addresses": &schema.Schema{
Type: schema.TypeString,