github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/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 // This is a non API attribute 11 // We are merely setting this to the same value as the Default setting in the schema 12 d.Set("retain_on_delete", false) 13 14 conn := meta.(*AWSClient).cloudfrontconn 15 id := d.Id() 16 resp, err := conn.GetDistributionConfig(&cloudfront.GetDistributionConfigInput{ 17 Id: aws.String(id), 18 }) 19 20 if err != nil { 21 return nil, err 22 } 23 24 distConfig := resp.DistributionConfig 25 results := make([]*schema.ResourceData, 1) 26 err = flattenDistributionConfig(d, distConfig) 27 if err != nil { 28 return nil, err 29 } 30 results[0] = d 31 return results, nil 32 }