From d5f23aec0a5c795635687386ebf9430f787c1b10 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Fri, 13 Mar 2015 10:54:00 -0500 Subject: [PATCH] provider/aws: Fix encoding bug with AWS Instance --- builtin/providers/aws/resource_aws_instance.go | 3 ++- builtin/providers/aws/resource_aws_instance_test.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/resource_aws_instance.go b/builtin/providers/aws/resource_aws_instance.go index 5475e7454..6ffd6a983 100644 --- a/builtin/providers/aws/resource_aws_instance.go +++ b/builtin/providers/aws/resource_aws_instance.go @@ -3,6 +3,7 @@ package aws import ( "bytes" "crypto/sha1" + "encoding/base64" "encoding/hex" "fmt" "log" @@ -258,7 +259,7 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error { // Figure out user data userData := "" if v := d.Get("user_data"); v != nil { - userData = v.(string) + userData = base64.StdEncoding.EncodeToString([]byte(v.(string))) } placement := &ec2.Placement{ diff --git a/builtin/providers/aws/resource_aws_instance_test.go b/builtin/providers/aws/resource_aws_instance_test.go index 3a9c16588..a9d439591 100644 --- a/builtin/providers/aws/resource_aws_instance_test.go +++ b/builtin/providers/aws/resource_aws_instance_test.go @@ -392,7 +392,7 @@ resource "aws_instance" "foo" { instance_type = "m1.small" security_groups = ["${aws_security_group.tf_test_foo.name}"] - user_data = "foo" + user_data = "foo:-with-character's" } `