github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/website/source/docs/providers/random/r/pet.html.md (about)

     1  ---
     2  layout: "random"
     3  page_title: "Random: random_pet"
     4  sidebar_current: "docs-random-resource-pet"
     5  description: |-
     6    Generates a random pet.
     7  ---
     8  
     9  # random\_pet
    10  
    11  The resource `random_pet` generates random pet names that are intended to be
    12  used as unique identifiers for other resources.
    13  
    14  This resource can be used in conjunction with resources that have
    15  the `create_before_destroy` lifecycle flag set, to avoid conflicts with
    16  unique names during the brief period where both the old and new resources
    17  exist concurrently.
    18  
    19  ## Example Usage
    20  
    21  The following example shows how to generate a unique pet name for an AWS EC2
    22  instance that changes each time a new AMI id is selected.
    23  
    24  ```hcl
    25  resource "random_pet" "server" {
    26    keepers = {
    27      # Generate a new pet name each time we switch to a new AMI id
    28      ami_id = "${var.ami_id}"
    29    }
    30  }
    31  
    32  resource "aws_instance" "server" {
    33    tags = {
    34      Name = "web-server-${random_pet.server.id}"
    35    }
    36  
    37    # Read the AMI id "through" the random_pet resource to ensure that
    38    # both will change together.
    39    ami = "${random_pet.server.keepers.ami_id}"
    40  
    41    # ... (other aws_instance arguments) ...
    42  }
    43  ```
    44  
    45  The result of the above will set the Name of the AWS Instance to
    46  `web-server-simple-snake`.
    47  
    48  ## Argument Reference
    49  
    50  The following arguments are supported:
    51  
    52  * `keepers` - (Optional) Arbitrary map of values that, when changed, will
    53    trigger a new id to be generated. See
    54    [the main provider documentation](../index.html) for more information.
    55  
    56  * `length` - (Optional) The length (in words) of the pet name.
    57  
    58  * `prefix` - (Optional) A string to prefix the name with.
    59  
    60  * `separator` - (Optional) The character to separate words in the pet name.
    61  
    62  ## Attribute Reference
    63  
    64  The following attributes are supported:
    65  
    66  * `id` - (string) The random pet name