2.1 KiB
2.1 KiB
layout | page_title | sidebar_current |
---|---|---|
aws | AWS: aws_instance | docs-aws-resource-instance |
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
resource "aws_instance" "web" {
ami = "ami-1234"
instance_type = "m1.small"
}
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.ebs_optimized
- (Optional) If true, the launched EC2 instance will be EBS-optimized.instance_type
- (Required) The type of instance to startkey_name
- (Optional) The key name to use for the instance.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.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.
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 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.subnet_id
- The VPC subnet ID.