providers/aws: cloudfront distribution 404 should mark as gone (#10281)

This commit is contained in:
Mitchell Hashimoto 2016-12-05 05:31:05 -08:00 committed by Paul Stack
parent 5b71b40f93
commit e014cf3d83
1 changed files with 7 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import (
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/cloudfront"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/resource"
@ -527,6 +528,12 @@ func resourceAwsCloudFrontDistributionRead(d *schema.ResourceData, meta interfac
resp, err := conn.GetDistribution(params)
if err != nil {
if errcode, ok := err.(awserr.Error); ok && errcode.Code() == "NoSuchDistribution" {
log.Printf("[WARN] No Distribution found: %s", d.Id())
d.SetId("")
return nil
}
return err
}