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

fix team tunnel route import #1574

Closed
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
7 changes: 3 additions & 4 deletions cloudflare/resource_cloudflare_teams_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,16 @@ func resourceCloudflareTeamsRouteDelete(d *schema.ResourceData, meta interface{}
}

func resourceCloudflareTeamsRouteImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
attributes := strings.SplitN(d.Id(), "/", 3)
attributes := strings.SplitN(d.Id(), "/", 2)

if len(attributes) != 2 {
return nil, fmt.Errorf(`invalid id (%q) specified, should be in format "accountID/tunnelID/network"`, d.Id())
return nil, fmt.Errorf(`invalid id (%q) specified, should be in format "accountID/network"`, d.Id())
}

accountID, tunnelID, network := attributes[0], attributes[1], attributes[2]
accountID, network := attributes[0], attributes[1]

d.SetId(network)
d.Set("account_id", accountID)
d.Set("tunnel_id", tunnelID)
d.Set("network", network)

err := resourceCloudflareTeamsRouteRead(d, meta)
Expand Down
13 changes: 7 additions & 6 deletions website/docs/r/teams_route.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ routes are used to direct IP traffic through Cloudflare Tunnels.
## Example Usage

```hcl
resource "cloudflare_teams_route" "example"
resource "cloudflare_teams_route" "example" {
account_id = "c4a7362d577a6c3019a474fd6f485821"
tunnel_id = "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415"
network = "192.0.2.24/32"
comment = "New tunnel route for documentation"
tunnel_id = "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415"
network = "192.0.2.24/32"
comment = "New tunnel route for documentation"
}
```

## Argument Reference
Expand All @@ -32,8 +33,8 @@ The following arguments are supported:

## Import

An existing tunnel route can be imported using the account ID, tunnel ID, and network CIDR.
An existing tunnel route can be imported using the account ID and network CIDR.

```
$ terraform import cloudflare_teams_route c4a7362d577a6c3019a474fd6f485821/f70ff985-a4ef-4643-bbbc-4a0ed4fc8415/192.0.2.24/32
$ terraform import cloudflare_teams_route c4a7362d577a6c3019a474fd6f485821/192.0.2.24/32
```