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_zone list all zones even if particular account is specified #452

Open
2 tasks done
Arnall opened this issue Aug 29, 2022 · 0 comments
Open
2 tasks done

Comments

@Arnall
Copy link

Arnall commented Aug 29, 2022

Confirmation

  • My issue isn't already found on the issue tracker.
  • I have replicated my issue using the latest version of the library and it is still present.

cf-terraforming version

v0.8.2

Expected outcome

when using cf-terraforming generate --resource-type cloudflare_zone --account 0123456789abcdef I expect having zones for the specified account:

resource "cloudflare_zone" "terraform_managed_resource_a7eb80xxxxxxxxxf24ffe" {
  account_id = "0123456789abcdef"
  paused     = false
  plan       = "enterprise"
  type       = "partial"
  zone       = "example1.com"
}

Actual outcome

I have all the zones listed with the same account_id attribute even if the zone belong to another account.

resource "cloudflare_zone" "terraform_managed_resource_a7eb80xxxxxxxxxf24ffe" {
  account_id = "0123456789abcdef"
  paused     = false
  plan       = "enterprise"
  type       = "partial"
  zone       = "example1.com"
}

resource "cloudflare_zone" "terraform_managed_resource_74b44xxxxxxxx79e01b" {
  account_id = "0123456789abcdef"
  paused     = false
  plan       = "enterprise"
  type       = "partial"
  zone       = "anotheraccount1.net"
}

resource "cloudflare_zone" "terraform_managed_resource_4d41b2ef0575xxxxxxxx05e83d3" {
  account_id = "0123456789abcdef"
  paused     = false
  plan       = "enterprise"
  type       = "partial"
  zone       = "anotheraccount2.net"
}

with generate -v:

cloudflare-go [DEBUG] REQUEST Method:GET URI:https://api.cloudflare.com/client/v4/zones?per_page=50 Headers:http.Header(nil) Body:<nil>
cloudflare-go [DEBUG] RESPONSE StatusCode:200 Body:"{\"result\":...
cloudflare-go [DEBUG] REQUEST Method:GET URI:https://api.cloudflare.com/client/v4/zones?page=2&per_page=50 Headers:http.Header(nil) Body:<nil>
cloudflare-go [DEBUG] RESPONSE StatusCode:200 Body:"{\"result\"...

we can see that the account id is not used in the API Call (https://api.cloudflare.com/#zone-list-zones account.id can be used to filter the results).
Also

"account": {
                "id": "<account_id>",
                "name": "Account Name"
            }

is not used to fill the results so we have the account id passed in the command line in every zones. If we do not specify an account id in the command line the account_id attribute just do not appears:

resource "cloudflare_zone" "terraform_managed_resource_a7eb80xxxxxxxxxf24ffe" {
  paused     = false
  plan       = "enterprise"
  type       = "partial"
  zone       = "example1.com"
}

Steps to reproduce

  1. Token with Account.Access: Apps and Policies permission on all account.
  2. export CLOUDFLARE_API_TOKEN="<token>"
  3. cf-terraforming generate --resource-type cloudflare_zone --account <specific_account_id>

References

No response

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

No branches or pull requests

1 participant