github.com/erriapo/terraform@v0.6.12-0.20160203182612-0340ea72354f/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-408c7f28"
    19      instance_type = "t1.micro"
    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-408c7f28"
    37      instance_type = "t1.micro"
    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-408c7f28"
    70      instance_type = "t1.micro"
    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  ```
    82  
    83  ## Argument Reference
    84  
    85  The following arguments are supported:
    86  
    87  * `name` - (Optional) The name of the launch configuration. If you leave
    88    this blank, Terraform will auto-generate a unique name.
    89  * `name_prefix` - (Optional) Creates a unique name beginning with the specified
    90    prefix. Conflicts with `name`.
    91  * `image_id` - (Required) The EC2 image ID to launch.
    92  * `instance_type` - (Required) The size of instance to launch.
    93  * `iam_instance_profile` - (Optional) The IAM instance profile to associate
    94       with launched instances.
    95  * `key_name` - (Optional) The key name that should be used for the instance.
    96  * `security_groups` - (Optional) A list of associated security group IDS.
    97  * `associate_public_ip_address` - (Optional) Associate a public ip address with an instance in a VPC.
    98  * `user_data` - (Optional) The user data to provide when launching the instance.
    99  * `enable_monitoring` - (Optional) Enables/disables detailed monitoring. This is enabled by default.
   100  * `ebs_optimized` - (Optional) If true, the launched EC2 instance will be EBS-optimized.
   101  * `root_block_device` - (Optional) Customize details about the root block
   102    device of the instance. See [Block Devices](#block-devices) below for details.
   103  * `ebs_block_device` - (Optional) Additional EBS block devices to attach to the
   104    instance.  See [Block Devices](#block-devices) below for details.
   105  * `ephemeral_block_device` - (Optional) Customize Ephemeral (also known as
   106    "Instance Store") volumes on the instance. See [Block Devices](#block-devices) below for details.
   107  * `spot_price` - (Optional) The price to use for reserving spot instances.
   108  * `placement_tenancy` - (Optional) The tenancy of the instance. Valid values are
   109    `"default"` or `"dedicated"`, see [AWS's Create Launch Configuration](http://docs.aws.amazon.com/AutoScaling/latest/APIReference/API_CreateLaunchConfiguration.html)
   110    for more details
   111  
   112  <a id="block-devices"></a>
   113  ## Block devices
   114  
   115  Each of the `*_block_device` attributes controls a portion of the AWS
   116  Launch Configuration's "Block Device Mapping". It's a good idea to familiarize yourself with [AWS's Block Device
   117  Mapping docs](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html)
   118  to understand the implications of using these attributes.
   119  
   120  The `root_block_device` mapping supports the following:
   121  
   122  * `volume_type` - (Optional) The type of volume. Can be `"standard"`, `"gp2"`,
   123    or `"io1"`. (Default: `"standard"`).
   124  * `volume_size` - (Optional) The size of the volume in gigabytes.
   125  * `iops` - (Optional) The amount of provisioned
   126    [IOPS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-io-characteristics.html).
   127    This must be set with a `volume_type` of `"io1"`.
   128  * `delete_on_termination` - (Optional) Whether the volume should be destroyed
   129    on instance termination (Default: `true`).
   130  
   131  Modifying any of the `root_block_device` settings requires resource
   132  replacement.
   133  
   134  Each `ebs_block_device` supports the following:
   135  
   136  * `device_name` - (Required) The name of the device to mount.
   137  * `snapshot_id` - (Optional) The Snapshot ID to mount.
   138  * `volume_type` - (Optional) The type of volume. Can be `"standard"`, `"gp2"`,
   139    or `"io1"`. (Default: `"standard"`).
   140  * `volume_size` - (Optional) The size of the volume in gigabytes.
   141  * `iops` - (Optional) The amount of provisioned
   142    [IOPS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-io-characteristics.html).
   143    This must be set with a `volume_type` of `"io1"`.
   144  * `delete_on_termination` - (Optional) Whether the volume should be destroyed
   145    on instance termination (Default: `true`).
   146  * `encryption` - (Optional) Whether the volume should be encrypted or not. Do not use this option if you are using `snapshot_id` as the encryption flag will be determined by the snapshot. (Default: `false`).
   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](https://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](https://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