github.com/ezbercih/terraform@v0.1.1-0.20140729011846-3c33865e0839/website/source/intro/examples/cross-provider.markdown (about) 1 --- 2 layout: "intro" 3 page_title: "Cross Provider" 4 sidebar_current: "examples-cross-provider" 5 --- 6 7 # Cross Provider Example 8 9 This is a simple example of the cross-provider capabilities of 10 Terraform. 11 12 Very simply, this creates a Heroku application and points a DNS 13 CNAME record at the result via DNSimple. A `host` query to the outputted 14 hostname should reveal the correct DNS configuration. 15 16 ## Command 17 18 ``` 19 terraform apply \ 20 -var 'heroku_email=YOUR_EMAIL' \ 21 -var 'heroku_api_key=YOUR_KEY' \ 22 -var 'dnsimple_domain=example.com' \ 23 -var 'dnsimple_email=YOUR_EMAIL' \ 24 -var 'dnsimple_token=YOUR_TOKEN' 25 ``` 26 27 ## Configuration 28 29 ``` 30 variable "heroku_email" {} 31 variable "heroku_api_key" {} 32 33 # The domain we are creating a record for 34 variable "dnsimple_domain" {} 35 36 variable "dnsimple_token" {} 37 variable "dnsimple_email" {} 38 39 40 # Specify the provider and access details 41 provider "heroku" { 42 email = "${var.heroku_email}" 43 api_key = "${var.heroku_api_key}" 44 } 45 46 # Create our Heroku application. Heroku will 47 # automatically assign a name. 48 resource "heroku_app" "web" { 49 } 50 51 # Create our DNSimple record to point to the 52 # heroku application. 53 resource "dnsimple_record" "web" { 54 domain = "${var.dnsimple_domain}" 55 56 name = "terraform" 57 58 # heroku_hostname is a computed attribute on the heroku 59 # application we can use to determine the hostname 60 value = "${heroku_app.web.heroku_hostname}" 61 62 type = "CNAME" 63 ttl = 3600 64 } 65 66 # The Heroku domain, which will be created and added 67 # to the heroku application after we have assigned the domain 68 # in DNSimple 69 resource "heroku_domain" "foobar" { 70 app = "${heroku_app.web.name}" 71 hostname = "${dnsimple_record.web.hostname}" 72 } 73 74 # Output the hostname of the newly created record 75 output "address" { 76 value = "${dnsimple_record.web.hostname}" 77 } 78 ```