github.com/mohanarpit/terraform@v0.6.16-0.20160909104007-291f29853544/builtin/providers/aws/import_aws_cloudfront_distribution.go (about) 1 package aws 2 3 import ( 4 "github.com/aws/aws-sdk-go/aws" 5 "github.com/aws/aws-sdk-go/service/cloudfront" 6 "github.com/hashicorp/terraform/helper/schema" 7 ) 8 9 func resourceAwsCloudFrontDistributionImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { 10 conn := meta.(*AWSClient).cloudfrontconn 11 id := d.Id() 12 resp, err := conn.GetDistributionConfig(&cloudfront.GetDistributionConfigInput{ 13 Id: aws.String(id), 14 }) 15 16 if err != nil { 17 return nil, err 18 } 19 20 distConfig := resp.DistributionConfig 21 results := make([]*schema.ResourceData, 1) 22 err = flattenDistributionConfig(d, distConfig) 23 if err != nil { 24 return nil, err 25 } 26 results[0] = d 27 return results, nil 28 }