This page demonstrates how to create an Ocean ECS Custom Launch Specification resource using the Spotinst Terraform plugin.

This post assumes that you already have a Spotinst account and went through Spotinst Terraform Installation & Configuration

Example Usage – Ocean ECS Launch Specification
resource "spotinst_ocean_ecs_launch_spec" "example" {
  ocean_id  = "o-123456"
  name      = "customLaunchSpec"
  image_id  = "ami-123456"
  user_data = "echo hello world"
  iam_instance_profile = "iam-profile"
  security_group_ids = ["awseb-12345"]
  
  attributes {
    key   = "fakeKey"
    value = "fakeValue"
  }

  autoscale_headrooms {
    num_of_units = 5
    cpu_per_unit = 1000
    memory_per_unit = 2048
  }
}

 

Argument Reference

Parameter Type Description
ocean_id * String

The Ocean cluster ID.

Example: o-123456
name * String

The Ocean Launch Specification name.

Example: customLaunchSpec
image_id String

ID of the image used to launch the instances.

user_data String

Base64-encoded MIME user data to make available to the instances.

Example: echo hello world
iam_instance_profile String

The ARN or name of an IAM instance profile to associate with launched instances.

Example: iam-profile
security_group_ids Array<String>

One or more security group IDs.

Example: ["sg-12345"]
attributes Object

Optionally adds labels to instances launched in an Ocean cluster.

attributes.key * String

The label key.

Example: fakeKey
attributes.value * String

The label value.

Example: fakeValue
autoscale_headrooms Object

Set custom headroom per launch spec. provide list of headrooms object.

autoscale_headrooms.num_of_units * Integer

The number of units to retain as headroom, where each unit has the defined headroom CPU and memory.

autoscale_headrooms.cpu_per_unit Integer

Optionally configure the number of CPUs to allocate for each headroom unit. CPUs are denoted in CPU units, where 1024 units = 1 vCPU.

autoscale_headrooms.memory_per_unit Integer

Optionally configure the amount of memory (MiB) to allocate for each headroom unit.