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 API Support #9040

Closed
omarabid opened this issue Sep 25, 2016 · 10 comments
Closed

Cloudflare API Support #9040

omarabid opened this issue Sep 25, 2016 · 10 comments

Comments

@omarabid
Copy link

This is not a bug report but rather a feature request. The cloudflare API currently supports only the "Record" resource. The GO API Library has many other features, though.

https://godoc.org/github.com/cloudflare/cloudflare-go

Any chances of getting some of these into the Cloudflare Provider?

@apparentlymart
Copy link
Member

Hi @omarabid!

In an ideal world Terraform would be able to create everything, but with finite development time it's necessary to prioritize. If you have some specific use-cases in mind that would be helped by new resources in Terraform it would help a lot if you could describe them a little, which will help to understand which of the Cloudflare concepts would be most useful/valuable.

@jonleighton
Copy link

Personally I'd particularly like to see Page Rules supported in Terraform.

@jamestyrrell
Copy link

Yeh, Page Rules support would be excellent.

@mwarkentin
Copy link
Contributor

+1 to page rules.

@OJFord
Copy link
Contributor

OJFord commented Jan 15, 2017

I agree with page rules as most important.

Crypto>SSL and automatic HTTPS rewrites (and the other Boolean toggles on that page) are potentially low-hanging but juicy fruit too though.

It doesn't seem like it'd be too difficult (just time-consuming) to implement something else using the existing records implementation as a reference - are you open to PRs for this?

@cemo
Copy link

cemo commented Jan 15, 2017

New private beta Load Balancer feature is also worth to implement.

@elithrar
Copy link

@cemo We're going to push support for our LB API to our Go library "soon" - if you'd like to collaborate on the Terraform integration we're open to it!

(Matt S @ Cloudflare)

OJFord added a commit to OJFord/terraform that referenced this issue Jan 17, 2017
This commit adds most of the boilerplate for implementing CloudFlare
Page Rules, and implements the Create method.

`PageRuleActionValue`s still need a validator; this is complex and
depends on `PageRuleActionId`.

Read, Update, and Delete methods will throw 'not implemented' errors.

Towards hashicorp#9040.
OJFord added a commit to OJFord/terraform that referenced this issue Jan 17, 2017
This commit adds most of the boilerplate for implementing CloudFlare
Page Rules, and implements the Create method.

`PageRuleActionValue`s still need a validator; this is complex and
depends on `PageRuleActionId`.

Read, Update, and Delete methods will throw 'not implemented' errors.

Towards hashicorp#9040.
OJFord added a commit to OJFord/terraform that referenced this issue Jan 18, 2017
This commit adds most of the boilerplate for implementing CloudFlare
Page Rules, and implements the Create method.

`PageRuleActionValue`s still need a validator; this is complex and
depends on `PageRuleActionId`.

Read, Update, and Delete methods will throw 'not implemented' errors.

Towards hashicorp#9040.
OJFord added a commit to OJFord/terraform that referenced this issue Jan 18, 2017
This commit adds most of the boilerplate for implementing CloudFlare
Page Rules, and implements the Create method.

`PageRuleActionValue`s still need a validator; this is complex and
depends on `PageRuleActionId`.

Read, Update, and Delete methods will throw 'not implemented' errors.

Towards hashicorp#9040.
OJFord added a commit to OJFord/terraform that referenced this issue Jan 18, 2017
This commit adds most of the boilerplate for implementing CloudFlare
Page Rules, and implements the Create method.

`PageRuleActionValue`s still need a validator; this is complex and
depends on `PageRuleActionId`.

Read, Update, and Delete methods will throw 'not implemented' errors.

Towards hashicorp#9040.
OJFord added a commit to OJFord/terraform that referenced this issue Jan 18, 2017
This commit adds most of the boilerplate for implementing CloudFlare
Page Rules, and implements the Create method.

`PageRuleActionValue`s still need a validator; this is complex and
depends on `PageRuleActionId`.

Read, Update, and Delete methods will throw 'not implemented' errors.

