github.com/ezbercih/terraform@v0.1.1-0.20140729011846-3c33865e0839/website/source/docs/configuration/resources.html.md (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Configuring Resources"
     4  sidebar_current: "docs-config-resources"
     5  ---
     6  
     7  # Resource Configuration
     8  
     9  The most important thing you'll configure with Terraform are
    10  resources. Resources are a component of your infrastructure.
    11  It might be some low level component such as a physical server,
    12  virtual machine, or container. Or it can be a higher level
    13  component such as an email provider, DNS record, or database
    14  provider.
    15  
    16  This page assumes you're familiar with the
    17  [configuration syntax](/docs/configuration/syntax.html)
    18  already.
    19  
    20  ## Example
    21  
    22  A resource configuration looks like the following:
    23  
    24  ```
    25  resource "aws_instance" "web" {
    26      ami = "ami-123456"
    27      instance_type = "m1.small"
    28  }
    29  ```
    30  
    31  ## Decription
    32  
    33  The `resource` block creates a resource of the given `TYPE` (first
    34  parameter) and `NAME` (second parameter). The combination of the type
    35  and name must be unique.
    36  
    37  Within the block (the `{ }`) is configuration for the resource. The
    38  configuration is dependent on the type, and is documented for each
    39  resource type in the
    40  [providers section](/docs/providers/index.html).
    41  
    42  There are **meta-parameters** available to all resources:
    43  
    44    * `count` (int) - The number of identical resources to create.
    45        This doesn't apply to all resources.
    46  
    47    * `depends_on` (list of strings) - Explicit dependencies that this
    48        resource has. These dependencies will be created before this
    49        resource. The dependencies are in the format of `TYPE.NAME`,
    50        for example `aws_instance.web`.
    51  
    52  -------------
    53  
    54  Within a resource, you can optionally have a **connection block**.
    55  Connection blocks describe to Terraform how to connect to the
    56  resource for
    57  [provisioning](/docs/provisioners/index.html). This block doesn't
    58  need to be present if you're using only local provisioners, or
    59  if you're not provisioning at all.
    60  
    61  Resources provide some data on their own, such as an IP address,
    62  but other data must be specified by the user.
    63  
    64  The full list of settings that can be specified are listed on
    65  the [provisioner connection page](/docs/provisioners/connection.html).
    66  
    67  -------------
    68  
    69  Within a resource, you can specify zero or more **provisioner
    70  blocks**. Provisioner blocks configure
    71  [provisioners](/docs/provisioners/index.html).
    72  
    73  Within the provisioner block is provisioner-specific configuration,
    74  much like resource-specific configuration.
    75  
    76  Provisioner blocks can also contain a connection block
    77  (documented above). This connection block can be used to
    78  provide more specific connection info for a specific provisioner.
    79  An example use case might be to use a different user to log in
    80  for a single provisioner.
    81  
    82  ## Syntax
    83  
    84  The full syntax is:
    85  
    86  ```
    87  resource TYPE NAME {
    88  	CONFIG ...
    89  	[count = COUNT]
    90  	[depends_on = [RESOURCE NAME, ...]]
    91  
    92  	[CONNECTION]
    93  	[PROVISIONER ...]
    94  }
    95  ```
    96  
    97  where `CONFIG` is:
    98  
    99  ```
   100  KEY = VALUE
   101  
   102  KEY {
   103  	CONFIG
   104  }
   105  ```
   106  
   107  where `CONNECTION` is:
   108  
   109  ```
   110  connection {
   111  	KEY = VALUE
   112  	...
   113  }
   114  ```
   115  
   116  where `PROVISIONER` is:
   117  
   118  ```
   119  provisioner NAME {
   120  	CONFIG ...
   121  
   122  	[CONNECTION]
   123  }
   124  ```