github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/website/source/docs/providers/aws/r/launch_configuration.html.markdown (about)

     1  ---
     2  layout: "aws"
     3  page_title: "AWS: aws_launch_configuration"
     4  sidebar_current: "docs-aws-resource-launch-configuration"
     5  description: |-
     6    Provides a resource to create a new launch configuration, used for autoscaling groups.
     7  ---
     8  
     9  # aws\_launch\_configuration
    10  
    11  Provides a resource to create a new launch configuration, used for autoscaling groups.
    12  
    13  ## Example Usage
    14  
    15  ```
    16  resource "aws_launch_configuration" "as_conf" {
    17      name = "web_config"
    18      image_id = "ami-1234"
    19      instance_type = "m1.small"
    20  }
    21  ```
    22  
    23  ## Using with AutoScaling Groups
    24  
    25  Launch Configurations cannot be updated after creation with the Amazon
    26  Web Service API. In order to update a Launch Configuration, Terraform will
    27  destroy the existing resource and create a replacement. In order to effectively
    28  use a Launch Configuration resource with an [AutoScaling Group resource][1],
    29  it's recommended to specify `create_before_destroy` in a [lifecycle][2] block.
    30  Either omit the Launch Configuration `name` attribute, or specify a partial name
    31  with `name_prefix`.  Example:
    32  
    33  ```
    34  resource "aws_launch_configuration" "as_conf" {
    35      name_prefix = "terraform-lc-example-"
    36      image_id = "ami-1234"
    37      instance_type = "m1.small"
    38  
    39      lifecycle {
    40        create_before_destroy = true
    41      }
    42  }
    43  
    44  resource "aws_autoscaling_group" "bar" {
    45      name = "terraform-asg-example"
    46      launch_configuration = "${aws_launch_configuration.as_conf.name}"
    47  
    48      lifecycle {
    49        create_before_destroy = true
    50      }
    51  }
    52  ```
    53  
    54  With this setup Terraform generates a unique name for your Launch
    55  Configuration and can then update the AutoScaling Group without conflict before
    56  destroying the previous Launch Configuration.
    57  
    58  ## Using with Spot Instances
    59  
    60  Launch configurations can set the spot instance pricing to be used for the
    61  Auto Scaling Group to reserve instances. Simply specifying the `spot_price`
    62  parameter will set the price on the Launch Configuration which will attempt to
    63  reserve your instances at this price.  See the [AWS Spot Instance
    64  documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html)
    65  for more information or how to launch [Spot Instances][3] with Terraform.
    66  
    67  ```
    68  resource "aws_launch_configuration" "as_conf" {
    69      image_id = "ami-1234"
    70      instance_type = "m1.small"
    71      spot_price = "0.001"
    72      lifecycle {
    73        create_before_destroy = true
    74      }
    75  }
    76  
    77  resource "aws_autoscaling_group" "bar" {
    78      name = "terraform-asg-example"
    79      launch_configuration = "${aws_launch_configuration.as_conf.name}"
    80  
    81      lifecycle {
    82        create_before_destroy = true
    83      }
    84  }
    85  ```
    86  
    87  ## Argument Reference
    88  
    89  The following arguments are supported:
    90  
    91  * `name` - (Optional) The name of the launch configuration. If you leave
    92    this blank, Terraform will auto-generate a unique name.
    93  * `name_prefix` - (Optional) Creates a unique name beginning with the specified
    94    prefix. Conflicts with `name`.
    95  * `image_id` - (Required) The EC2 image ID to launch.
    96  * `instance_type` - (Required) The size of instance to launch.
    97  * `iam_instance_profile` - (Optional) The IAM instance profile to associate
    98       with launched instances.
    99  * `key_name` - (Optional) The key name that should be used for the instance.
   100  * `security_groups` - (Optional) A list of associated security group IDS.
   101  * `associate_public_ip_address` - (Optional) Associate a public ip address with an instance in a VPC.
   102  * `user_data` - (Optional) The user data to provide when launching the instance.
   103  * `enable_monitoring` - (Optional) Enables/disables detailed monitoring. This is enabled by default.
   104  * `ebs_optimized` - (Optional) If true, the launched EC2 instance will be EBS-optimized.
   105  * `root_block_device` - (Optional) Customize details about the root block
   106    device of the instance. See [Block Devices](#block-devices) below for details.
   107  * `ebs_block_device` - (Optional) Additional EBS block devices to attach to the
   108    instance.  See [Block Devices](#block-devices) below for details.
   109  * `ephemeral_block_device` - (Optional) Customize Ephemeral (also known as
   110    "Instance Store") volumes on the instance. See [Block Devices](#block-devices) below for details.
   111  * `spot_price` - (Optional) The price to use for reserving spot instances.
   112  
   113  <a id="block-devices"></a>
   114  ## Block devices
   115  
   116  Each of the `*_block_device` attributes controls a portion of the AWS
   117  Launch Configuration's "Block Device Mapping". It's a good idea to familiarize yourself with [AWS's Block Device
   118  Mapping docs](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html)
   119  to understand the implications of using these attributes.
   120  
   121  The `root_block_device` mapping supports the following:
   122  
   123  * `volume_type` - (Optional) The type of volume. Can be `"standard"`, `"gp2"`,
   124    or `"io1"`. (Default: `"standard"`).
   125  * `volume_size` - (Optional) The size of the volume in gigabytes.
   126  * `iops` - (Optional) The amount of provisioned
   127    [IOPS](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-io-characteristics.html).
   128    This must be set with a `volume_type` of `"io1"`.
   129  * `delete_on_termination` - (Optional) Whether the volume should be destroyed
   130    on instance termination (Default: `true`).
   131  
   132  Modifying any of the `root_block_device` settings requires resource
   133  replacement.
   134  
   135  Each `ebs_block_device` supports the following:
   136  
   137  * `device_name` - (Required) The name of the device to mount.
   138  * `snapshot_id` - (Optional) The Snapshot ID to mount.
   139  * `volume_type` - (Optional) The type of volume. Can be `"standard"`, `"gp2"`,
   140    or `"io1"`. (Default: `"standard"`).
   141  * `volume_size` - (Optional) The size of the volume in gigabytes.
   142  * `iops` - (Optional) The amount of provisioned
   143    [IOPS](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-io-characteristics.html).
   144    This must be set with a `volume_type` of `"io1"`.
   145  * `delete_on_termination` - (Optional) Whether the volume should be destroyed
   146    on instance termination (Default: `true`).
   147  
   148  Modifying any `ebs_block_device` currently requires resource replacement.
   149  
   150  Each `ephemeral_block_device` supports the following:
   151  
   152  * `device_name` - The name of the block device to mount on the instance.
   153  * `virtual_name` - The [Instance Store Device
   154    Name](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#InstanceStoreDeviceNames)
   155    (e.g. `"ephemeral0"`)
   156  
   157  Each AWS Instance type has a different set of Instance Store block devices
   158  available for attachment. AWS [publishes a
   159  list](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#StorageOnInstanceTypes)
   160  of which ephemeral devices are available on each type. The devices are always
   161  identified by the `virtual_name` in the format `"ephemeral{0..N}"`.
   162  
   163  ~> **NOTE:** Changes to `*_block_device` configuration of _existing_ resources
   164  cannot currently be detected by Terraform. After updating to block device
   165  configuration, resource recreation can be manually triggered by using the
   166  [`taint` command](/docs/commands/taint.html).
   167  
   168  ## Attributes Reference
   169  
   170  The following attributes are exported:
   171  
   172  * `id` - The ID of the launch configuration.
   173  
   174  [1]: /docs/providers/aws/r/autoscaling_group.html
   175  [2]: /docs/configuration/resources.html#lifecycle
   176  [3]: /docs/providers/aws/r/spot_instance_request.html