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

resource/cloudfare_api_token: allow empty conditions #902

Conversation

jacobbednarz
Copy link
Member

@jacobbednarz jacobbednarz commented Jan 3, 2021

In the initial PR for adding API token support to Terraform (#862), an
assumption was made that empty condition blocks would allow all
traffic; this is incorrect and puts the end user in a state where no
traffic is allowed.

To address this, we need to conditionally build the API token based on
what fields are non-zero values. This requires a bit of a rewrite as
this assumption ran deep into the methods and the structure of the code
itself.

While this increases the test coverage, we do now have a restriction in
the API itself whereby if you create an API token with IP restrictions
and then wish to remove them, you cannot -- you must recreate the token.
This issue is outside the scope of this work so I'll leave it as a known
factor for now.

Depends on cloudflare/cloudflare-go#569
Closes #87

In the initial PR for adding API token support to Terraform (#862), an
assumption was made that empty `condition` blocks would allow all
traffic; this is incorrect and puts the end user in a state where no
traffic is allowed.

To address this, we need to conditionally build the API token based on
what fields are non-zero values. This requires a bit of a rewrite as
this assumption ran deep into the methods and the structure of the code
itself.

While this increases the test coverage, we do now have a restriction in
the API itself whereby if you create an API token with IP restrictions
and then wish to remove them, you cannot -- you must recreate the token.
This issue is outside the scope of this work so I'll leave it as a known
factor for now.

Closes #897
jacobbednarz added a commit to jacobbednarz/cloudflare-go that referenced this pull request Jan 3, 2021
Updates the `APITokenRequestIPCondition` fields to be omitted when empty
to support only setting one of the values.

Supports the changes in cloudflare/terraform-provider-cloudflare#902
jacobbednarz added a commit to jacobbednarz/cloudflare-go that referenced this pull request Jan 3, 2021
Updates the `APITokenRequestIPCondition` fields to be omitted when empty
to support only setting one of the values.

Supports the changes in cloudflare/terraform-provider-cloudflare#902
patryk pushed a commit to cloudflare/cloudflare-go that referenced this pull request Jan 4, 2021
)

Updates the `APITokenRequestIPCondition` fields to be omitted when empty
to support only setting one of the values.

Supports the changes in cloudflare/terraform-provider-cloudflare#902
@jacobbednarz jacobbednarz merged commit bdde198 into cloudflare:master Jan 5, 2021
@jacobbednarz jacobbednarz deleted the allow-empty-api-token-permissions branch January 5, 2021 20:17
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.

1 participant