GithubHelp home page GithubHelp logo

isabella232 / cf2tf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brave-experiments/cf2tf

0.0 0.0 0.0 26 KB

A Terraform importer for Cloudflare resources, inspired by terraforming

License: Mozilla Public License 2.0

JavaScript 100.00%

cf2tf's Introduction

cf2tf: Cloudflare to Terraform

A Terraform importer for Cloudflare resources inspired by terraforming.

Installation

git clone https://github.com/brave/cf2tf
npm install -g

Prerequisites

You must export your Cloudflare credentials:

export CLOUDFLARE_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
export [email protected]

Usage

$ cf2tf --help
Commands:
  dns  import dns records

Options:
  --help  Show help                                                    [boolean]
  --tfstate  output tfstate                                     [default: false]
$ cf2tf dns --help
cf2tf dns

Options:
  --help     Show help                                                 [boolean]
  --tfstate  output tfstate                                     [default: false]
  --zone     limit to a particular zone by name                    [default: ""]

Example

The following example shows simulated output for a domain mysite.com which has a single record, an apex CNAME to mysite.org

$ cf2tf dns --zone mysite.com > main.tf
$ cat main.tf
{
    "resource": {
        "cloudflare_record": {
            "mysite_com_CNAME_mysite_org": {
                "domain": "mysite.com",
                "name": "mysite.com",
                "value": "mysite.org",
                "type": "CNAME",
                "proxied": false
            }
        }
    }
}
$ cf2tf dns --zone mysite.com --tfstate > terraform.tfstate
$ cat terraform.tfstate
{
    "version": 1,
    "serial": 1,
    "modules": [
        {
            "path": [
                "root"
            ],
            "outputs": {},
            "resources": {
                "cloudflare_record.mysite_com_CNAME_mysite_org": {
                    "type": "cloudflare_record",
                    "depends_on": [],
                    "primary": {
                        "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                        "attributes": {
                            "domain": "mysite.com",
                            "hostname": "mysite.com",
                            "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                            "name": "mysite.com",
                            "priority": "0",
                            "proxied": "false",
                            "ttl": "1",
                            "type": "CNAME",
                            "value": "mysite.org",
                            "zone_id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                        },
                        "meta": {
                            "schema_version": "1"
                        },
                        "tainted": false
                    },
                    "deposed": [],
                    "provider": ""
                }
            },
            "depends_on": []
        }
    ]
}

Notes

Unlike terraforming, cf2tf outputs in the Terraform JSON configuration format. This can easily converted to hcl format via a tool like json2hcl.

cf2tf's People

Contributors

evq 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.