Skip to content

Resource: awsOpsworksInstance

Provides an OpsWorks instance resource.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.opsworksInstance.OpsworksInstance(this, "my-instance", {
  instanceType: "t2.micro",
  layerIds: ["${aws_opsworks_custom_layer.my-layer.id}"],
  os: "Amazon Linux 2015.09",
  stackId: "${aws_opsworks_stack.main.id}",
  state: "stopped",
});

Argument Reference

The following arguments are required:

  • layerIds - (Required) List of the layers the instance will belong to.
  • stackId - (Required) Identifier of the stack the instance will belong to.

The following arguments are optional:

  • agentVersion - (Optional) OpsWorks agent to install. Default is inherit.
  • amiId - (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 x8664 or i386. The default is x8664.
  • autoScalingType - (Optional) Creates load-based or time-based instances. Valid values are load, timer.
  • availabilityZone - (Optional) Name of the availability zone where instances will be created by default.
  • deleteEbs - (Optional) Whether to delete EBS volume on deletion. Default is true.
  • deleteEip - (Optional) Whether to delete the Elastic IP on deletion.
  • ebsBlockDevice - (Optional) Configuration block for additional EBS block devices to attach to the instance. See Block Devices below.
  • ebsOptimized - (Optional) Whether the launched EC2 instance will be EBS-optimized.
  • ecsClusterArn - (Optional) ECS cluster's ARN for container instances.
  • elasticIp - (Optional) Instance Elastic IP address.
  • ephemeralBlockDevice - (Optional) Configuration block for ephemeral (also known as "Instance Store") volumes on the instance. See Block Devices below.
  • hostname - (Optional) Instance's host name.
  • infrastructureClass - (Optional) For registered instances, infrastructure class: ec2 or on-premises.
  • installUpdatesOnBoot - (Optional) Controls where to install OS and package updates when the instance boots. Default is true.
  • instanceProfileArn - (Optional) ARN of the instance's IAM profile.
  • instanceType - (Optional) Type of instance to start.
  • os - (Optional) Name of operating system that will be installed.
  • rootBlockDevice - (Optional) Configuration block for the root block device of the instance. See Block Devices below.
  • rootDeviceType - (Optional) Name of the type of root device instances will have by default. Valid values are ebs or instanceStore.
  • sshKeyName - (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.
  • subnetId - (Optional) Subnet ID to attach to.
  • tenancy - (Optional) Instance tenancy to use. Valid values are default, dedicated or host.
  • virtualizationType - (Optional) Keyword to choose what virtualization mode created instances will use. Valid values are paravirtual or hvm.

Block devices

Each of the *BlockDevice 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.

ebsBlockDevice

  • deleteOnTermination - (Optional) Whether the volume should be destroyed on instance termination. Default is true.
  • deviceName - (Required) Name of the device to mount.
  • iops - (Optional) Amount of provisioned IOPS. This must be set with a volumeType of io1.
  • snapshotId - (Optional) Snapshot ID to mount.
  • volumeSize - (Optional) Size of the volume in gigabytes.
  • volumeType - (Optional) Type of volume. Valid values are standard, gp2, or io1. Default is standard.

Modifying any ebsBlockDevice currently requires resource replacement.

ephemeralBlockDevice

  • deviceName - Name of the block device to mount on the instance.
  • virtualName - 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 virtualName in the format ephemeral{0N}.

rootBlockDevice

  • deleteOnTermination - (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 volumeType of io1.
  • volumeSize - (Optional) Size of the volume in gigabytes.
  • volumeType - (Optional) Type of volume. Valid values are standard, gp2, or io1. Default is standard.

Modifying any of the rootBlockDevice settings requires resource replacement.

\~> NOTE: Currently, changes to *BlockDevice 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

In addition to all arguments above, the following attributes are exported:

  • createdAt - Time that the instance was created.
  • ec2InstanceId - EC2 instance ID.
  • id - ID of the OpsWorks instance.
  • lastServiceErrorId - ID of the last service error.
  • platform - Instance's platform.
  • privateDns - 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.
  • privateIp - Private IP address assigned to the instance.
  • publicDns - Public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC.
  • publicIp - Public IP address assigned to the instance, if applicable.
  • registeredBy - For registered instances, who performed the registration.
  • reportedAgentVersion - Instance's reported AWS OpsWorks Stacks agent version.
  • reportedOsFamily - For registered instances, the reported operating system family.
  • reportedOsName - For registered instances, the reported operating system name.
  • reportedOsVersion - For registered instances, the reported operating system version.
  • rootDeviceVolumeId - Root device volume ID.
  • securityGroupIds - Associated security groups.
  • sshHostDsaKeyFingerprint - SSH key's Deep Security Agent (DSA) fingerprint.
  • sshHostRsaKeyFingerprint - SSH key's RSA fingerprint.
  • status - Instance status. Will be one of booting, connectionLost, online, pending, rebooting, requested, runningSetup, setupFailed, shuttingDown, startFailed, stopFailed, stopped, stopping, terminated, or terminating.

Timeouts

Configuration options:

  • create - (Default 10M)
  • delete - (Default 10M)
  • update - (Default 10M)

Import

Opsworks Instances can be imported using the instanceId, e.g.,

$ terraform import aws_opsworks_instance.my_instance 4d6d1710-ded9-42a1-b08e-b043ad7af1e2