github.com/chalford/terraform@v0.3.7-0.20150113080010-a78c69a8c81f/website/source/docs/providers/aws/r/instance.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_instance" 4 sidebar_current: "docs-aws-resource-instance" 5 description: |- 6 Provides an EC2 instance resource. This allows instances to be created, updated, and deleted. Instances also support provisioning. 7 --- 8 9 # aws\_instance 10 11 Provides an EC2 instance resource. This allows instances to be created, updated, 12 and deleted. Instances also support [provisioning](/docs/provisioners/index.html). 13 14 ## Example Usage 15 16 ``` 17 # Create a new instance of the ami-1234 on an m1.small node with an AWS Tag naming it "HelloWorld" 18 resource "aws_instance" "web" { 19 ami = "ami-1234" 20 instance_type = "m1.small" 21 tags { 22 Name = "HelloWorld" 23 } 24 } 25 ``` 26 27 ## Argument Reference 28 29 The following arguments are supported: 30 31 * `ami` - (Required) The AMI to use for the instance. 32 * `availability_zone` - (Optional) The AZ to start the instance in. 33 * `ebs_optimized` - (Optional) If true, the launched EC2 instance will be 34 EBS-optimized. 35 * `instance_type` - (Required) The type of instance to start 36 * `key_name` - (Optional) The key name to use for the instance. 37 * `security_groups` - (Optional) A list of security group IDs or names to associate with. 38 If you are within a non-default VPC, you'll need to use the security group ID. Otherwise, 39 for EC2 and the default VPC, use the security group name. 40 * `subnet_id` - (Optional) The VPC Subnet ID to launch in. 41 * `associate_public_ip_address` - (Optional) Associate a public ip address with an instance in a VPC. 42 * `private_ip` - (Optional) Private IP address to associate with the 43 instance in a VPC. 44 * `source_dest_check` - (Optional) Controls if traffic is routed to the instance when 45 the destination address does not match the instance. Used for NAT or VPNs. Defaults true. 46 * `user_data` - (Optional) The user data to provide when launching the instance. 47 * `iam_instance_profile` - (Optional) The IAM Instance Profile to 48 launch the instance with. 49 * `tags` - (Optional) A mapping of tags to assign to the resource. 50 * `block_device` - (Optional) A list of block devices to add. Their keys are documented below. 51 52 Each `block_device` supports the following: 53 54 * `device_name` - The name of the device to mount. 55 * `virtual_name` - (Optional) The virtual device name. 56 * `snapshot_id` - (Optional) The Snapshot ID to mount. 57 * `volume_type` - (Optional) The type of volume. Can be standard, gp2, or io1. Defaults to standard. 58 * `volume_size` - (Optional) The size of the volume in gigabytes. 59 * `delete_on_termination` - (Optional) Should the volume be destroyed on instance termination (defaults true). 60 * `encrypted` - (Optional) Should encryption be enabled (defaults false). 61 62 ## Attributes Reference 63 64 The following attributes are exported: 65 66 * `id` - The instance ID. 67 * `availability_zone` - The availability zone of the instance. 68 * `key_name` - The key name of the instance 69 * `private_dns` - The Private DNS name of the instance 70 * `private_ip` - The private IP address. 71 * `public_dns` - The public DNS name of the instance 72 * `public_ip` - The public IP address. 73 * `security_groups` - The associated security groups. 74 * `subnet_id` - The VPC subnet ID.