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

Add vnet param to tunnel routes #1668

Merged
merged 11 commits into from Jun 10, 2022
Merged

Conversation

vavsab
Copy link
Contributor

@vavsab vavsab commented Jun 2, 2022

Add missing vnet param
Closes #1605

@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2022

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.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2022

This project handles dependency version bumps (including upstream changes from cloudflare-go) independently of the standard PR process using automation. This allows the dependency upgrades to land without causing merge conflicts in multiple branches and handled in a consistent way. The exception to this is security related dependency upgrades but they should be co-ordinated with the maintainer team privately.

Please remove the changes to the go.mod or go.sum files from this PR in order to proceed with review and merging.

@vavsab vavsab marked this pull request as ready for review June 8, 2022 06:59
@vavsab vavsab requested a review from jacobbednarz as a code owner June 8, 2022 06:59
d.SetId(newTunnelRoute.Network)
if virtualNetworkID != "" {
// It's possible to create several routes with the same network but different virtual network ids.
d.SetId(fmt.Sprintf("%s/%s", newTunnelRoute.Network, virtualNetworkID))
Copy link
Member

Choose a reason for hiding this comment

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

if you are doing this, you'll want to make virtual_network_id ForceNew otherwise, the underlying ID will change everytime the virtual_network_id updates and you'll have issues in Update/Read operations.

we should also use stringChecksum to keep the ID value looking consistent with others.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image
Have not found a way to update vnet. Changed it for ForceNew and used stringChecksum (btw, do you know why we need to use it (except following project code style)?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We always had slashes in ID even before (because CIDR always contains slash) but were not using stringChecksum.. so what is the real purpose?

if err != nil {
return diag.FromErr(fmt.Errorf("error deleting Tunnel Route for Network %q: %w", d.Get("network").(string), err))
return diag.FromErr(fmt.Errorf("error deleting Tunnel Route for Network %q: %w", network, err))
}

return nil
}

func resourceCloudflareTunnelRouteImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
Copy link
Member

Choose a reason for hiding this comment

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

this seems unnecessarily complex; let's just force it to include the virtual_network_id for explicitness.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As a cloudflared user I know that vnet is totally optional param there.
Making it required during import will create additional headache for developers that are always working inside of the "default" vnet since it's not easy at all to get GUID of the default vnet (you cannot do it through UI. Only by using API or cloudflared).

But anyway for me it does not make any difference. So let's make it required.

@jacobbednarz
Copy link
Member

as you've updated the templates directory, we'll also need to run make docs to generate the docs equivalent. or if you really want, swap this resource over to the autogenerating documentation in this PR 😄

@vavsab
Copy link
Contributor Author

vavsab commented Jun 9, 2022

No problem. Will do 🙂

@vavsab vavsab requested a review from jacobbednarz June 9, 2022 11:17
@jacobbednarz jacobbednarz merged commit 09b9006 into cloudflare:master Jun 10, 2022
@jacobbednarz
Copy link
Member

awesome 🍭 thanks!

@github-actions github-actions bot added this to the v3.17.0 milestone Jun 10, 2022
@github-actions
Copy link
Contributor

This functionality has been released in v3.17.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.

Improvement: add the virtual_network_id reference to cloudflare_tunnel_route resource
2 participants