Skip to content

Commit 4002758

Browse files
authored
Update record.py
zone id get from os environment variable
1 parent e1d0d64 commit 4002758

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

examples/dns/record.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1+
import os
12
from cloudflare import Cloudflare
23

34

5+
zone_id = os.getenv("CLOUDFLARE_ZONE_ID")
6+
if zone_id is None:
7+
sys.exit("CLOUDFLARE_ZONE_ID is not defined")
48

5-
cloudflare_token = "your-cloudflare-token"
6-
cloudflare_zone_id = "zone"
79
alias_name = "www.mydns.com"
810
cannonical_name = "cname.example.com"
911

10-
client = Cloudflare()
1112

13+
client = Cloudflare()
1214

1315

1416
# create dns using defined driver
1517
record = client.dns.records.create(
16-
zone_id=cloudflare_zone_id,
18+
zone_id=zone_id,
1719
type='CNAME',
1820
name=alias_name,
1921
content=cannonical_name,
2022
proxied=False
2123
)
2224

25+
2326
# print output
24-
print(record)
27+
print(record)

0 commit comments

Comments
 (0)