-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ElioLopez/feature-bearer-token-option-add
bearer token option add
- Loading branch information
Showing
3 changed files
with
29 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,35 +17,41 @@ kubectl apply -f k8s-cronjob.yaml | |
|
||
## Values for k8s-cronjob.yaml | ||
|
||
- Get the ZONE_ID under dash.cloudflare.com -> Your domain -> Overview -> API -> Zone ID | ||
- Get the RECORD_ID: https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records | ||
``` | ||
#example | ||
ZONE_ID = 023e105f4ecef8ad9ca31a8372d0c353 | ||
RECORD_ID = 372e67954025e0ba6aaa6d586b9e0b59 | ||
``` | ||
|
||
- Get the RECORD_ID: https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records | ||
- Specify your domain | ||
``` | ||
#example | ||
RECORD_ID = 372e67954025e0ba6aaa6d586b9e0b59 | ||
NAME = example.com | ||
``` | ||
- Get the ZONE_ID under dash.cloudflare.com -> Your domain -> Overview -> API -> Zone ID | ||
``` | ||
#example | ||
ZONE_ID = 023e105f4ecef8ad9ca31a8372d0c353 | ||
``` | ||
|
||
- Get your AUTH_KEY (Create a key with "DNS Edit" permissions): https://support.cloudflare.com/hc/en-us/articles/200167836-Where-do-I-find-my-Cloudflare-API-key- | ||
- There are two options for authentication, AUTH_KEY and AUTH_EMAIL or just API_TOKEN | ||
if AUTH_EMAIL is defined the first option will execute. | ||
Values for the first option: | ||
|
||
- Get your AUTH_KEY (Create a key with "DNS Edit" permissions): https://support.cloudflare.com/hc/en2-us/articles/200167836-Where-do-I-find-my-Cloudflare-API-key- | ||
``` | ||
#example | ||
AUTH_KEY = c2547eb745049flc9320b638f5e225cf483cc5cfdda41 | ||
``` | ||
|
||
- Specify your cloudflare email | ||
``` | ||
#example | ||
AUTH_EMAIL = [email protected] | ||
``` | ||
Values for the second option: | ||
- Get your API Token My profile -> API Tokens -> Create Tokens -> Edit Zone DNS for the desired zone (https://developers.cloudflare.com/api/tokens/create/): | ||
|
||
|
||
- Specify your domain | ||
``` | ||
#example | ||
NAME = example.com | ||
``` | ||
API_TOKEN = 4525cf483cc5cfd049flc9320b638f5e2c2547eb7da41 | ||
|
||
For more Cloudflare API informations read the [Cloudflare API documentation v4](https://api.cloudflare.com/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
#!/bin/bash | ||
|
||
if [[ -z "${AUTH_EMAIL+x}" ]]; then | ||
echo "AUTH_EMAIL are not defined, will use API Bearer Token method" | ||
curl -X PUT "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$RECORD_ID" \ | ||
-H "Authorization: Bearer $API_TOKEN" \ | ||
-H "Content-Type: application/json" \ | ||
--data "{\"type\":\"A\",\"name\":\"$NAME\",\"content\":\"`curl ifconfig.co`\"}" | ||
|
||
else | ||
echo "AUTH_EMAIL is defined, will use AUTH_KEY Method" | ||
curl -X PUT "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$RECORD_ID" \ | ||
-H "X-Auth-Email: $AUTH_EMAIL" \ | ||
-H "X-Auth-Key: $AUTH_KEY" \ | ||
-H "Content-Type: application/json" \ | ||
--data "{\"type\":\"A\",\"name\":\"$NAME\",\"content\":\"`curl ifconfig.co`\"}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters