github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/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 }