-
Notifications
You must be signed in to change notification settings - Fork 630
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
[WIP] New Resource: cloudflare_spectrum_app #156
Conversation
bfa4322
to
cfa0ec2
Compare
e8a9b45
to
bb8e2dd
Compare
@jacobbednarz this PR is ready for review (failing CI pending merge of cloudflare/cloudflare-go#253) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an awesome start! Some comments/discussions inline.
cloudflare/data_source_zone.go
Outdated
"regexp" | ||
) | ||
|
||
func dataSourceCloudflareZone() *schema.Resource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little uncertain on whether a data source for a zone is needed as I would have expected that should you need the details, you would have defined the resource already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jacobbednarz, great question. I should have put some context around this in the PR text. Actually we don't plan to manage the zone
resource in the same terraform project. We prefer to delegate permission to that important resource to another project, which is only accessible to a team with a different set of credentials. This is why i thought the datasource would be so useful. It's how we currently manage our route53, using a datasource to lookup the zone_id
and then passing that when creating related resources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very interesting (and sensible!) use case. I'm 👌 with this approach given the context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the idea of Zone data source, in fact I've been asked for the same thing internally (a list of zones currently added to an account), but let's pull this out of this PR and create a separate PR.
1 PR == 1 feature
bb8e2dd
to
ab0f712
Compare
@jacobbednarz thanks for the review, I've hopefully addressed all the comments corrects and marked the conversations as resolved with a comment |
cloudflare/data_source_zone.go
Outdated
Type: schema.TypeString, | ||
}, | ||
}, | ||
"meta": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you determine where to draw the line with the fields here? I noticed there are a few missing from our enterprise accounts and was curious if it was intended. Happy to provide an anonymised output if you don't have visibility into the full listing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the attributes from the resource_cloudflare_zone
, these look reasonable for a first attempt
ab0f712
to
9648cba
Compare
@jacobbednarz thanks for another review 😄 all suggestions should be pushed now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine to me, great job! 🌟
There are a bunch of unrelated changes in this PR but I suspect it's a side effect of you force pushing and not rebasing/merging in the changes without fast forwarding that is causing them to show up in here.
9648cba
to
1e3ca9e
Compare
@jacobbednarz I've rebased against |
1e3ca9e
to
1046198
Compare
Signed-off-by: Edward Wilde <[email protected]>
1046198
to
b9684be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add import section in documentation, please?
zoneName = idAttr[0] | ||
applicationID = idAttr[1] | ||
} else { | ||
return nil, fmt.Errorf("invalid id (\"%s\") specified, should be in format \"zoneName/applicationID\"", d.Id()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use Zone ID instead of name here?
testAccCheckCloudflareSpectrumApplicationIDIsValid(name), | ||
resource.TestCheckResourceAttr(name, "protocol", "tcp/22"), | ||
resource.TestCheckResourceAttr(name, "origin_direct.#", "1"), | ||
resource.TestCheckResourceAttr(name, "origin_direct.0", "tcp://120.120.102.10:23"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use reserved IP address, instead of random public one.
See: https://en.wikipedia.org/wiki/Reserved_IP_addresses
resource.TestCheckResourceAttr(name, "origin_direct.0", "tcp://120.120.102.10:23"), | |
resource.TestCheckResourceAttr(name, "origin_direct.0", "tcp://192.0.2.1:23"), |
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckCloudflareSpectrumApplicationExists(name, &spectrumApp), | ||
testAccCheckCloudflareSpectrumApplicationIDIsValid(name), | ||
resource.TestCheckResourceAttr(name, "origin_direct.0", "tcp://120.120.102.10:23"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use reserved IP here.
resource.TestCheckResourceAttr(name, "origin_direct.0", "tcp://120.120.102.10:23"), | |
resource.TestCheckResourceAttr(name, "origin_direct.0", "tcp://192.0.2.1:23"), |
} | ||
return nil | ||
}, | ||
resource.TestCheckResourceAttr(name, "origin_direct.0", "tcp://81.120.102.10:23"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use reserved IP here.
resource.TestCheckResourceAttr(name, "origin_direct.0", "tcp://81.120.102.10:23"), | |
resource.TestCheckResourceAttr(name, "origin_direct.0", "tcp://192.0.2.2:23"), |
"name" = "ssh.${data.cloudflare_zone.test.zone}" | ||
} | ||
|
||
origin_direct = ["tcp://81.120.102.10:23"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
origin_direct = ["tcp://81.120.102.10:23"] | |
origin_direct = ["tcp://192.0.2.2:23"] |
|
||
## Argument Reference | ||
|
||
* `protocol` - (Required) The port configuration at Cloudflare’s edge. i.e. `tcp/22`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `protocol` - (Required) The port configuration at Cloudflare’s edge. i.e. `tcp/22`. | |
* `protocol` - (Required) The port configuration at Cloudflare’s edge. e.g. `tcp/22`. |
|
||
* `protocol` - (Required) The port configuration at Cloudflare’s edge. i.e. `tcp/22`. | ||
* `dns` - (Required) The name and type of DNS record for the Spectrum application. Fields documented below. | ||
* `origin_direct` - (Optional) A list of destination addresses to the origin. i.e. `tcp://192.0.2.1:22`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `origin_direct` - (Optional) A list of destination addresses to the origin. i.e. `tcp://192.0.2.1:22`. | |
* `origin_direct` - (Optional) A list of destination addresses to the origin. e.g. `tcp://192.0.2.1:22`. |
* `dns` - (Required) The name and type of DNS record for the Spectrum application. Fields documented below. | ||
* `origin_direct` - (Optional) A list of destination addresses to the origin. i.e. `tcp://192.0.2.1:22`. | ||
* `origin_dns` - (Optional) A destination DNS addresses to the origin. Fields documented below. | ||
* `origin_port` - (Optional) If using `origin_dns` this is a required attribute. Origin port to proxy traffice to i.e. `22`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `origin_port` - (Optional) If using `origin_dns` this is a required attribute. Origin port to proxy traffice to i.e. `22`. | |
* `origin_port` - (Optional) If using `origin_dns` this is a required attribute. Origin port to proxy traffice to e.g. `22`. |
|
||
**origin_dns** | ||
|
||
* `name` - (Required) Fully qualified domain name of the origin i.e. origin-ssh.example.com. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `name` - (Required) Fully qualified domain name of the origin i.e. origin-ssh.example.com. | |
* `name` - (Required) Fully qualified domain name of the origin e.g. origin-ssh.example.com. |
Thanks @ewilde ! |
@patryk thanks for the review and merge, but think the tests will need updating to use the plural |
ill do this now |
Oh yes, please do. |
* The upcoming Purge by Host functionality has been added to the library * flarectl now has a `purge` sub-command for purging from cache. e.g ``` # Purge by host (upcoming) flarectl zone purge --zone=example.com --hosts="repeater.example.com" # Purge everything flarectl zone purge --zone=example.com --everything # Purge by filename flarectl zone purge --zone=example.com \ --files="http://repeater.example.com/styles.css,http://repeater.example.com/javascript.js" ```
Work in progress this PR is to add a new resource to automate cloudflare spectrum applications
Relates to #155
TODO
Test results
resource cloudflare_spectrum_app
data cloudflare_zone
Import
Website
make website-test
cloudflare_specturm_app
data cloudflare_zone