Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
88e07c6
feat(aws-ec2-instance-type): add AWS EC2 instance type parameter module
phorcys420 Sep 21, 2026
0563dbd
refactor(aws-ec2-instance-type): store instance catalog in instance-t…
phorcys420 Sep 21, 2026
16c9763
feat(aws-ec2-instance-type): expose instances output with architectur…
phorcys420 Sep 21, 2026
3c92a70
refactor(aws-ec2-instance-type): drop redundant attr arch field
phorcys420 Sep 21, 2026
f9bd1d6
refactor(aws-ec2-instance-type): use raw spec fields (vcpus, memory_m…
phorcys420 Sep 21, 2026
ead39a5
refactor(aws-ec2-instance-type): store AWS-only specs, derive categor…
phorcys420 Sep 21, 2026
903b60a
test(aws-ec2-instance-type): remove terraform native tests
phorcys420 Sep 21, 2026
ec470be
feat(aws-ec2-instance-type): add create_parameter toggle to disable t…
phorcys420 Sep 21, 2026
a6f4006
Merge branch 'main' into phorcys/aws-ec2-instance-type
phorcys420 Sep 23, 2026
ebde90b
test(aws-ec2-instance-type): add terraform native tests covering the …
phorcys420 Sep 28, 2026
0d4bcc3
Merge branch 'main' into phorcys/aws-ec2-instance-type
phorcys420 Sep 28, 2026
f0fcf89
feat(aws-ec2-instance-type): add instance-types.json regeneration script
phorcys420 Sep 28, 2026
bd8595a
fix(aws-ec2-instance-type): keep the parameter a picker under dynamic…
phorcys420 Sep 28, 2026
a4bc3f3
feat(aws-ec2-instance-type): label options by specs and filter by family
phorcys420 Sep 28, 2026
3dd4425
refactor(aws-ec2-instance-type): drop unused instance category deriva…
phorcys420 Sep 28, 2026
ffdaadc
refactor(aws-ec2-instance-type): enumerate instance sizes from AWS
phorcys420 Sep 28, 2026
8a060de
Merge branch 'main' into phorcys/aws-ec2-instance-type
phorcys420 Sep 28, 2026
1d8eaef
feat(aws-ec2-instance-type): rename catalog fields, merge custom_meta…
phorcys420 Sep 28, 2026
c2e64ac
fix(aws-ec2-instance-type): index count example and validate include
phorcys420 Sep 28, 2026
0532c5f
docs(aws-ec2-instance-type): add parameter preview image
phorcys420 Sep 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added registry/coder/.images/aws-ec2-instance-type.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions registry/coder/modules/aws-ec2-instance-type/.scripts/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash

# Regenerates instance-types.json from the AWS EC2 API. Edit the families list
# below, then run this script and commit the result. Sizes within each family
# are enumerated from AWS, so a newly released size is picked up automatically.
#
# Requires the AWS CLI with credentials allowed to call
# ec2:DescribeInstanceTypes. Override the query region with AWS_REGION
# (default us-east-1, which offers every family in the list).

set -euo pipefail

script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
output_file="$script_dir/../instance-types.json"
region="${AWS_REGION:-us-east-1}"

# Instance families to offer. general: t3/t4g/m5/m7g, compute: c5, memory: r5,
# storage: i3, gpu: g4dn.
families=(t3 t4g m5 m7g c5 r5 i3 g4dn)

if ! command -v aws > /dev/null 2>&1; then
echo "error: aws CLI not found; install and configure it first" >&2
exit 1
fi

# Turn the families into an instance-type wildcard filter, e.g. "t3.*,m5.*".
family_filter=""
for family in "${families[@]}"; do
family_filter="${family_filter:+$family_filter,}$family.*"
done

tmp="$(mktemp)"
trap 'rm -f "$tmp"' EXIT

# bare-metal=false keeps the catalog to virtualized sizes; .metal instances are
# not sensible workspace defaults. The AWS CLI paginates automatically.
aws ec2 describe-instance-types \
--region "$region" \
--filters "Name=instance-type,Values=${family_filter}" "Name=bare-metal,Values=false" \
--output json \
--query 'sort_by(InstanceTypes, &MemoryInfo.SizeInMiB)[].{type: InstanceType, vcpus: VCpuInfo.DefaultVCpus, memory_mib: MemoryInfo.SizeInMiB, gpus: (GpuInfo.Gpus[0].Count || `0`), arch: ProcessorInfo.SupportedArchitectures[-1]}' \
> "$tmp"

mv "$tmp" "$output_file"

# AWS CLI emits 4-space JSON; match the repo's prettier formatting.
if command -v bun > /dev/null 2>&1; then
bun x prettier --write "$output_file" > /dev/null
else
echo "note: bun not found; run 'bun run fmt' before committing $output_file" >&2
fi

echo "Updated $output_file"
121 changes: 121 additions & 0 deletions registry/coder/modules/aws-ec2-instance-type/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
display_name: AWS EC2 Instance Type
description: A parameter with human readable AWS EC2 instance type names
icon: ../../../../.icons/aws.svg
verified: false
tags: [helper, parameter, instances, aws]
---

# AWS EC2 Instance Type

A parameter with common AWS EC2 instance types, filtered by instance family.
Each option is labeled with its vCPU, RAM, and architecture so developers can
select the machine that best fits their workspace.

```tf
module "aws_ec2_instance_type" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/aws-ec2-instance-type/coder"
version = "1.0.0"
default = "t3.micro"
}

resource "aws_instance" "dev" {
instance_type = module.aws_ec2_instance_type[0].value
# ...
}
```

![AWS EC2 Instance Type parameter](../../.images/aws-ec2-instance-type.png)

## Examples

### Choose instance families

By default only the `t3` family is offered. Pass `include` to expose more
families and preselect one:

```tf
module "aws_ec2_instance_type" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/aws-ec2-instance-type/coder"
version = "1.0.0"
include = ["t3", "m5", "c5"]
default = "m5.large"
}
```

The bundled catalog covers the `t3`, `t4g`, `m5`, `m7g`, `c5`, `r5`, `i3`, and
`g4dn` families.

### Customize labels and tooltips

Each option is labeled with its specs and architecture (for example
`2 vCPU, 4 GiB RAM (amd64)`) and shows the instance type as a tooltip. Override
either per instance type:

```tf
module "aws_ec2_instance_type" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/aws-ec2-instance-type/coder"
version = "1.0.0"
default = "t3.medium"

custom_metadata = {
"t3.medium" = {
name = "Standard workspace"
description = "Recommended default"
}
}
}
```

### Architecture-aware provisioning

The `instances` output maps every instance type ID to its metadata, including architecture fields. Look up the selected value to configure the agent and pick a matching AMI:

```tf
module "aws_ec2_instance_type" {
source = "registry.coder.com/coder/aws-ec2-instance-type/coder"
version = "1.0.0"
}

locals {
selected = module.aws_ec2_instance_type.instances[module.aws_ec2_instance_type.value]
}

resource "coder_agent" "dev" {
arch = local.selected.coder_arch # amd64 or arm64
os = "linux"
}

data "aws_ami" "workspace" {
most_recent = true
owners = ["amazon"]

filter {
name = "architecture"
values = [local.selected.arch] # x86_64 or arm64
}
}
```

### Use the catalog without a parameter

Set `create_parameter = false` to skip the picker (for example when the template pins the size) while still using the `instances` catalog:

```tf
module "aws_ec2_instance_type" {
source = "registry.coder.com/coder/aws-ec2-instance-type/coder"
version = "1.0.0"
create_parameter = false
default = "t4g.large"
}
```

## Related templates

For a complete AWS EC2 template, see the following examples in the [Coder Registry](https://registry.coder.com/).

- [AWS EC2 (Linux)](https://registry.coder.com/templates/aws-linux)
- [AWS EC2 (Windows)](https://registry.coder.com/templates/aws-windows)
Loading
Loading