Skip to content

Conversation

@jdrowne
Copy link

@jdrowne jdrowne commented Jan 11, 2026

Description

Add a new subnet_ids parameter that allows users to specify multiple subnets for spot instances. When used with spot_instance_types, EC2 Fleet receives overrides for all instance type × subnet combinations, enabling automatic failover when capacity is constrained.

Example configuration:

source "amazon-ebs" "example" {
  spot_price          = "auto"
  spot_instance_types = ["m6i.large", "m5.large", "m6a.large"]
  subnet_ids          = ["subnet-abc123", "subnet-def456", "subnet-ghi789"]
}

This gives EC2 Fleet 9 placement options (3 instance types × 3 subnets) to choose from.

How it works:

  • When subnet_ids is set, the launch template omits Placement/subnet
  • Fleet overrides include the Cartesian product of instance types × subnets
  • EC2 Fleet selects an available combination at launch time
  • Existing subnet_id and subnet_filter behavior is unchanged

Resolved Issues

Closes #425

Rollback Plan

This change is additive and backward compatible. To rollback, revert the commit. Existing configurations using subnet_id or subnet_filter are unaffected.

Changes to Security Controls

No changes to security controls (access controls, encryption, logging).

Add a new `subnet_ids` parameter that allows users to specify multiple
subnets across different availability zones for spot instances. EC2 Fleet
will receive overrides for all instance type × subnet combinations,
enabling automatic failover when capacity is constrained in a particular AZ.

This addresses GitHub issue hashicorp#425 where spot instance builds fail when
a single AZ lacks capacity, with no retry mechanism to try other AZs.

When using `subnet_ids`:
- EC2 Fleet receives instance_type × subnet Cartesian product as overrides
- Launch template omits Placement/subnet (determined by Fleet)
- Fleet automatically selects available instance type + subnet combination

The existing `subnet_id` and `subnet_filter` behavior is unchanged.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@jdrowne jdrowne requested a review from a team as a code owner January 11, 2026 17:22
@hashicorp-cla-app
Copy link

hashicorp-cla-app bot commented Jan 11, 2026

CLA assistant check
All committers have signed the CLA.

@hashicorp-cla-app
Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

@jdrowne jdrowne marked this pull request as draft January 11, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When using the most_free subnet filter, stuck in the same subnet/availability zone even if spot capacity request fails.

1 participant