Skip to content
This repository has been archived by the owner on Jul 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #48 from terraform-providers/svh/f-user-data
Browse files Browse the repository at this point in the history
Allow user-data to be plain text or base64 encoded text
  • Loading branch information
Sander van Harmelen committed Dec 27, 2018
2 parents 16c388d + edc2258 commit 4a61ae7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cloudstack/resource_cloudstack_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,10 @@ func resourceCloudStackInstanceDelete(d *schema.ResourceData, meta interface{})

// 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
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The following arguments are supported:
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.
Expand Down

0 comments on commit 4a61ae7

Please sign in to comment.