Provides an OpsWorks instance resource.
resource "aws_opsworks_instance" "my-instance" {
stack_id = aws_opsworks_stack.main.id
layer_ids = [
aws_opsworks_custom_layer.my-layer.id,
]
instance_type = "t2.micro"
os = "Amazon Linux 2015.09"
state = "stopped"
}
The following arguments are required:
layer_ids
- (Required) List of the layers the instance will belong to.stack_id
- (Required) Identifier of the stack the instance will belong to.The following arguments are optional:
agent_version
- (Optional) OpsWorks agent to install. Default is INHERIT
.ami_id
- (Optional) AMI to use for the instance. If an AMI is specified, os
must be Custom
.architecture
- (Optional) Machine architecture for created instances. Valid values are x86_64
or i386
. The default is x86_64
.auto_scaling_type
- (Optional) Creates load-based or time-based instances. Valid values are load
, timer
.availability_zone
- (Optional) Name of the availability zone where instances will be created by default.delete_ebs
- (Optional) Whether to delete EBS volume on deletion. Default is true
.delete_eip
- (Optional) Whether to delete the Elastic IP on deletion.ebs_block_device
- (Optional) Configuration block for additional EBS block devices to attach to the instance. See Block Devices below.ebs_optimized
- (Optional) Whether the launched EC2 instance will be EBS-optimized.ecs_cluster_arn
- (Optional) ECS cluster's ARN for container instances.elastic_ip
- (Optional) Instance Elastic IP address.ephemeral_block_device
- (Optional) Configuration block for ephemeral (also known as "Instance Store") volumes on the instance. See Block Devices below.hostname
- (Optional) Instance's host name.infrastructure_class
- (Optional) For registered instances, infrastructure class: ec2 or on-premises.install_updates_on_boot
- (Optional) Controls where to install OS and package updates when the instance boots. Default is true
.instance_profile_arn
- (Optional) ARN of the instance's IAM profile.instance_type
- (Optional) Type of instance to start.os
- (Optional) Name of operating system that will be installed.root_block_device
- (Optional) Configuration block for the root block device of the instance. See Block Devices below.root_device_type
- (Optional) Name of the type of root device instances will have by default. Valid values are ebs
or instance-store
.ssh_key_name
- (Optional) Name of the SSH keypair that instances will have by default.state
- (Optional) Desired state of the instance. Valid values are running
or stopped
.subnet_id
- (Optional) Subnet ID to attach to.tenancy
- (Optional) Instance tenancy to use. Valid values are default
, dedicated
or host
.virtualization_type
- (Optional) Keyword to choose what virtualization mode created instances will use. Valid values are paravirtual
or hvm
.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.
ebs_block_device
delete_on_termination
- (Optional) Whether the volume should be destroyed on instance termination. Default is true
.device_name
- (Required) Name of the device to mount.iops
- (Optional) Amount of provisioned IOPS. This must be set with a volume_type
of io1
.snapshot_id
- (Optional) Snapshot ID to mount.volume_size
- (Optional) Size of the volume in gigabytes.volume_type
- (Optional) Type of volume. Valid values are standard
, gp2
, or io1
. Default is standard
.Modifying any ebs_block_device
currently requires resource replacement.
ephemeral_block_device
device_name
- 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}
.
root_block_device
delete_on_termination
- (Optional) Whether the volume should be destroyed on instance termination. Default is true
.iops
- (Optional) Amount of provisioned IOPS. This must be set with a volume_type
of io1
.volume_size
- (Optional) Size of the volume in gigabytes.volume_type
- (Optional) Type of volume. Valid values are standard
, gp2
, or io1
. Default is standard
.Modifying any of the root_block_device
settings requires resource
replacement.
This resource exports the following attributes in addition to the arguments above:
created_at
- Time that the instance was created.ec2_instance_id
- EC2 instance ID.id
- ID of the OpsWorks instance.last_service_error_id
- ID of the last service error.platform
- Instance's platform.private_dns
- Private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC.private_ip
- Private IP address assigned to the instance.public_dns
- Public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC.public_ip
- Public IP address assigned to the instance, if applicable.registered_by
- For registered instances, who performed the registration.reported_agent_version
- Instance's reported AWS OpsWorks Stacks agent version.reported_os_family
- For registered instances, the reported operating system family.reported_os_name
- For registered instances, the reported operating system name.reported_os_version
- For registered instances, the reported operating system version.root_device_volume_id
- Root device volume ID.security_group_ids
- Associated security groups.ssh_host_dsa_key_fingerprint
- SSH key's Deep Security Agent (DSA) fingerprint.ssh_host_rsa_key_fingerprint
- SSH key's RSA fingerprint.status
- Instance status. Will be one of booting
, connection_lost
, online
, pending
, rebooting
, requested
, running_setup
, setup_failed
, shutting_down
, start_failed
, stop_failed
, stopped
, stopping
, terminated
, or terminating
.create
- (Default 10m
)delete
- (Default 10m
)update
- (Default 10m
)In Terraform v1.5.0 and later, use an import
block to import Opsworks Instances using the instance id
. For example:
import {
to = aws_opsworks_instance.my_instance
id = "4d6d1710-ded9-42a1-b08e-b043ad7af1e2"
}
Using terraform import
, import Opsworks Instances using the instance id
. For example:
% terraform import aws_opsworks_instance.my_instance 4d6d1710-ded9-42a1-b08e-b043ad7af1e2