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

cloudflare_argo_tunnel: add tunnel token to state #1590

Merged
merged 9 commits into from May 29, 2022

Conversation

bradleyglover
Copy link

@bradleyglover bradleyglover commented Apr 30, 2022

The cloudflared service supports passing in a token to allow a connector to authenticate and run a tunnel. This token is a base64 encoded string made up of the account ID, tunnel ID, and secret ID. Since these items are already stored in state, this PR represents a nice quality of life improvement by constructing, encoding, and storing the token in state too.

Closes #1439

@jacobbednarz
Copy link
Member

i'm going to put this one on the back burner until we land the changes from cloudflare/cloudflare-go#866 and update the methods internally. as is, this won't work because the tunnel secret is only available on the Create response; not the individual fetch. however, we did recently add a method to directly get the token via https://github.com/cloudflare/cloudflare-go/blob/master/tunnel.go#L266 which we can use instead.

@jacobbednarz jacobbednarz added the workflow/pending-upstream-library Indicates an issue or PR requires changes from an upstream library. label May 1, 2022
@jacobbednarz jacobbednarz removed the workflow/pending-upstream-library Indicates an issue or PR requires changes from an upstream library. label May 11, 2022
@jacobbednarz
Copy link
Member

the upstream changes landed this morning if you'd like to incorporate them into this PR and we can get it merged.

@bradleyglover
Copy link
Author

Nice, I'll take a stab at refactoring this tomorrow or the next day.

Looking at #1439 (comment), it seems we will expect errors setting the token state for older tunnels. Is there any example I can lean on for how the provider would handle that? aka leave the token field empty, return a message, etc?

@jacobbednarz
Copy link
Member

for older tunnels that return the 404, let's leave it empty. we can issue a diag.Warning from the Read operation to notify the end user it won't be set and perhaps recreate it if they want the token to work in Terraform. since we have a way to fetch the accurate value, we can't populate it with dummy or wrong data as people may rely on it.

@bradleyglover
Copy link
Author

Updated to use the upstream TunnelToken method, but this will not be functional until the changes from cloudflare/cloudflare-go#881 are released

@jacobbednarz jacobbednarz added the workflow/pending-upstream-library Indicates an issue or PR requires changes from an upstream library. label May 12, 2022
@jacobbednarz jacobbednarz linked an issue May 13, 2022 that may be closed by this pull request
2 tasks
.changelog/1590.txt Outdated Show resolved Hide resolved
@jacobbednarz
Copy link
Member

@bradleyglover this is ready for you to pick back up and test now.

@jacobbednarz jacobbednarz removed the workflow/pending-upstream-library Indicates an issue or PR requires changes from an upstream library. label May 25, 2022
@bradleyglover
Copy link
Author

@jacobbednarz thanks! all tests passed for me locally (with the exception of some existing lint failures)

@jacobbednarz jacobbednarz merged commit 18a570f into cloudflare:master May 29, 2022
@github-actions github-actions bot added this to the v3.16.0 milestone May 29, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jun 1, 2022

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

cloudflare_argo_tunnel import does not include secrets
2 participants