Partial (CNAME) setup とは
こちらをご参照ください。
API で行う必要性
通常アカウントでは、Business もしくは Enterprise プランのゾーンにのみ Partial (CNAME) setup が許可されていますが、
Cloudflare パートナーアカウントでは、Free プランを含む全てのプランで Partial (CNAME) setup が許可されています。
ただし、GUI による Partial (CNAME) setup は Business もしくは Enterprise プランのゾーンのみ、のままになっています。
https://dash.cloudflare.com/?to=/:account/:zone
Business もしくは Enterprise プラン
Free もしくは Pro プラン
API で Partial (CNAME) setup ゾーン作成
変数セットして、API からゾーン作成します。
export EMAIL='YOUR_EMAIL'
export APIKEY='YOUR_APIKEY'
export ACCOUNT_ID='YOUR_ACCOUNT_ID'
export ZONE_NAME='YOUR_ZONE_NAME'
ZONE_NAME
と type: partial
を指定してゾーン作成します(作成時にプラン指定はできません)。
curl -sX POST "https://api.cloudflare.com/client/v4/zones" \
-H "X-Auth-Email: $EMAIL" \
-H "X-Auth-Key: $APIKEY" \
-H "Content-Type: application/json" \
--data '{"name":"'"$ZONE_NAME"'","account":{"id":"'"$ACCOUNT_ID"'"},"jump_start":false,"type":"partial"}' | jq
Free プランで Partial (CNAME) setup ゾーンが作成できました。
その後のプラン変更は Cloudflare のゾーン削除・プラン変更 - Qiita をご参照ください。
result.json
{
"result": {
"id": "xxx",
"name": "example.com",
"status": "pending",
"paused": false,
"type": "partial",
"development_mode": 0,
"verification_key": "xxx-xxx",
"cname_suffix": "cdn.cloudflare.net",
"original_name_servers": [
"ns1.xxx.com",
"ns2.xxx.com"
],
"original_registrar": "xxx",
"original_dnshost": null,
"modified_on": "2021-10-11T03:41:49.595275Z",
"created_on": "2021-10-11T03:41:49.595275Z",
"activated_on": null,
"meta": {
"step": 4,
"wildcard_proxiable": false,
"custom_certificate_quota": 0,
"page_rule_quota": 3,
"phishing_detected": false,
"multiple_railguns_allowed": false
},
"owner": {
"id": "xxx",
"type": "organization",
"name": "xxx Account"
},
"account": {
"id": "xxx",
"name": "xxx Account"
},
"permissions": [
"#access:edit",
"#access:read",
"#analytics:read",
"#app:edit",
"#auditlogs:read",
"#billing:edit",
"#billing:read",
"#cache_purge:edit",
"#dns_records:edit",
"#dns_records:read",
"#lb:edit",
"#lb:read",
"#legal:edit",
"#legal:read",
"#logs:edit",
"#logs:read",
"#member:edit",
"#member:read",
"#organization:edit",
"#organization:read",
"#ssl:edit",
"#ssl:read",
"#stream:edit",
"#stream:read",
"#subscription:edit",
"#subscription:read",
"#teams:edit",
"#teams:pii",
"#teams:read",
"#teams:report",
"#waf:edit",
"#waf:read",
"#webhooks:edit",
"#webhooks:read",
"#worker:edit",
"#worker:read",
"#zone:edit",
"#zone:read",
"#zone_settings:edit",
"#zone_settings:read"
],
"plan": {
"id": "0feeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"name": "Free Website",
"price": 0,
"currency": "USD",
"frequency": "",
"is_subscribed": false,
"can_subscribe": false,
"legacy_id": "free",
"legacy_discount": false,
"externally_managed": false
}
},
"success": true,
"errors": [],
"messages": []
}