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

Support creating zones in a specific account #72

Merged
merged 1 commit into from
Dec 6, 2023

Conversation

austinylin
Copy link
Contributor

This PR adds support for creating zones in a specific Cloudflare account (as specified by the existing account_id param on the provider config).

With this change, when account_id is set on the provider it's included in the POST request to /zones when creating a new zone:

curl --request POST \
  --url https://api.cloudflare.com/client/v4/zones \
  --header 'Authorization: Bearer my-fake-cf-token' \
  --header 'Content-Type: application/json' \
  --data '{
  "account": {
    "id": "023e105f4ecef8ad9ca31a8372d0c353"
  },
  "name": "example.com",
  "type": "full"
}'

(https://developers.cloudflare.com/api/operations/zones-post)

This resolves a current issue whereby new zones are created in the wrong account when the api token isn't created on the account where the zone is intended to be created.

As an example, say that Contoso Inc has a Cloudflare organization/account and adds Alice as an authorized administrator. Alice sets up an api token under her [email protected] Cloudflare user account. If Alice uses octodns to create a new zone, the zone will be created in Alice's account not Contoso Inc's account as desired because Cloudflare interprets a request to create a zone without an account_id as a request to create it on the current user's account.

With this change, if account_id is set to the Contoso Inc's account, the zone is properly created on the Contoso Inc account.

@ross ross merged commit cf555c5 into octodns:main Dec 6, 2023
7 checks passed
@austinylin austinylin deleted the account-id-on-zone-creation branch December 6, 2023 19:19
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.

2 participants