-
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
New Data Source: cloudflare_zones #168
Conversation
63107b6
to
22f3ec2
Compare
1. Tested website manually 2. Tested website with `make website-test` 3. Tested new data source with new integration tests Signed-off-by: Edward Wilde <[email protected]>
22f3ec2
to
ac8b484
Compare
data "cloudflare_zones" "examples_domains" { | ||
filter { | ||
zone = "baa.*" | ||
paused = "${cloudflare_zone.foo_net.paused}" // true |
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.
Hack This might look a bit weird, but it's necessary to reference a resource here so it gets created before the data source look up executes.
I did try referencing the test zones from the data source using depends_on
attribute, but this caused a test failure during the check plan diff
is empty phase.
cloudflare/data_source_zones.go
Outdated
MaxItems: 1, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"zone": { |
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 rename it to name
, in consistency with the API?
Thanks @ewilde ! |
The initial implementation of the datasource had the provider request all the available zones and then we would perform some logic within the provider to filter down to the match the attributes. This is slightly inefficient for a couple of reasons: - We are requesting *all* zones (even if we only want a small subset of them); and - We are duplicating the zone filtering logic in the provider that is already available in the API This change replaces that functionality by pushing the responsibility of filtering back to the API. It maintains a reasonable amount of backwards compatibility outlined in the initial PR (cloudflare#168) where the "name" had to accept wildcards but under the hood accepted a full regex. Instead, we use the `contains:` modifier on the name search parameter which will instead fuzzy match. The rest remains the same but is performed via the API. Fixes cloudflare#707
This PR adds support for a new data source
cloudflare_zones
. To look up zones based on a filtercloudflare_zones
Use this data source to look up [Zone][1] records.
Example Usage
The example below matches all
active
zones that begin withexample.
and are not paused. The matched zones are thenlocked down using the
cloudflare_zone_lockdown
resource.Argument Reference
filter
- (Required) filter - (Optional) One or more values filter off of. It more than one value is given all valuesmust match, see below for full list.
filter
zone
- (Optional) A regular expression matching the zone to lookup.status
- (Optional) Status of the zone to lookup. Valid values: active, pending, initializing, moved, deleted, deactivated and read only.paused
- (Optional) Paused status of the zone to lookup. Valid values aretrue
orfalse
.Attributes Reference
zones
- A list of zone names[1]: https://api.cloudflare.com/#zone-properties
Testing
make website-test
Signed-off-by: Edward Wilde [email protected]