|
|
|
|
@ -2,6 +2,7 @@ package aws
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"log"
|
|
|
|
|
"os"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
@ -34,6 +35,45 @@ func TestAccAWSVPCPeeringConnection_basic(t *testing.T) {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAccAWSVPCPeeringConnection_plan(t *testing.T) {
|
|
|
|
|
var connection ec2.VpcPeeringConnection
|
|
|
|
|
|
|
|
|
|
// reach out and DELETE the VPC Peering connection outside of Terraform
|
|
|
|
|
testDestroy := func(*terraform.State) error {
|
|
|
|
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
|
|
|
|
log.Printf("[DEBUG] Test deleting VPC Peering connection")
|
|
|
|
|
_, err := conn.DeleteVpcPeeringConnection(
|
|
|
|
|
&ec2.DeleteVpcPeeringConnectionInput{
|
|
|
|
|
VpcPeeringConnectionId: connection.VpcPeeringConnectionId,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
|
PreCheck: func() {
|
|
|
|
|
testAccPreCheck(t)
|
|
|
|
|
if os.Getenv("AWS_ACCOUNT_ID") == "" {
|
|
|
|
|
t.Fatal("AWS_ACCOUNT_ID must be set")
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Providers: testAccProviders,
|
|
|
|
|
CheckDestroy: testAccCheckAWSVpcPeeringConnectionDestroy,
|
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
|
resource.TestStep{
|
|
|
|
|
Config: testAccVpcPeeringConfig,
|
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
|
testAccCheckAWSVpcPeeringConnectionExists("aws_vpc_peering_connection.foo", &connection),
|
|
|
|
|
testDestroy,
|
|
|
|
|
),
|
|
|
|
|
ExpectNonEmptyPlan: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAccAWSVPCPeeringConnection_tags(t *testing.T) {
|
|
|
|
|
var connection ec2.VpcPeeringConnection
|
|
|
|
|
peerId := os.Getenv("TF_PEER_ID")
|
|
|
|
|
@ -93,9 +133,12 @@ func testAccCheckAWSVpcPeeringConnectionDestroy(s *terraform.State) error {
|
|
|
|
|
return fmt.Errorf("Found vpc peering connection in unexpected state: %s", pc)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// return error here; we've found the vpc_peering object we want, however
|
|
|
|
|
// it's not in an expected state
|
|
|
|
|
return fmt.Errorf("Fall through error for testAccCheckAWSVpcPeeringConnectionDestroy")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fmt.Errorf("Fall through error for testAccCheckAWSVpcPeeringConnectionDestroy")
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func testAccCheckAWSVpcPeeringConnectionExists(n string, connection *ec2.VpcPeeringConnection) resource.TestCheckFunc {
|
|
|
|
|
@ -130,6 +173,9 @@ func testAccCheckAWSVpcPeeringConnectionExists(n string, connection *ec2.VpcPeer
|
|
|
|
|
const testAccVpcPeeringConfig = `
|
|
|
|
|
resource "aws_vpc" "foo" {
|
|
|
|
|
cidr_block = "10.0.0.0/16"
|
|
|
|
|
tags {
|
|
|
|
|
Name = "TestAccAWSVPCPeeringConnection_basic"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "aws_vpc" "bar" {
|
|
|
|
|
@ -146,6 +192,9 @@ resource "aws_vpc_peering_connection" "foo" {
|
|
|
|
|
const testAccVpcPeeringConfigTags = `
|
|
|
|
|
resource "aws_vpc" "foo" {
|
|
|
|
|
cidr_block = "10.0.0.0/16"
|
|
|
|
|
tags {
|
|
|
|
|
Name = "TestAccAWSVPCPeeringConnection_tags"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "aws_vpc" "bar" {
|
|
|
|
|
|