Skip to content

Commit 9bab267

Browse files
committed
readme content added
1 parent 43dfad5 commit 9bab267

File tree

2 files changed

+126
-2
lines changed

2 files changed

+126
-2
lines changed

README.md

Lines changed: 126 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,126 @@
1-
# cloudflareDNSRecord
2-
CloudFlare DNS record creation
1+
# Cloudflare DNS Record Management with Pulumi
2+
3+
This project automates DNS record management in Cloudflare using Pulumi's infrastructure-as-code approach. It creates A and CNAME records from YAML configuration files while handling existing records gracefully.
4+
5+
![Successful Pulumi Deployment](snapshot.png)
6+
7+
## Features
8+
9+
- 🚀 **Declarative DNS Management**: Define records in simple YAML files
10+
- 🔄 **Idempotent Operations**: Skips existing records automatically
11+
-**Cloudflare Integration**: Uses Cloudflare's official Pulumi provider
12+
- 🛡️ **Error Handling**: Robust error checking and reporting
13+
- 🔍 **Existence Checks**: Prevents duplicate record creation
14+
- 📊 **Output Reporting**: Shows created records count
15+
16+
## Prerequisites
17+
18+
- Python 3.7+
19+
- Pulumi CLI
20+
- Cloudflare account with API access
21+
- GitLab account (for CI/CD pipeline)
22+
23+
## Project Structure
24+
25+
```
26+
cloudflare-dns-record/
27+
├── Pulumi.yaml # Pulumi project configuration
28+
├── __main__.py # Main Pulumi program
29+
├── requirements.txt # Python dependencies
30+
├── resources/
31+
│ ├── arecord.yaml # A record definitions
32+
│ └── cname.yaml # CNAME record definitions
33+
└── README.md # This file
34+
```
35+
36+
## Setup
37+
38+
1. **Install dependencies**:
39+
```bash
40+
pip install -r requirements.txt
41+
```
42+
43+
2. **Create record files**:
44+
- Add your A records to `resources/arecord.yaml`
45+
- Add your CNAME records to `resources/cname.yaml`
46+
47+
## Example Record
48+
49+
```yaml
50+
- name: "example.com"
51+
content: "192.0.2.1"
52+
type: "A"
53+
proxied: true
54+
55+
- name: "api.example.com"
56+
content: "203.0.113.1"
57+
type: "A"
58+
ttl: 600
59+
proxied: false
60+
```
61+
62+
```yaml
63+
- name: "www.example.com"
64+
content: "example.com"
65+
type: "CNAME"
66+
proxied: true
67+
68+
- name: "app.example.com"
69+
content: "external-app.com"
70+
type: "CNAME"
71+
ttl: 3600
72+
proxied: false
73+
```
74+
75+
## Usage
76+
77+
### Local Execution
78+
```bash
79+
pulumi up --stack dev
80+
```
81+
snapshot.png
82+
83+
### GitLab CI/CD
84+
The included `.gitlab-ci.yml` provides:
85+
- Validation of project structure
86+
- Dependency installation
87+
- Preview of changes
88+
- Deployment to Cloudflare
89+
90+
## Error Handling
91+
92+
The program handles:
93+
- ✅ Existing records (skips creation)
94+
- ✅ Missing YAML files (continues with warning)
95+
- ✅ API timeouts (automatic retries)
96+
- ✅ Invalid configurations (clear error messages)
97+
98+
## Outputs
99+
100+
After successful execution, you'll see:
101+
```
102+
Outputs:
103+
arecord_records_created: 2
104+
cname_records_created : 1
105+
```
106+
107+
## Best Practices
108+
109+
1. **Version Control**: Always commit your YAML files
110+
2. **Review Changes**: Use `pulumi preview` before applying
111+
3. **Backup Records**: Export existing records before migration
112+
4. **Least Privilege**: Use API tokens with minimal permissions
113+
114+
## Troubleshooting
115+
116+
| Error | Solution |
117+
|-------|----------|
118+
| `Record already exists` | This is expected - existing records are skipped |
119+
| `Missing YAML file` | Create the required YAML file or remove the reference |
120+
| `API timeout` | The program will automatically retry |
121+
| `Invalid configuration` | Check YAML syntax and required fields |
122+
123+
## License
124+
125+
MIT License - see [LICENSE](LICENSE) for details.
126+
```

snapshot.png

79.1 KB
Loading

0 commit comments

Comments
 (0)