Skip to content

Skip EBS AMI preparation when no image is created#681

Open
FocalChord wants to merge 1 commit into
hashicorp:mainfrom
FocalChord:skip-create-ami-skip-source-stop
Open

Skip EBS AMI preparation when no image is created#681
FocalChord wants to merge 1 commit into
hashicorp:mainfrom
FocalChord:skip-create-ami-skip-source-stop

Conversation

@FocalChord

@FocalChord FocalChord commented Jun 15, 2026

Copy link
Copy Markdown

Description

This changes the Amazon EBS builder so skip_create_ami = true also reaches the source instance AMI preparation steps.

Today those steps can still stop the source instance and modify source instance attributes before the create image step observes skip_create_ami. For no image builds, I think those steps are AMI preparation work and can be skipped.

The patch passes skip_create_ami into:

  1. StepStopEBSBackedInstance
  2. StepModifyEBSBackedInstance

This PR intentionally does not change the final source instance termination wait. That behavior is a separate cleanup concern and can be discussed independently.

Resolved Issues

Closes #680

Evidence

I tested this with no image Amazon EBS runs that collect outputs before cleanup.

  1. Full no image EBS run on c5.metal with Amazon plugin 1.8.1
    The source instance stop wait took about 19m16s.

  2. Local patch that skips source stop and source attribute preparation
    Packer logged that source instance stop was skipped when skip_create_ami = true.

  3. The remaining cleanup wait moved to final termination, which is why this PR avoids addressing that separate behavior.

Validation

  1. go test ./builder/common ./common ./builder/ebs
  2. Git whitespace check on the amended commit

Rollback Plan

Revert this change.

Changes to Security Controls

No. This does not change access controls, encryption, or logging.

@FocalChord FocalChord requested a review from a team as a code owner June 15, 2026 04:37
@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

This PR updates the Amazon EBS builder workflow so that when skip_create_ami is enabled, AMI-preparation steps (stopping the source instance and modifying source instance attributes) are skipped instead of running before AMI creation is bypassed.

Changes:

  • Plumbs AMISkipCreateImage into the EBS builder’s source-instance stop and attribute-modification steps.
  • Adds early-exit behavior in the stop/modify steps to skip work when skip_create_ami is set.
  • Adds unit tests covering the new early-exit behavior for both SDK v2 (common/) and SDK v1 (builder/common/) step implementations.

Reviewed changes

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

Show a summary per file
File Description
common/step_stop_ebs_instance.go Skips stopping the source instance when AMISkipCreateImage is true.
common/step_stop_ebs_instance_test.go Adds a test ensuring stop is skipped when skip_create_ami is set.
common/step_modify_ebs_instance.go Skips source instance attribute modification when AMISkipCreateImage is true.
common/step_modify_ebs_instance_test.go Adds a test ensuring modification is skipped when skip_create_ami is set.
builder/ebs/builder.go Passes AMISkipCreateImage into the stop/modify steps in the EBS builder step chain.
builder/common/step_stop_ebs_instance.go Mirrors skip behavior for the SDK v1 step implementation.
builder/common/step_stop_ebs_instance_test.go Adds a test ensuring stop is skipped (SDK v1 implementation).
builder/common/step_modify_ebs_instance.go Mirrors skip behavior for the SDK v1 modification step.
builder/common/step_modify_ebs_instance_test.go Adds a test ensuring modification is skipped (SDK v1 implementation).

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

Comment thread common/step_stop_ebs_instance_test.go Outdated
Comment thread builder/common/step_stop_ebs_instance_test.go Outdated
@FocalChord FocalChord changed the title Skip AMI preparation when image creation is disabled Reduce cleanup waits for no-AMI EBS builds Jun 15, 2026
@FocalChord FocalChord force-pushed the skip-create-ami-skip-source-stop branch 2 times, most recently from 617d89c to 30a79ad Compare June 15, 2026 07:38
@FocalChord FocalChord force-pushed the skip-create-ami-skip-source-stop branch from 30a79ad to 207d5b5 Compare June 15, 2026 07:53
@FocalChord FocalChord changed the title Reduce cleanup waits for no-AMI EBS builds Skip EBS AMI preparation when no image is created Jun 15, 2026
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.

EBS builds with skip_create_ami still run AMI preparation steps

3 participants