github.com/jsoriano/terraform@v0.6.7-0.20151026070445-8b70867fdd95/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 recommend to omit the Launch Configuration `name` attribute, and 30 specify `create_before_destroy` in a [lifecycle][2] block, as shown: 31 32 ``` 33 resource "aws_launch_configuration" "as_conf" { 34 image_id = "ami-1234" 35 instance_type = "m1.small" 36 37 lifecycle { 38 create_before_destroy = true 39 } 40 } 41 42 resource "aws_autoscaling_group" "bar" { 43 name = "terraform-asg-example" 44 launch_configuration = "${aws_launch_configuration.as_conf.name}" 45 46 lifecycle { 47 create_before_destroy = true 48 } 49 } 50 ``` 51 52 With this setup Terraform generates a unique name for your Launch 53 Configuration and can then update the AutoScaling Group without conflict before 54 destroying the previous Launch Configuration. 55 56 ## Using with Spot Instances 57 58 Launch configurations can set the spot instance pricing to be used for the 59 Auto Scaling Group to reserve instances. Simply specifying the `spot_price` 60 parameter will set the price on the Launch Configuration which will attempt to 61 reserve your instances at this price. See the [AWS Spot Instance 62 documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html) 63 for more information or how to launch [Spot Instances][3] with Terraform. 64 65 ``` 66 resource "aws_launch_configuration" "as_conf" { 67 image_id = "ami-1234" 68 instance_type = "m1.small" 69 spot_price = "0.001" 70 lifecycle { 71 create_before_destroy = true 72 } 73 } 74 75 resource "aws_autoscaling_group" "bar" { 76 name = "terraform-asg-example" 77 launch_configuration = "${aws_launch_configuration.as_conf.name}" 78 79 lifecycle { 80 create_before_destroy = true 81 } 82 } 83 ``` 84 85 ## Argument Reference 86 87 The following arguments are supported: 88 89 * `name` - (Optional) The name of the launch configuration. If you leave 90 this blank, Terraform will auto-generate it. 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 109 <a id="block-devices"></a> 110 ## Block devices 111 112 Each of the `*_block_device` attributes controls a portion of the AWS 113 Launch Configuration's "Block Device Mapping". It's a good idea to familiarize yourself with [AWS's Block Device 114 Mapping docs](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html) 115 to understand the implications of using these attributes. 116 117 The `root_block_device` mapping supports the following: 118 119 * `volume_type` - (Optional) The type of volume. Can be `"standard"`, `"gp2"`, 120 or `"io1"`. (Default: `"standard"`). 121 * `volume_size` - (Optional) The size of the volume in gigabytes. 122 * `iops` - (Optional) The amount of provisioned 123 [IOPS](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-io-characteristics.html). 124 This must be set with a `volume_type` of `"io1"`. 125 * `delete_on_termination` - (Optional) Whether the volume should be destroyed 126 on instance termination (Default: `true`). 127 128 Modifying any of the `root_block_device` settings requires resource 129 replacement. 130 131 Each `ebs_block_device` supports the following: 132 133 * `device_name` - (Required) The name of the device to mount. 134 * `snapshot_id` - (Optional) The Snapshot ID to mount. 135 * `volume_type` - (Optional) The type of volume. Can be `"standard"`, `"gp2"`, 136 or `"io1"`. (Default: `"standard"`). 137 * `volume_size` - (Optional) The size of the volume in gigabytes. 138 * `iops` - (Optional) The amount of provisioned 139 [IOPS](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-io-characteristics.html). 140 This must be set with a `volume_type` of `"io1"`. 141 * `delete_on_termination` - (Optional) Whether the volume should be destroyed 142 on instance termination (Default: `true`). 143 144 Modifying any `ebs_block_device` currently requires resource replacement. 145 146 Each `ephemeral_block_device` supports the following: 147 148 * `device_name` - The name of the block device to mount on the instance. 149 * `virtual_name` - The [Instance Store Device 150 Name](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#InstanceStoreDeviceNames) 151 (e.g. `"ephemeral0"`) 152 153 Each AWS Instance type has a different set of Instance Store block devices 154 available for attachment. AWS [publishes a 155 list](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#StorageOnInstanceTypes) 156 of which ephemeral devices are available on each type. The devices are always 157 identified by the `virtual_name` in the format `"ephemeral{0..N}"`. 158 159 ~> **NOTE:** Changes to `*_block_device` configuration of _existing_ resources 160 cannot currently be detected by Terraform. After updating to block device 161 configuration, resource recreation can be manually triggered by using the 162 [`taint` command](/docs/commands/taint.html). 163 164 ## Attributes Reference 165 166 The following attributes are exported: 167 168 * `id` - The ID of the launch configuration. 169 170 [1]: /docs/providers/aws/r/autoscaling_group.html 171 [2]: /docs/configuration/resources.html#lifecycle 172 [3]: /docs/providers/aws/r/spot_instance_request.html