Setup Terraform in Windows (AMD64)
Download Terraform for Windows (AMD64) from
Unzip the file to a directory
Add the Terraform binary to your system's PATH:
Right-click This PC →Settings → Advanced system settings → Environment Variables. Under User variables for Unity_0116, find the Path variable, and click Edit. Click New, and add the path to the directory where you unzipped Terraform. Press OK to save the changes. terraform —version (Terraform version command)
Create API Tokens in Digital Ocean
Go to and log in to your account. Expiration :- 30/60/90 days and No Expir Set Permissions :- full access Create API Tokens in GitHub
Access Personal Access Tokens: Click on your profile icon in the top-right corner.
Select Settings from the dropdown menu.
In the left sidebar, click on Developer settings.
Click on Personal access tokens.
Click on Personal access tokens (classic).
Enter a Token name to describe its purpose.
Choose an Expiration date or set it to No expiration if you prefer.
Ensure that your token has both admin:public_key and write:public_key permissions. You can regenerate the token if needed, ensuring those scopes are checked.
Generate and Copy the Token
Create API Tokens for Cloudflare
Select the "Edit zone DNS" template or create a custom token with permissions for "Zone DNS"
Zone DNS" read and edit
Define the token's permissions:
Permissions: Select "Zone DNS" and set to "Read" and "Edit."
Zone Resources: Set to "Include All Zones" or specify the zones as needed.
Click "Continue to summary" and then "Create Token."
How to Retrieve the Cloudflare Zone ID
Select your account and choose the domain for which you need the Zone ID.
On the Overview page (this is the default landing page when you select a domain), scroll down to find the API section.
In this section, you will find both the Zone ID and the Account ID. Copy the Zone ID to use in your Terraform configuration or API calls.
ssh-keygen -t rsa
And Save Terraform File
file name :- id_rsa.pub
Terraform File
create a new Terraform file
create the .tf file
file (Terraform Provider Configuration for Digital Ocean and Cloudflare) terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 3.0" # Use the latest version within the 3.x range
}
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0" # Example: Use the latest version within the 2.x range
}
}
}
# Configure the DigitalOcean Provider
provider "digitalocean" {
token = var.do_token
}
# Configure the Cloudflare Provider
provider "cloudflare" {
api_token = var.cloudflare_api_token
}
terraform.tfvars
# DigitalOcean API Token
do_token = "dop_v1_cd61e7b627830e2212033ceb47b6400e1f1ed981c896b88a3ca6fe5f541da5c4"
# Cloudflare API Token
cloudflare_api_token = "z2ah0j36vxc-nJ11_4qEbDCDLNJtGK8HE8rJ4wQj"
# Cloudflare Zone ID
cloudflare_zone_id = "3dd054264c1a06c8794306590a4205e2"