Giter Site home page Giter Site logo

terraform-cloudflare-template's Introduction

terraform-cloudflare-template

A terraform template for managing Cloudflare DNS

Places in the code that have "1domain1" can to be replaced with your actual domain name if you are going to be managing multiple domains. Most things can use the variable file to get the domain name, but a few places require hard coded input. I found it easier to just have a DNS folder and then a folder for each domain to manage them separetly as there is not many times when I need to make changes to many at once, even if I did, it would not take long to just run through each one. That is up to your personal situation, though.

It is named 1domain1 so that you can quickly do a replace-all and insert your domain in it's place!


Everything else is pretty self explanitory. A single root host "A" record is setup and will be populated by the variables.tfvars cloudflare_domain= entry. A CNAME of www is setup as well.
If you need additional entries, you can just copy the current ones and change the necessary values to suit your needs.
The MX records are set to Google Gmail records, but can simply be changed / modified to fit your requirements.

To use, fill out the necessary values, make sure you have Terraform installed, then from the root of the folder type in:

terraform init 

which will download the Cloudflare plugin and get things setup initially. Then you can type in:

terraform plan --var-file=variables.tfvars

If the changes look like what you are expecting, you can finalize and perform the actions by using:

terraform apply --var-file=variables.tfvars

Do note that the first time you run apply it will create the DNS zone within Cloudflare but will not apply the zone records. You may have to wait a few minutes for everything to be created on their side. Once the domain zone is created, go look at your Cloudflare account for the new domain and open it's dashboard. It will give you your assigned DNS Nameservers. These will need to be input into your domains registrar to point your name to Cloudflare. Once this is completed you should be able to run terraform apply again for it to create the actual records.

Thanks!


To find your Cloudflare API Key, you will need to go from your main dashboard to the top right corner and click on the account dropdown and select "Profile":

alt text

Then scroll down to the bottom of the profile page to the API Keys section and press the "View" button:

alt text

From there it will ask for your password to verify you are you. It will then show you your API Key. Copy this key and place it into the variables.tfvars file in the cloudflare_apikey= section.

alt text


alt text

terraform-cloudflare-template's People

Contributors

instance-id avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.