github.com/jrasell/terraform@v0.6.17-0.20160523115548-2652f5232949/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  ## Block devices
   113  
   114  Each of the `*_block_device` attributes controls a portion of the AWS
   115  Launch Configuration's "Block Device Mapping". It's a good idea to familiarize yourself with [AWS's Block Device
   116  Mapping docs](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html)
   117  to understand the implications of using these attributes.
   118  
   119  The `root_block_device` mapping supports the following:
   120  
   121  * `volume_type` - (Optional) The type of volume. Can be `"standard"`, `"gp2"`,
   122    or `"io1"`. (Default: `"standard"`).
   123  * `volume_size` - (Optional) The size of the volume in gigabytes.
   124  * `iops` - (Optional) The amount of provisioned
   125    [IOPS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-io-characteristics.html).
   126    This must be set with a `volume_type` of `"io1"`.
   127  * `delete_on_termination` - (Optional) Whether the volume should be destroyed
   128    on instance termination (Default: `true`).
   129  
   130  Modifying any of the `root_block_device` settings requires resource
   131  replacement.
   132  
   133  Each `ebs_block_device` supports the following:
   134  
   135  * `device_name` - (Required) The name of the device to mount.
   136  * `snapshot_id` - (Optional) The Snapshot ID to mount.
   137  * `volume_type` - (Optional) The type of volume. Can be `"standard"`, `"gp2"`,
   138    or `"io1"`. (Default: `"standard"`).
   139  * `volume_size` - (Optional) The size of the volume in gigabytes.
   140  * `iops` - (Optional) The amount of provisioned
   141    [IOPS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-io-characteristics.html).
   142    This must be set with a `volume_type` of `"io1"`.
   143  * `delete_on_termination` - (Optional) Whether the volume should be destroyed
   144    on instance termination (Default: `true`).
   145  * `encrypted` - (Optional) Whether the volume should be encrypted or not. Do not use this option if you are using `snapshot_id` as the encrypted flag will be determined by the snapshot. (Default: `false`).
   146  
   147  Modifying any `ebs_block_device` currently requires resource replacement.
   148  
   149  Each `ephemeral_block_device` supports the following:
   150  
   151  * `device_name` - The name of the block device to mount on the instance.
   152  * `virtual_name` - The [Instance Store Device
   153    Name](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#InstanceStoreDeviceNames)
   154    (e.g. `"ephemeral0"`)
   155  
   156  Each AWS Instance type has a different set of Instance Store block devices
   157  available for attachment. AWS [publishes a
   158  list](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#StorageOnInstanceTypes)
   159  of which ephemeral devices are available on each type. The devices are always
   160  identified by the `virtual_name` in the format `"ephemeral{0..N}"`.
   161  
   162  ~> **NOTE:** Changes to `*_block_device` configuration of _existing_ resources
   163  cannot currently be detected by Terraform. After updating to block device
   164  configuration, resource recreation can be manually triggered by using the
   165  [`taint` command](/docs/commands/taint.html).
   166  
   167  ## Attributes Reference
   168  
   169  The following attributes are exported:
   170  
   171  * `id` - The ID of the launch configuration.
   172  
   173  [1]: /docs/providers/aws/r/autoscaling_group.html
   174  [2]: /docs/configuration/resources.html#lifecycle
   175  [3]: /docs/providers/aws/r/spot_instance_request.html