2014-07-23 23:41:48 +02:00
|
|
|
---
|
|
|
|
layout: "aws"
|
|
|
|
page_title: "AWS: aws_instance"
|
|
|
|
sidebar_current: "docs-aws-resource-instance"
|
|
|
|
---
|
|
|
|
|
|
|
|
# aws\_instance
|
|
|
|
|
|
|
|
Provides an EC2 instance resource. This allows instances to be created, updated,
|
|
|
|
and deleted. Instances also support [provisioning](/docs/provisioners/index.html).
|
|
|
|
|
|
|
|
## Example Usage
|
|
|
|
|
|
|
|
```
|
2014-10-13 22:55:59 +02:00
|
|
|
# Create a new instance of the ami-1234 on an m1.small node with an AWS Tag naming it "HelloWorld"
|
|
|
|
resource "aws_instance" "web" {
|
|
|
|
ami = "ami-1234"
|
|
|
|
instance_type = "m1.small"
|
|
|
|
tags {
|
|
|
|
Name = "HelloWorld"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2014-07-23 23:41:48 +02:00
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
|
|
|
* `ami` - (Required) The AMI to use for the instance.
|
|
|
|
* `availability_zone` - (Optional) The AZ to start the instance in.
|
2014-09-08 01:03:48 +02:00
|
|
|
* `ebs_optimized` - (Optional) If true, the launched EC2 instance will be
|
|
|
|
EBS-optimized.
|
2014-07-23 23:41:48 +02:00
|
|
|
* `instance_type` - (Required) The type of instance to start
|
|
|
|
* `key_name` - (Optional) The key name to use for the instance.
|
2014-07-25 00:57:07 +02:00
|
|
|
* `security_groups` - (Optional) A list of security group IDs or names to associate with.
|
|
|
|
If you are within a VPC, you'll need to use the security group ID. Otherwise,
|
|
|
|
for EC2, use the security group name.
|
2014-07-23 23:41:48 +02:00
|
|
|
* `subnet_id` - (Optional) The VPC Subnet ID to launch in.
|
2014-07-29 14:12:43 +02:00
|
|
|
* `associate_public_ip_address` - (Optional) Associate a public ip address with an instance in a VPC.
|
2014-09-01 10:06:39 +02:00
|
|
|
* `private_ip` - (Optional) Private IP address to associate with the
|
2014-08-22 02:17:50 +02:00
|
|
|
instance in a VPC.
|
2014-07-23 23:41:48 +02:00
|
|
|
* `source_dest_check` - (Optional) Controls if traffic is routed to the instance when
|
2014-09-16 13:40:16 +02:00
|
|
|
the destination address does not match the instance. Used for NAT or VPNs. Defaults true.
|
2014-07-23 23:41:48 +02:00
|
|
|
* `user_data` - (Optional) The user data to provide when launching the instance.
|
2014-09-23 20:06:30 +02:00
|
|
|
* `iam_instance_profile` - (Optional) The IAM Instance Profile to
|
|
|
|
launch the instance with.
|
2014-10-13 22:55:59 +02:00
|
|
|
* `tags` - (Optional) A mapping of tags to assign to the resource.
|
2014-07-23 23:41:48 +02:00
|
|
|
|
|
|
|
## Attributes Reference
|
|
|
|
|
|
|
|
The following attributes are exported:
|
|
|
|
|
|
|
|
* `id` - The instance ID.
|
|
|
|
* `availability_zone` - The availability zone of the instance.
|
|
|
|
* `key_name` - The key name of the instance
|
|
|
|
* `private_dns` - The Private DNS name of the instance
|
|
|
|
* `private_ip` - The private IP address.
|
|
|
|
* `public_dns` - The public DNS name of the instance
|
|
|
|
* `public_ip` - The public IP address.
|
|
|
|
* `security_groups` - The associated security groups.
|
|
|
|
* `subnet_id` - The VPC subnet ID.
|