Skip to content

Commit

Permalink
resource/aws_route_table: Add documentation/warnings for import behavior
Browse files Browse the repository at this point in the history
This adds warnings and work around information related to the bug
detailed in hashicorp#5631.
  • Loading branch information
YakDriver committed Aug 30, 2018
1 parent a47ddea commit 4a3e1a6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions aws/import_aws_route_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package aws

import (
"fmt"
"log"

"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform/helper/schema"
Expand Down Expand Up @@ -30,6 +31,9 @@ func resourceAwsRouteTableImportState(
results := make([]*schema.ResourceData, 1,
2+len(table.Associations)+len(table.Routes))
results[0] = d
log.Print("[WARN] RouteTable imports will be handled differently in a future version.")
log.Printf("[WARN] This import will create %d resources (aws_route_table, aws_route, aws_route_table_association).", len(results))
log.Print("[WARN] In the future, only 1 aws_route_table resource will be created with inline routes.")

{
// Construct the routes
Expand Down
9 changes: 9 additions & 0 deletions website/docs/guides/version-2-upgrade.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Upgrade topics:
- [Resource: aws_instance](#resource-aws_instance)
- [Resource: aws_network_acl](#resource-aws_network_acl)
- [Resource: aws_redshift_cluster](#resource-aws_redshift_cluster)
- [Resource: aws_route_table](#resource-aws_route_table)
- [Resource: aws_wafregional_byte_match_set](#resource-aws_wafregional_byte_match_set)

<!-- /TOC -->
Expand Down Expand Up @@ -591,6 +592,14 @@ resource "aws_redshift_cluster" "example" {
}
```

## Resource: aws_route_table

### Import Change

Previously, importing this resource resulted in an `aws_route` resource for each route, in
addition to the `aws_route_table`, in the Terraform state. Support for importing `aws_route` resources has been added and importing this resource only adds the `aws_route_table`
resource, with in-line routes, to the state.

## Resource: aws_wafregional_byte_match_set

### byte_match_tuple Argument Removal
Expand Down
7 changes: 5 additions & 2 deletions website/docs/r/route_table.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ attribute once the route resource is created.

## Import

Route Tables can be imported using the `route table id`, e.g.
~> **NOTE:** Importing this resource currently adds an `aws_route` resource to the state for each route, in addition to adding the `aws_route_table` resource. If you plan to apply the imported state, avoid the deletion of actual routes by not using in-line routes in your configuration and by naming `aws_route` resources after the `aws_route_table`. For example, if your route table is `aws_route_table.rt`, name routes as `aws_route.rt`, `aws_route.rt-1` and so forth. The behavior of adding `aws_route` resources with the `aws_route_table` resource will be removed in the next major version.

Route Tables can be imported using the route table `id`. For example, to import
route table `rtb-4e616f6d69`, use this command:

```
$ terraform import aws_route_table.public_rt rtb-22574640
$ terraform import aws_route_table.public_rt rtb-4e616f6d69
```

0 comments on commit 4a3e1a6

Please sign in to comment.