CDK for dnscontrol
CDK for dnscontrol simplifies DNS management using the Cloud Development Kit (CDK).
Requirements
- Node.js >= 22
- Go >= 1.23.0
Installation
Install the CLI and library:
Usage
Write CDK
This example is based on the official dnscontrol tutorial.
1. Create a Stack
Create lib/example-stack.ts
:
2. Create an Entry Point
Create bin/index.ts
:
3. Add Credentials
Create creds.json
:
4. Apply DNS Configurations
Use the following commands to manage DNS configurations:
After applying, the zone file will be generated in the output directory.
Migrate from dnsconfig.js
Limitations
- Cannot use
IMPORT
andTRANSFORM
. - The following functions are not supported:
FETCH
HASH
PANIC
getConfiguredDomains
- Cannot use
require
andrequire_glob
. - If you use
D_EXTEND
, records are flattened in the CDK code.- It is recommended to split records into constructs instead of using
D_EXTEND
.
- It is recommended to split records into constructs instead of using
1. Migrate from dnsconfig.js
Use the following command to migrate from dnsconfig.js
:
2. Create an Entry Point
Create bin/index.ts
:
3. Add Credentials
Create creds.json
:
4. Apply DNS Configurations
Use the following commands to manage DNS configurations:
After applying, the zone file will be generated in the output directory.
CLI Options
diff
The diff
command compares the current DNS configurations with the desired state defined in your CDK code. It synthesizes the CDK application and displays the differences without applying any changes.
Use the --cdk-entry-point
(or -i
) flag to specify a custom entry point for the CDK application:
deploy
The deploy
command applies the desired DNS configurations defined in your CDK code. It synthesizes the CDK application and pushes the changes to the DNS provider.
Use the --cdk-entry-point
(or -i
) flag to specify a custom entry point for the CDK application:
migrate
The migrate
command helps convert an existing dnsconfig.js
file into CDK code. It generates CDK constructs and stacks based on the DNS configurations defined in the dnsconfig.js
file.
Use the following flags to customize the migration process:
--dnsconfig
(or-d
): Specify the path to thednsconfig.js
file. Defaults to./dnsconfig.js
.--outputDir
(or-o
): Specify the output directory for the generated CDK code. Defaults to./lib/stacks
.
Example:
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
Roadmap
- General
- Publish jsii packages
- Write documentation:
- Examples
- API docs
- Migration guide
- Tutorial
- FAQ
- Add CI/CD
- CDK
- Add Aspects
- Add CDK constructs
- CLI
- Support other languages
- Add options for
creds.json