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 support for Magic Transit IPsec tunnels #1404

Merged
merged 10 commits into from Jan 27, 2022

Conversation

cehrig
Copy link
Contributor

@cehrig cehrig commented Jan 22, 2022

This PR adds a new resource for managing IPsec tunnels. The resource layout looks as follows:

resource "cloudflare_ipsec_tunnel" "example" {
  account_id          = "c4a7362d577a6c3019a474fd6f485821"
  name                = "IPsec_1"
  customer_endpoint   = "203.0.113.1"
  cloudflare_endpoint = "203.0.113.2"
  interface_address   = "10.212.0.5/31"
  description         = "Tunnel for ISP X"
}

A pending cloudflare-go PR cloudflare/cloudflare-go#787 is required for this feature. The provided acceptance tests will only be working when using an account with Magic Transit support.

The Create and Update methods occasionally run into a time out. I am checking with Magic team why that happens.


func resourceCloudflareIPsecTunnelCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*cloudflare.API)
client.AccountID = d.Get("account_id").(string)
Copy link
Member

Choose a reason for hiding this comment

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

this will now need to update that we are not using the api.AccountID field and instead, pull it from the schema.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I hope I didn't miss any. I am actually not sure, how does meta behave when run in parallel on different resources with different account IDs? I think meta is not really protected from this, right?

Copy link
Member

Choose a reason for hiding this comment

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

i don't think so but i'd need to confirm the internals. it shouldn't be an issue though as in the Tenant use case, the client will be the same (authn/z) but the URLs will need to swap based on the account.

@cehrig
Copy link
Contributor Author

cehrig commented Jan 25, 2022

Magic Team implemented a fix for the API time outs we were observing. Acceptance Tests started to pass

$ go test $(go list ./...) -v -run TestAccCloudflareIPsecTunnel
?       github.com/cloudflare/terraform-provider-cloudflare     [no test files]
=== RUN   TestAccCloudflareIPsecTunnelExists
--- PASS: TestAccCloudflareIPsecTunnelExists (30.88s)
=== RUN   TestAccCloudflareIPsecTunnelUpdateDescription
--- PASS: TestAccCloudflareIPsecTunnelUpdateDescription (48.68s)
PASS
ok      github.com/cloudflare/terraform-provider-cloudflare/cloudflare  79.576s
?       github.com/cloudflare/terraform-provider-cloudflare/tools/cmd/changelog-check   [no test files]
?       github.com/cloudflare/terraform-provider-cloudflare/version     [no test files]

@jacobbednarz jacobbednarz force-pushed the magic-ipsec branch 2 times, most recently from 6c91994 to c03cde6 Compare January 27, 2022 04:07
@jacobbednarz
Copy link
Member

@cehrig this now has the latest cloudflare-go changes. do you mind running the acceptance tests against your account before i merge?

@cehrig
Copy link
Contributor Author

cehrig commented Jan 27, 2022

@cehrig this now has the latest cloudflare-go changes. do you mind running the acceptance tests against your account before i merge?

Thanks @jacobbednarz, looking good!

$ go mod vendor
go: downloading github.com/cloudflare/cloudflare-go v0.31.0
$ go test $(go list ./...) -v -run TestAccCloudflareIPsecTunnel
?       github.com/cloudflare/terraform-provider-cloudflare     [no test files]
=== RUN   TestAccCloudflareIPsecTunnelExists
--- PASS: TestAccCloudflareIPsecTunnelExists (35.37s)
=== RUN   TestAccCloudflareIPsecTunnelUpdateDescription
--- PASS: TestAccCloudflareIPsecTunnelUpdateDescription (55.68s)
PASS
ok      github.com/cloudflare/terraform-provider-cloudflare/cloudflare  91.060s
?       github.com/cloudflare/terraform-provider-cloudflare/tools/cmd/changelog-check   [no test files]
?       github.com/cloudflare/terraform-provider-cloudflare/version     [no test files]

@jacobbednarz jacobbednarz merged commit a700052 into cloudflare:master Jan 27, 2022
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.

None yet

2 participants