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

adds cloudflare_teams_route and acceptance tests #1572

Merged
merged 2 commits into from
Apr 22, 2022

Conversation

terinjokes
Copy link
Contributor

No description provided.

@github-actions
Copy link
Contributor

Oops! It looks like no changelog entry is attached to this PR. Please include a release note as described in https://github.com/cloudflare/terraform-provider-cloudflare/blob/master/docs/changelog-process.md.

Example:

```release-note:TYPE
Release note
```

If you do not require a release note to be included, please add the workflow/skip-changelog-entry label.

@terinjokes terinjokes force-pushed the teams_route branch 2 times, most recently from 6e4a326 to 287e36c Compare April 21, 2022 17:44
@terinjokes terinjokes force-pushed the teams_route branch 2 times, most recently from 4b2e54d to cac449a Compare April 22, 2022 02:05
@jacobbednarz jacobbednarz linked an issue Apr 22, 2022 that may be closed by this pull request
@jacobbednarz jacobbednarz merged commit 1cc74ba into cloudflare:master Apr 22, 2022
@github-actions github-actions bot added this to the v3.14.0 milestone Apr 22, 2022
func resourceCloudflareTeamsRouteImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
attributes := strings.SplitN(d.Id(), "/", 3)

if len(attributes) != 2 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import doesn't seem like it'll work as it splits into 3 parts but looks for only 2 here. Similarly, since the read function only uses the account_id and network to find the route, shouldn't import just require those two fields? tunnel_id here isn't actually used, as the read call overrides it from the api response.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I originally implemented it with a different API call where tunnel_id was required. I'll send a follow-up PR in a few moments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doh. i hadn't noticed you'd responded ... and just submitted a pr myself ... feel free to kill mine if you've got one.

func resourceCloudflareTeamsRouteRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*cloudflare.API)

tunnelRoute, err := client.GetTunnelRouteForIP(context.Background(), cloudflare.TunnelRoutesForIPParams{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of this to read the resource seems fragile. If you are managing two routes, say 10.0.0.0/8 and 10.10.0.0/24 via terraform and 10.10.0.0/24 gets manually removed on accident ... terraform will scan resources and actually find the route for 10.0.0.0/8 for the 10.10.0.0/24 resource. Was it not feasible to use the List Tunnel Routes API passing in the tunnel_id parameter to specify an exact tunnel?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, perhaps this should verify the network returned is an exact match for what was requested to prevent this?

Copy link
Contributor

@tjstansell tjstansell Apr 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess more than one network could route to the same tunnel, but you could pass in network_subnet=10.10.0.0/24 and network_superset=10.10.0.0/24 to get the exact route. And probably include is_deleted=false too ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take a look at doing that instead. It's a lot of workaround for an endpoint that doesn't follow the normal pattern of the V4 API.

Network: d.Get("network").(string),
}

if comment, ok := d.Get("comment").(string); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have a comment in a resource and then simply delete the line with the intent to remove the comment, will it remove it? Perhaps the comment parameter should have a default of "" so it's always set to something since the API seems to always return an empty string as the comment field.

@terinjokes terinjokes deleted the teams_route branch April 26, 2022 20:49
@github-actions
Copy link
Contributor

github-actions bot commented May 3, 2022

This functionality has been released in v3.14.0 of the Terraform Cloudflare Provider.

Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: add cloudflare_argo_tunnel_route resource
3 participants