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