Skip to content

Commit

Permalink
Update examples for changes in Cloudflare provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsomething committed Apr 6, 2020
1 parent ccd8181 commit 979e45e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
9 changes: 7 additions & 2 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ It requires the following input variables:
- `cloudflare_token` - Your Cloudflare API token.
- `do_token` - Your DigitalOcean API token.
- `cloudflare_domain` - The Cloudflare domain to which the A record will be added.
- `cloudflare_zone_id` - The ID of the Cloudflare zone to which the A record will be added.
- `test_name` - The name that will be used for both the A record and the Droplet. (Default: `tf-example`)

You can run this example with:

```
terraform init
terraform plan -var "do_token=$DO_TOKEN" -var "cloudflare_email=$CF_EMAIL" -var "cloudflare_token=$CF_TOKEN" -var "cloudflare_domain=$CF_DOMAIN"
terraform apply -var "do_token=$DO_TOKEN" -var "cloudflare_email=$CF_EMAIL" -var "cloudflare_token=$CF_TOKEN" -var "cloudflare_domain=$CF_DOMAIN"
terraform plan -var "do_token=$DO_TOKEN" -var "cloudflare_email=$CF_EMAIL" \
-var "cloudflare_token=$CF_TOKEN" -var "cloudflare_domain=$CF_DOMAIN" \
-var "cloudflare_zone_id=$CF_ZONE_ID"
terraform apply -var "do_token=$DO_TOKEN" -var "cloudflare_email=$CF_EMAIL" \
-var "cloudflare_token=$CF_TOKEN" -var "cloudflare_zone_id=$CF_ZONE_ID" \
-var "cloudflare_domain=$CF_DOMAIN"
```
18 changes: 12 additions & 6 deletions example/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
provider "cloudflare" {
version = "~> 2.0"
email = var.cloudflare_email
api_key = var.cloudflare_token
}

provider "digitalocean" {
token = var.do_token
}
Expand All @@ -10,16 +16,16 @@ module "firewall_inbound_cloudflare" {
}

resource "cloudflare_record" "foobar" {
domain = var.cloudflare_domain
name = var.test_name
value = digitalocean_droplet.tf-example.ipv4_address
type = "A"
proxied = true
zone_id = var.cloudflare_zone_id
name = var.test_name
value = digitalocean_droplet.tf-example.ipv4_address
type = "A"
proxied = true
}

resource "digitalocean_droplet" "tf-example" {
image = var.do_image
name = var.test_name}.${var.cloudflare_domain
name = format("%s.%s", var.test_name, var.cloudflare_domain)
region = var.do_region
size = var.do_size
}
7 changes: 6 additions & 1 deletion example/variables.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
variable "cloudflare_email" {}
variable "cloudflare_token" {}
variable "cloudflare_domain" {}
variable "cloudflare_zone_id" {}

variable "do_token" {}

variable "do_image" {
default = "lemp-16-04"
default = "lemp-18-04"
}

variable "do_region" {
Expand Down

0 comments on commit 979e45e

Please sign in to comment.