Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing aws_route difference after apply. #5321

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions builtin/providers/aws/resource_aws_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,19 @@ func resourceAwsRoute() *schema.Resource {
"gateway_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"nat_gateway_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"instance_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"instance_owner_id": &schema.Schema{
Expand All @@ -60,6 +63,7 @@ func resourceAwsRoute() *schema.Resource {
"network_interface_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"origin": &schema.Schema{
Expand Down
73 changes: 71 additions & 2 deletions builtin/providers/aws/resource_aws_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ func TestAccAWSRoute_basic(t *testing.T) {
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
PreCheck: func() {
testAccPreCheck(t)
},
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSRouteDestroy,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -93,7 +95,9 @@ func TestAccAWSRoute_changeCidr(t *testing.T) {
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
PreCheck: func() {
testAccPreCheck(t)
},
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSRouteDestroy,
Steps: []resource.TestStep{
Expand All @@ -116,6 +120,44 @@ func TestAccAWSRoute_changeCidr(t *testing.T) {
})
}

func TestAccAWSRoute_noopdiff(t *testing.T) {
var route ec2.Route
var routeTable ec2.RouteTable

testCheck := func(s *terraform.State) error {
return nil
}

testCheckChange := func(s *terraform.State) error {
return nil
}

resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
},
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSRouteDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSRouteNoopChange,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSRouteExists("aws_route.test", &route),
testCheck,
),
},
resource.TestStep{
Config: testAccAWSRouteNoopChange,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSRouteExists("aws_route.test", &route),
testAccCheckRouteTableExists("aws_route_table.test", &routeTable),
testCheckChange,
),
},
},
})
}

// Acceptance test if mixed inline and external routes are implemented
/*
func TestAccAWSRoute_mix(t *testing.T) {
Expand Down Expand Up @@ -296,3 +338,30 @@ resource "aws_route" "bar" {
gateway_id = "${aws_internet_gateway.foo.id}"
}
`)

var testAccAWSRouteNoopChange = fmt.Sprint(`
resource "aws_vpc" "test" {
cidr_block = "10.10.0.0/16"
}

resource "aws_route_table" "test" {
vpc_id = "${aws_vpc.test.id}"
}

resource "aws_subnet" "test" {
vpc_id = "${aws_vpc.test.id}"
cidr_block = "10.10.10.0/24"
}

resource "aws_route" "test" {
route_table_id = "${aws_route_table.test.id}"
destination_cidr_block = "0.0.0.0/0"
instance_id = "${aws_instance.nat.id}"
}

resource "aws_instance" "nat" {
ami = "ami-9abea4fb"
instance_type = "t2.nano"
subnet_id = "${aws_subnet.test.id}"
}
`)