From 44f259bd74d6b24f91ad581613cb14601b45667d Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Fri, 13 Nov 2015 11:21:22 -0600 Subject: [PATCH] provider/aws: homedir expand in s3 object source fixes #3856 --- builtin/providers/aws/resource_aws_s3_bucket_object.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_s3_bucket_object.go b/builtin/providers/aws/resource_aws_s3_bucket_object.go index b1c399dd1114..ca10cf4cb3ee 100644 --- a/builtin/providers/aws/resource_aws_s3_bucket_object.go +++ b/builtin/providers/aws/resource_aws_s3_bucket_object.go @@ -8,6 +8,7 @@ import ( "os" "github.com/hashicorp/terraform/helper/schema" + "github.com/mitchellh/go-homedir" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -95,7 +96,11 @@ func resourceAwsS3BucketObjectPut(d *schema.ResourceData, meta interface{}) erro if v, ok := d.GetOk("source"); ok { source := v.(string) - file, err := os.Open(source) + path, err := homedir.Expand(source) + if err != nil { + return fmt.Errorf("Error expanding homedir in source (%s): %s", source, err) + } + file, err := os.Open(path) if err != nil { return fmt.Errorf("Error opening S3 bucket object source (%s): %s", source, err) }