-
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
Empty condition block in cloudflare_api_token #897
Comments
It looks like this issue goes deeper than I initially thought. For some reason, when editing the
I still get the
I am not sure if by doing |
I created a new token via API by doing:
It looks exactly the same as
This one works just fine. Maybe the API token listing endpoint is not showing the cause of the error? |
FWIW, an empty condition block in the API is not desirable as your IP will be missing from both and will default to a deny ACL rule. I'm not sure on why the API doesn't return them (maybe to help the user?) but if you don't put the IP!conditions in, it should be omitted completely and not sent. |
@jacobbednarz When I first create the tokens via terraform, even when not specifying a condition block in the code, it still shows up when listing it via API. 🤔 |
Yep, I suspect that is because the fields aren't being correctly checked for zero values and end up appended to the payload. You should be able to confirm this by looking at the TF_LOG=DEBUG output for the HTTP request. We may also be able to fix this in the cloudflare-go library struct but we'll need to see. |
@jacobbednarz Just to clarify, doesn't this issue make all CloudFlare API tokens created via Terraform useless? Is there a way for me to fix this until a new version of the provider gets released? |
No, if you define the conditions, it will work as expected. |
Sadly, defining conditions is not an option for me, as terraform applies will be executed from:
I will leave this issue open and wait for a new version of the provider to arrive. Thank you very much for your help! |
@jacobbednarz I second @dsalaza4 's report that this is not expected functionality. When you create an API Token on Cloudflare's web console or API, no conditions are defined by default. When you create an API token using their terraform provider, a condition of "request_ip is in [] and not in []" is defined by default, which cannot be met. It eliminates Cloudflare's allowed functionality of not defining any conditions. Conditions are an optional parameter. The terraform provider is now forcing them. |
I think you've misunderstood the context of that response. Sending empty arrays is not intended or expected (hence also why this is still labelled as a bug). The snippet you've quoted here is in relation to when you actually provide the IP restrictions. This is in the queue to look at when I'm back from leave which should be on the next couple of weeks unless someone else wants to take a look. |
#902 should hopefully address this one |
I just verified this issue has been fixed. @jacobbednarz Thank you so much for your help! |
Terraform version
Affected resource(s)
Terraform configuration files
Expected behavior
cloudflare_api_token
should not have acondition
block when not provided in terraform.Actual behavior
When I create a
cloudflare_api_token
and try to use it, I get the following error:When I manually create a token with the same permissions, the request works just fine:
When listing both tokens, I notice that the only difference between them is an empty
condition
block intoken_terraform
:Steps to reproduce
Cannot use the access token from location: <your-ip>
error.Community note
to the original issue to help the community and maintainers prioritize this request
request, please leave a comment
The text was updated successfully, but these errors were encountered: