hashicorp/terraform — pull request #693 by ceh (2014-12-18 05:52:50+00:00)
Title: remove unreachable code and skip unnecessary remote call

Remove unreachable code when deleting internet gateway ([L119-133]).

When DeleteInternetGateway is successful it returns a nil error value.
However, for a nil error value, the RetryFunc returns an error ([L116]) yielding a
unnecessary second call to DeleteInternetGateway in the retry logic.

The logic works because DeleteInternetGateway eventually returns an ec2.Error
with error code ```InvalidInternetGatewayID.NotFound``` since the internet gateway
has been deleted in the previous call. The return value of nil breaks the
retry logic and the deletion is deemed successful ([L107-108]).

Fix the unnecessary second call to DeleteInternetGateway by short circuiting
with a nil error value when deletion of the internet gateway is successful on
the first try.

Add an acceptance test for internet gateway deletion while here.

[L107-108]: https://github.com/hashicorp/terraform/blob/6a6ae12fd2/builtin/providers/aws/resource_aws_internet_gateway.go#L107-108
[L116]: https://github.com/hashicorp/terraform/blob/6a6ae12fd2/builtin/providers/aws/resource_aws_internet_gateway.go#L116
[L119-133]: https://github.com/hashicorp/terraform/blob/6a6ae12fd2/builtin/providers/aws/resource_aws_internet_gateway.go#L119-133