user_data support
Mostly stolen from: https://github.com/jtopjian/terraform-provider-openstack/blob/master/openstack/resource_openstack_instance.go
This commit is contained in:
parent
2e37784065
commit
0092946f74
|
@ -2,6 +2,8 @@ package openstack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/sha1"
|
||||||
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
@ -75,6 +77,21 @@ func resourceComputeInstanceV2() *schema.Resource {
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: false,
|
ForceNew: false,
|
||||||
},
|
},
|
||||||
|
"user_data": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: true,
|
||||||
|
// just stash the hash for state & diff comparisons
|
||||||
|
StateFunc: func(v interface{}) string {
|
||||||
|
switch v.(type) {
|
||||||
|
case string:
|
||||||
|
hash := sha1.Sum([]byte(v.(string)))
|
||||||
|
return hex.EncodeToString(hash[:])
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
"security_groups": &schema.Schema{
|
"security_groups": &schema.Schema{
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
@ -224,6 +241,7 @@ func resourceComputeInstanceV2Create(d *schema.ResourceData, meta interface{}) e
|
||||||
Metadata: resourceInstanceMetadataV2(d),
|
Metadata: resourceInstanceMetadataV2(d),
|
||||||
ConfigDrive: d.Get("config_drive").(bool),
|
ConfigDrive: d.Get("config_drive").(bool),
|
||||||
AdminPass: d.Get("admin_pass").(string),
|
AdminPass: d.Get("admin_pass").(string),
|
||||||
|
UserData: []byte(d.Get("user_data").(string)),
|
||||||
}
|
}
|
||||||
|
|
||||||
if keyName, ok := d.Get("key_pair").(string); ok && keyName != "" {
|
if keyName, ok := d.Get("key_pair").(string); ok && keyName != "" {
|
||||||
|
|
Loading…
Reference in New Issue