vpc vpn connection test fixes
This commit is contained in:
parent
70bb536be1
commit
558e839bf2
|
@ -5,6 +5,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/service/ec2"
|
"github.com/aws/aws-sdk-go/service/ec2"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
|
@ -44,8 +45,40 @@ func TestAccAWSVpnConnection_basic(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccAwsVpnConnectionDestroy(s *terraform.State) error {
|
func testAccAwsVpnConnectionDestroy(s *terraform.State) error {
|
||||||
if len(s.RootModule().Resources) > 0 {
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
return fmt.Errorf("Expected all resources to be gone, but found: %#v", s.RootModule().Resources)
|
for _, rs := range s.RootModule().Resources {
|
||||||
|
if rs.Type != "aws_vpn_connection" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := conn.DescribeVpnConnections(&ec2.DescribeVpnConnectionsInput{
|
||||||
|
VpnConnectionIds: []*string{aws.String(rs.Primary.ID)},
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if ec2err, ok := err.(awserr.Error); ok && ec2err.Code() == "InvalidVpnConnectionID.NotFound" {
|
||||||
|
// not found
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var vpn *ec2.VpnConnection
|
||||||
|
for _, v := range resp.VpnConnections {
|
||||||
|
if v.VpnConnectionId != nil && *v.VpnConnectionId == rs.Primary.ID {
|
||||||
|
vpn = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if vpn == nil {
|
||||||
|
// vpn connection not found
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if vpn.State != nil && *vpn.State == "deleted" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue