Skip to content

feat: add capacity_reservation_market_type configuration option#645

Open
harrison-ahearn wants to merge 1 commit into
hashicorp:mainfrom
harrison-ahearn:feat/capacity-reservation-market-type
Open

feat: add capacity_reservation_market_type configuration option#645
harrison-ahearn wants to merge 1 commit into
hashicorp:mainfrom
harrison-ahearn:feat/capacity-reservation-market-type

Conversation

@harrison-ahearn

Copy link
Copy Markdown

Summary

  • Adds capacity_reservation_market_type configuration option to all AWS Packer builders
  • Enables support for interruptible capacity reservations and capacity blocks
  • Includes validation to ensure market type is only used with specific capacity reservation IDs or group ARNs

Changes

  • Added CapacityReservationMarketType field to RunConfig with validation
  • Updated StepRunSourceInstance to apply the market type via InstanceMarketOptions
  • Updated all builder types (ebs, ebssurrogate, ebsvolume, instance) to pass through the new field
  • Regenerated HCL2 spec files for all builders
  • Updated documentation with the new configuration option

Test plan

  • Verify configuration validation works correctly
  • Test with interruptible capacity reservations
  • Test with capacity blocks
  • Ensure backwards compatibility (empty value defaults to standard on-demand)

🤖 Generated with Claude Code

Add support for specifying market type when using EC2 capacity reservations.
This enables users to leverage interruptible capacity reservations and capacity
blocks by setting the capacity_reservation_market_type field.

Changes include:
- Add CapacityReservationMarketType field to RunConfig
- Add validation for market type values (interruptible-capacity-reservation, capacity-block)
- Update StepRunSourceInstance to apply market type to instance launch options
- Update all builder types (ebs, ebssurrogate, ebsvolume, instance) to pass through the new field
- Regenerate HCL2 spec files for all builders
- Update documentation with new configuration option

Co-Authored-By: Claude <noreply@anthropic.com>
@harrison-ahearn harrison-ahearn requested a review from a team as a code owner January 21, 2026 19:15
@hashicorp-cla-app

hashicorp-cla-app Bot commented Jan 21, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@hashicorp-cla-app

Copy link
Copy Markdown

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new capacity_reservation_market_type option to all AWS Packer builders so that users can target interruptible capacity reservations and capacity blocks when launching the source instance. The field is added to RunConfig, validated in Prepare, plumbed through each builder's StepRunSourceInstance, and surfaced via the regenerated HCL2 spec files and docs partials.

Changes:

  • New CapacityReservationMarketType field + validation in both common/run_config.go and builder/common/run_config.go.
  • StepRunSourceInstance (in both common packages) now sets InstanceMarketOptions when the market type is configured, with a defensive nil‑check on CapacityReservationSpecification.
  • All four builders (ebs, ebssurrogate, ebsvolume, instance) pass the new field through; HCL2 spec files and the two RunConfig docs partials are regenerated.

Reviewed changes

Copilot reviewed 10 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
common/run_config.go Adds field and validation (valid values + requires id/ARN).
common/step_run_source_instance.go Plumbs market type into InstanceMarketOptions (SDK v2).
builder/common/run_config.go Mirror of root validation for the legacy package.
builder/common/step_run_source_instance.go Mirror of step changes (SDK v1).
builder/ebs/builder.go, builder/ebssurrogate/builder.go, builder/ebsvolume/builder.go, builder/instance/builder.go Wire new config into StepRunSourceInstance.
builder/{ebs,ebssurrogate,ebsvolume,instance}/builder.hcl2spec.go Regenerated HCL2 specs.
docs-partials/common/RunConfig-not-required.mdx, docs-partials/builder/common/RunConfig-not-required.mdx Documents the new option.
Files not reviewed (4)
  • builder/ebs/builder.hcl2spec.go: Language not supported
  • builder/ebssurrogate/builder.hcl2spec.go: Language not supported
  • builder/ebsvolume/builder.hcl2spec.go: Language not supported
  • builder/instance/builder.hcl2spec.go: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread common/run_config.go
Comment on lines +921 to +933
// Validate capacity_reservation_market_type
if c.CapacityReservationMarketType != "" {
switch c.CapacityReservationMarketType {
case "interruptible-capacity-reservation", "capacity-block":
// Valid market types
default:
errs = append(errs, fmt.Errorf(`capacity_reservation_market_type only accepts 'interruptible-capacity-reservation' or 'capacity-block' values`))
}
// Market type should only be used with a specific capacity reservation
if c.CapacityReservationId == "" && c.CapacityReservationGroupArn == "" {
errs = append(errs, fmt.Errorf(`capacity_reservation_market_type requires either capacity_reservation_id or capacity_reservation_group_arn to be set`))
}
}
Comment thread common/run_config.go
Comment on lines +924 to +927
case "interruptible-capacity-reservation", "capacity-block":
// Valid market types
default:
errs = append(errs, fmt.Errorf(`capacity_reservation_market_type only accepts 'interruptible-capacity-reservation' or 'capacity-block' values`))

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 14 changed files in this pull request and generated 3 comments.

Files not reviewed (4)
  • builder/ebs/builder.hcl2spec.go: Language not supported
  • builder/ebssurrogate/builder.hcl2spec.go: Language not supported
  • builder/ebsvolume/builder.hcl2spec.go: Language not supported
  • builder/instance/builder.hcl2spec.go: Language not supported

Comment thread common/run_config.go
Comment on lines +924 to +927
case "interruptible-capacity-reservation", "capacity-block":
// Valid market types
default:
errs = append(errs, fmt.Errorf(`capacity_reservation_market_type only accepts 'interruptible-capacity-reservation' or 'capacity-block' values`))
Comment on lines +277 to +280
// Set market type if specified for interruptible capacity reservations or capacity blocks
if s.CapacityReservationMarketType != "" {
runOpts.InstanceMarketOptions = &ec2types.InstanceMarketOptionsRequest{
MarketType: ec2types.MarketType(s.CapacityReservationMarketType),
Comment thread common/run_config.go
}
// Market type should only be used with a specific capacity reservation
if c.CapacityReservationId == "" && c.CapacityReservationGroupArn == "" {
errs = append(errs, fmt.Errorf(`capacity_reservation_market_type requires either capacity_reservation_id or capacity_reservation_group_arn to be set`))
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.

2 participants