* master: (84 commits) provider/aws: Update to aws-sdk 0.9.0 rc1 use name instead of id - launch configs use the name and not ID Fix typo on heroku_cert example provider/aws: add value into ELB name validation message tests: fix missed test update from last merge update prevent_destroy error message Update CHANGELOG.md Update CHANGELOG.md providers/aws: Update Launch Config. docs to detail naming and lifecycle recommendation release: cleanup after v0.6.3 v0.6.3 Update CHANGELOG.md core: fix deadlock when dependable node replaced with non-dependable one tests: extract deadlock checking test helper core: log every 5s while waiting for dependencies Fixed indentation in a code sample state/remote/s3: match with upstream changes provider/aws: match with upstream changes google: Add example of two-tier app Updating Launch Config Docs for Name attribute ...
6.7 KiB
layout, page_title, sidebar_current, description
| layout | page_title | sidebar_current | description |
|---|---|---|---|
| aws | AWS: aws_instance | docs-aws-resource-instance | Provides an EC2 instance resource. This allows instances to be created, updated, and deleted. Instances also support provisioning. |
aws_instance
Provides an EC2 instance resource. This allows instances to be created, updated, and deleted. Instances also support provisioning.
Example Usage
# 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"
}
}
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.placement_group- (Optional) The Placement Group to start the instance in.ebs_optimized- (Optional) If true, the launched EC2 instance will be EBS-optimized.disable_api_termination- (Optional) If true, enables EC2 Instance Termination Protectioninstance_initiated_shutdown_behavior- (Optional) Shutdown behavior for the instance. Amazon defaults this tostopfor EBS-backed instances andterminatefor instance-store instances. Cannot be set on instance-store instances. See Shutdown Behavior for more information.instance_type- (Required) The type of instance to startkey_name- (Optional) The key name to use for the instance.monitoring- (Optional) If true, the launched EC2 instance will have detailed monitoring enabled. (Available since v0.6.0)security_groups- (Optional) A list of security group names to associate with. If you are within a non-default VPC, you'll need to usevpc_security_group_idsinstead.vpc_security_group_ids- (Optional) A list of security group IDs to associate with.subnet_id- (Optional) The VPC Subnet ID to launch in.associate_public_ip_address- (Optional) Associate a public ip address with an instance in a VPC.private_ip- (Optional) Private IP address to associate with the instance in a VPC.source_dest_check- (Optional) Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. Defaults true.user_data- (Optional) The user data to provide when launching the instance.iam_instance_profile- (Optional) The IAM Instance Profile to launch the instance with.tags- (Optional) A mapping of tags to assign to the resource.root_block_device- (Optional) Customize details about the root block device of the instance. See Block Devices below for details.ebs_block_device- (Optional) Additional EBS block devices to attach to the instance. See Block Devices below for details.ephemeral_block_device- (Optional) Customize Ephemeral (also known as "Instance Store") volumes on the instance. See Block Devices below for details.
Block devices
Each of the *_block_device attributes controls a portion of the AWS
Instance's "Block Device Mapping". It's a good idea to familiarize yourself with AWS's Block Device
Mapping docs
to understand the implications of using these attributes.
The root_block_device mapping supports the following:
volume_type- (Optional) The type of volume. Can be"standard","gp2", or"io1". (Default:"standard").volume_size- (Optional) The size of the volume in gigabytes.iops- (Optional) The amount of provisioned IOPS. This must be set with avolume_typeof"io1".delete_on_termination- (Optional) Whether the volume should be destroyed on instance termination (Default:true).
Modifying any of the root_block_device settings requires resource
replacement.
Each ebs_block_device supports the following:
device_name- The name of the device to mount.snapshot_id- (Optional) The Snapshot ID to mount.volume_type- (Optional) The type of volume. Can be"standard","gp2", or"io1". (Default:"standard").volume_size- (Optional) The size of the volume in gigabytes.iops- (Optional) The amount of provisioned IOPS. This must be set with avolume_typeof"io1".delete_on_termination- (Optional) Whether the volume should be destroyed on instance termination (Default:true).encrypted- (Optional) Enables EBS encryption on the volume (Default:false). Cannot be used withsnapshot_id.
Modifying any ebs_block_device currently requires resource replacement.
Each ephemeral_block_device supports the following:
device_name- The name of the block device to mount on the instance.virtual_name- The Instance Store Device Name (e.g."ephemeral0")
Each AWS Instance type has a different set of Instance Store block devices
available for attachment. AWS publishes a
list
of which ephemeral devices are available on each type. The devices are always
identified by the virtual_name in the format "ephemeral{0..N}".
~> NOTE: Currently, changes to *_block_device configuration of existing
resources cannot be automatically detected by Terraform. After making updates
to block device configuration, resource recreation can be manually triggered by
using the taint command.
Attributes Reference
The following attributes are exported:
id- The instance ID.availability_zone- The availability zone of the instance.placement_group- The placement group of the instance.key_name- The key name of the instanceprivate_dns- The Private DNS name of the instanceprivate_ip- The private IP address.public_dns- The public DNS name of the instancepublic_ip- The public IP address.security_groups- The associated security groups.vpc_security_group_ids- The associated security groups in non-default VPCsubnet_id- The VPC subnet ID.