From c27b2cd9b96933266dc7fdcfee82458fc27080c2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 25 Jul 2014 14:51:12 -0700 Subject: [PATCH] website: providers and variables --- .../docs/configuration/providers.html.md | 76 ++++++++++++ .../docs/configuration/variables.html.md | 111 ++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 website/source/docs/configuration/providers.html.md create mode 100644 website/source/docs/configuration/variables.html.md diff --git a/website/source/docs/configuration/providers.html.md b/website/source/docs/configuration/providers.html.md new file mode 100644 index 000000000..d1c9b8d63 --- /dev/null +++ b/website/source/docs/configuration/providers.html.md @@ -0,0 +1,76 @@ +--- +layout: "docs" +page_title: "Configuring Providers" +sidebar_current: "docs-config-providers" +--- + +# Provider Configuration + +Providers are responsible in Terraform for managing the lifecycle +of a [resource](/docs/configuration/resource.html): create, +read, update, delete. + +Every resource in Terraform is mapped to a provider based +on longest-prefix matching. For example the `aws_instance` +resource type would map to the `aws` provider (if that exists). + +Most providers require some sort of configuration to provide +authentication information, endpoint URLs, etc. Provider configuration +blocks are a way to set this information globally for all +matching resources. + +This page assumes you're familiar with the +[configuration syntax](/docs/configuration/syntax.html) +already. + +## Example + +A provider configuration looks like the following: + +``` +provider "aws" { + access_key = "foo" + secret_key = "bar" + region = "us-east-1" +} +``` + +## Decription + +The `provider` block configures the provider of the given `NAME`. +Multiple provider blocks can be used to configure multiple providers. + +Terraform matches providers to resources by matching two criteria. +Both criteria must be matched for a provider to manage a resource: + + * They must share a common prefix. Longest matching prefixes are + tried first. For example, `aws_instance` would choose the + `aws` provider. + + * The provider must report that it supports the given resource + type. Providers internally tell Terraform the list of resources + they support. + +Within the block (the `{ }`) is configuration for the resource. +The configuration is dependent on the type, and is documented +[for each provider](/docs/providers/index.html). + +## Syntax + +The full syntax is: + +``` +provider NAME { + CONFIG ... +} +``` + +where `CONFIG` is: + +``` +KEY = VALUE + +KEY { + CONFIG +} +``` diff --git a/website/source/docs/configuration/variables.html.md b/website/source/docs/configuration/variables.html.md new file mode 100644 index 000000000..59b37fdc4 --- /dev/null +++ b/website/source/docs/configuration/variables.html.md @@ -0,0 +1,111 @@ +--- +layout: "docs" +page_title: "Configuring Variables" +sidebar_current: "docs-config-variables" +--- + +# Variable Configuration + +Variables define the parameterization of Terraform configurations. +Variables can be overridden via the CLI. Variable usage is +covered in more detail in the +[getting started guide](/intro/getting-started/variables.html). +This page covers configuration syntax for variables. + +This page assumes you're familiar with the +[configuration syntax](/docs/configuration/syntax.html) +already. + +## Example + +A variable configuration looks like the following: + +``` +variable "key" {} + +variable "images" { + default = { + "us-east-1": "image-1234", + "us-west-2": "image-4567", + } +} +``` + +## Decription + +The `variable` block configures a single input variable for +a Terraform configuration. Multiple variables blocks can be used to +add multiple variables. + +The `NAME` given to the variable block is the name used to +set the variable via the CLI as well as reference the variable +throughout the Terraform configuration. + +Within the block (the `{ }`) is configuration for the variable. +These are the parameters that can be set: + + * `default` (optional) - If set, this sets a default value + for the variable. If this isn't set, the variable is required + and Terraform will error if not set. The default value can be + a string or a mapping. This is covered in more detail below. + + * `description` (optional) - A human-friendly description for + the variable. This is primarily for documentation for users + using your Terraform configuration. A future version of Terraform + will expose these descriptions as part of some Terraform CLI + command. + +------ + +**Default values** can be either strings or maps. If a default +value is omitted and the variable is required, the value assigned +via the CLI must be a string. + +String values are simple and represent a basic key to value +mapping where the key is the variable name. An example is: + +``` +variable "key" { + default = "value" +} +``` + +A map allows a key to contain a lookup table. This is useful +for some values that change depending on some external pivot. +A common use case for this is mapping cloud images to regions. +An example: + +``` +variable "images" { + default = { + "us-east-1": "image-1234", + "us-west-2": "image-4567", + } +} +``` + +The usage of maps, strings, etc. is documented fully in the +[interpolation syntax](/docs/configuration/interpolation.html) +page. + +## Syntax + +The full syntax is: + +``` +variable NAME { + [default = DEFAULT] + [description = DESCRIPTION] +} +``` + +where `DEFAULT` is: + +``` +VALUE + +{ + KEY: VALUE, + ... +} +```