Merge pull request #48 from terraform-providers/svh/f-user-data

Allow user-data to be plain text or base64 encoded text
diff --git a/cloudstack/resource_cloudstack_instance.go b/cloudstack/resource_cloudstack_instance.go
index c3bd057..101e93d 100644
--- a/cloudstack/resource_cloudstack_instance.go
+++ b/cloudstack/resource_cloudstack_instance.go
@@ -612,7 +612,10 @@
 
 // getUserData returns the user data as a base64 encoded string
 func getUserData(userData string, httpGetOnly bool) (string, error) {
-	ud := base64.StdEncoding.EncodeToString([]byte(userData))
+	ud := userData
+	if _, err := base64.StdEncoding.DecodeString(ud); err != nil {
+		ud = base64.StdEncoding.EncodeToString([]byte(userData))
+	}
 
 	// deployVirtualMachine uses POST by default, so max userdata is 32K
 	maxUD := 32768
diff --git a/website/docs/r/instance.html.markdown b/website/docs/r/instance.html.markdown
index cee1d4a..71b05e4 100644
--- a/website/docs/r/instance.html.markdown
+++ b/website/docs/r/instance.html.markdown
@@ -68,7 +68,7 @@
     created. Changing this forces a new resource to be created.
 
 * `user_data` - (Optional) The user data to provide when launching the
-    instance.
+    instance. This can be either plain text or base64 encoded text.
 
 * `keypair` - (Optional) The name of the SSH key pair that will be used to
     access this instance.