Towards hashicorp#9040.
OJFord added a commit to OJFord/terraform that referenced this issue Jan 18, 2017
This commit adds most of the boilerplate for implementing CloudFlare
Page Rules, and implements the Create method.

`PageRuleActionValue`s still need a validator; this is complex and
depends on `PageRuleActionId`.

Read, Update, and Delete methods will throw 'not implemented' errors.

Towards hashicorp#9040.
OJFord added a commit to OJFord/terraform that referenced this issue Jan 18, 2017
This commit adds most of the boilerplate for implementing CloudFlare
Page Rules, and implements the Create method.

`PageRuleActionValue`s still need a validator; this is complex and
depends on `PageRuleActionId`.

Read, Update, and Delete methods will throw 'not implemented' errors.

Towards hashicorp#9040.
OJFord added a commit to OJFord/terraform that referenced this issue Jan 18, 2017
This commit adds most of the boilerplate for implementing CloudFlare
Page Rules, and implements the Create method.

`PageRuleActionValue`s still need a validator; this is complex and
depends on `PageRuleActionId`.

Read, Update, and Delete methods will throw 'not implemented' errors.

Towards hashicorp#9040.
@OJFord
Copy link
Contributor

OJFord commented Jan 20, 2017

@jonleighton @jamestyrrell @mwarkentin - Please feel free to test Page Rules with my branch (#11249) - everything I've tested 'works', in so far as the rules are created.

I am seeing an error coming out of the cloudflare-go library though, which stops terraform saving the state. I'm 90% sure it's a problem in the lib, but I could have done something wrong... YMMV so if any of you do have a chance to test (with some kind of demo, or a copy of something existing, not production of course!) it may be helpful in tracking it down. 🙂

@elithrar
Copy link

elithrar commented Jan 20, 2017 via email

OJFord added a commit to OJFord/terraform-provider-cloudflare that referenced this issue Jul 5, 2017
This commit adds most of the boilerplate for implementing CloudFlare
Page Rules, and implements the Create method.

`PageRuleActionValue`s still need a validator; this is complex and
depends on `PageRuleActionId`.

Read, Update, and Delete methods will throw 'not implemented' errors.

Towards hashicorp/terraform#9040; cloudflare#3.
OJFord added a commit to OJFord/terraform-provider-cloudflare that referenced this issue Jul 5, 2017
This commit adds most of the boilerplate for implementing CloudFlare
Page Rules, and implements the Create method.

`PageRuleActionValue`s still need a validator; this is complex and
depends on `PageRuleActionId`.

Read, Update, and Delete methods will throw 'not implemented' errors.

Towards hashicorp/terraform#9040; cloudflare#3.
benjvi pushed a commit to benjvi/terraform-provider-cloudflare that referenced this issue Mar 1, 2018
This commit adds most of the boilerplate for implementing CloudFlare
Page Rules, and implements the Create method.

`PageRuleActionValue`s still need a validator; this is complex and
depends on `PageRuleActionId`.

Read, Update, and Delete methods will throw 'not implemented' errors.

Towards hashicorp/terraform#9040; cloudflare#3.
benjvi pushed a commit to benjvi/terraform-provider-cloudflare that referenced this issue Mar 5, 2018
This commit adds most of the boilerplate for implementing CloudFlare
Page Rules, and implements the Create method.

`PageRuleActionValue`s still need a validator; this is complex and
depends on `PageRuleActionId`.

Read, Update, and Delete methods will throw 'not implemented' errors.

Towards hashicorp/terraform#9040; cloudflare#3.
catsby pushed a commit to cloudflare/terraform-provider-cloudflare that referenced this issue Mar 12, 2018
This commit adds most of the boilerplate for implementing CloudFlare
Page Rules, and implements the Create method.

`PageRuleActionValue`s still need a validator; this is complex and
depends on `PageRuleActionId`.

Read, Update, and Delete methods will throw 'not implemented' errors.

Towards hashicorp/terraform#9040; #3.

Require at least one page rule action

Simplify page rule targets API

Asking for a list of targets is just confusing to a user when Cloudflare
only accepts  a single `"url"` target.

Implement action value validation

Improve legibility

Change action Elems to be Schema

Implement Read/Update/Delete Page Rules

Simplify Page Rule action schema

This commit changes Page Rule actions to be a TypeSet of maps containing
the action ID, and optionally its sub-setting. This makes validation a
bit nicer, too.

Fix crash while running apply

Page Rule Read implementation was naïvely copying Cloudflare's returned
data structure, rather than transforming to fit schema.

Fix passing PageRuleAction value error back up

Flatten PageRule action schema

Fix flattened structure

Unfortunately, we cannot have the desired structure with a
`schema.Resource` `actions` in the main schema:

    resource "cloudflare_page_rule" "foo" {
      actions = {
        always_online = true
      }
    }

where `always_online` and other Actions are explicitly defined, since
`actions` needs to be a `schema.Schema`.

This commit moves the `Resource` inside `actions`, which now becomes a
`Schema` of `TypeSet`, which means Cloudflare's binary options such as
`always_online` will default to `false` if we have them be `TypeBool`.
To circumvent that, we instead use `TypeString` and validate `"on"` or
`"off"` (matching Cloudflare's API) - since these will be empty if not
set.

The logic's a little less clean, since we now have to loop through every
possible action type for each action in the set, testing the type and
value of its sub-setting/mode to determine if it was really set by the
user.

Document page rule resources

Appease linter

Add acceptance tests for page rules

Fix allowing multiple entries in page rule actions

Improve error reporting

get page rule resource working, add tests

random fixes

standardise on zone + implement import

tests check api attributes + docs update for page rule

error check on set complex attr + remove failing attributes from page rules tests
catsby added a commit to cloudflare/terraform-provider-cloudflare that referenced this issue Mar 12, 2018
This commit adds most of the boilerplate for implementing CloudFlare
Page Rules, and implements the Create method.

`PageRuleActionValue`s still need a validator; this is complex and
depends on `PageRuleActionId`.

Read, Update, and Delete methods will throw 'not implemented' errors.

Towards hashicorp/terraform#9040; #3.

Require at least one page rule action

Simplify page rule targets API

Asking for a list of targets is just confusing to a user when Cloudflare
only accepts  a single `"url"` target.

Implement action value validation

Improve legibility

Change action Elems to be Schema

Implement Read/Update/Delete Page Rules

Simplify Page Rule action schema

This commit changes Page Rule actions to be a TypeSet of maps containing
the action ID, and optionally its sub-setting. This makes validation a
bit nicer, too.

Fix crash while running apply

Page Rule Read implementation was naïvely copying Cloudflare's returned
data structure, rather than transforming to fit schema.

Fix passing PageRuleAction value error back up

Flatten PageRule action schema

Fix flattened structure

Unfortunately, we cannot have the desired structure with a
`schema.Resource` `actions` in the main schema:

    resource "cloudflare_page_rule" "foo" {
      actions = {
        always_online = true
      }
    }

where `always_online` and other Actions are explicitly defined, since
`actions` needs to be a `schema.Schema`.

This commit moves the `Resource` inside `actions`, which now becomes a
`Schema` of `TypeSet`, which means Cloudflare's binary options such as
`always_online` will default to `false` if we have them be `TypeBool`.
To circumvent that, we instead use `TypeString` and validate `"on"` or
`"off"` (matching Cloudflare's API) - since these will be empty if not
set.

The logic's a little less clean, since we now have to loop through every
possible action type for each action in the set, testing the type and
value of its sub-setting/mode to determine if it was really set by the
user.

Document page rule resources

Appease linter

Add acceptance tests for page rules

Fix allowing multiple entries in page rule actions

Improve error reporting

get page rule resource working, add tests

random fixes

standardise on zone + implement import

tests check api attributes + docs update for page rule

error check on set complex attr + remove failing attributes from page rules tests
@ghost
Copy link

ghost commented Apr 10, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@hashicorp hashicorp locked and limited conversation to collaborators Apr 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants