Check for ecr repository and policy removal

This commit is contained in:
nextrevision 2015-12-22 11:04:07 -05:00
parent 6a3ed429ad
commit 27b8dd08e7
1 changed files with 12 additions and 4 deletions

View File

@ -67,9 +67,14 @@ func resourceAwsEcrRepositoryPolicyRead(d *schema.ResourceData, meta interface{}
RepositoryName: aws.String(d.Id()),
})
if err != nil {
if ecrerr, ok := err.(awserr.Error); ok && ecrerr.Code() == "RepositoryPolicyNotFoundException" {
if ecrerr, ok := err.(awserr.Error); ok {
switch ecrerr.Code() {
case "RepositoryNotFoundException", "RepositoryPolicyNotFoundException":
d.SetId("")
return nil
default:
return err
}
}
return err
}
@ -119,9 +124,12 @@ func resourceAwsEcrRepositoryPolicyDelete(d *schema.ResourceData, meta interface
})
if err != nil {
if ecrerr, ok := err.(awserr.Error); ok {
if ecrerr.Code() == "RepositoryPolicyNotFoundException" || ecrerr.Code() == "RepositoryNotFoundException" {
switch ecrerr.Code() {
case "RepositoryNotFoundException", "RepositoryPolicyNotFoundException":
d.SetId("")
return nil
default:
return err
}
}
return err