Fix error when refreshing on a deleted AWS subnet

If a subnet exists in the state file and a refresh is performed, the
read function for subnets would return an error. Now it updates the
state to indicate that the subnet no longer exists, so Terraform can
plan to recreate it.
This commit is contained in:
Phil Frost 2015-01-29 11:06:40 -05:00
parent 6947ba2518
commit 04e86697fb
1 changed files with 5 additions and 0 deletions

View File

@ -94,6 +94,11 @@ func resourceAwsSubnetRead(d *schema.ResourceData, meta interface{}) error {
resp, err := ec2conn.DescribeSubnets([]string{d.Id()}, ec2.NewFilter())
if err != nil {
if ec2err, ok := err.(*ec2.Error); ok && ec2err.Code == "InvalidSubnetID.NotFound" {
// Update state to indicate the subnet no longer exists.
d.SetId("")
return nil
}
return err
}
if resp == nil {