Skip to content

Lets EC2 choose the build AZ by default - #852

Merged
lorengordon merged 1 commit into
plus3it:masterfrom
lorengordon:fix/aws-associate-public-ip-var
Nov 18, 2026
Merged

lorengordon merged 1 commit into
plus3it:masterfrom
lorengordon:fix/aws-associate-public-ip-var

Conversation

@lorengordon

@lorengordon lorengordon commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

November's scheduled GovCloud builds failed with InsufficientInstanceCapacity for t3.2xlarge in us-gov-west-1a, even though the template never sets an AZ (example: https://github.com/plus3it/spel/actions/runs/44174033910/job/134360520763). Every failed job launched into the same subnet in that AZ.

Cause: we set associate_public_ip_address = true without a subnet_id. In that case the amazon plugin (v1.8.4, common/step_network_info.go, GetDefaultVPCAndSubnet) picks a subnet in the default VPC itself, always the one with the most free IPs. That subnet pins the AZ, so all builds go to one AZ, and max_retries just retries that same AZ.

Changes offered/proposed in this pull request:

  • Adds aws_associate_public_ip_address (bool, default null) and uses it for associate_public_ip_address in the amazon-ebssurrogate source. When null, Packer launches with no subnet and EC2 picks an AZ with capacity. The public IP comes from the default subnet's MapPublicIpOnLaunch, which is enabled in the commercial and GovCloud build accounts.
  • Uses the same variable in the amazon-ebs validation template under tests/, which also hard-coded true.
  • Documents the new input in spel/README.md.

Environments that must disable public IPs can set PKR_VAR_aws_associate_public_ip_address=false, typically together with aws_subnet_id.

Checked: packer fmt -check and packer validate pass for the AWS builds with the variable unset, false, and true.

  • New PR Alert to: @plus3it/spel

🤖 Generated with Claude Code

Setting associate_public_ip_address without a subnet_id makes the amazon
plugin infer a subnet in the default VPC, always choosing the subnet with
the most free IPs. That pins every build to one AZ, so an
InsufficientInstanceCapacity error in that AZ fails every build, and the
retries keep trying the same AZ.

Exposes the setting as aws_associate_public_ip_address, defaulting to null.
When null, Packer launches without a subnet and EC2 places the instance in
an AZ with capacity, using the default subnet's MapPublicIpOnLaunch to assign
the public IP. Environments that must disable (or force) public IPs can still
set the variable explicitly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lorengordon
lorengordon force-pushed the fix/aws-associate-public-ip-var branch from 9051201 to 823c4b7 Compare November 17, 2026 23:34
@lorengordon
lorengordon marked this pull request as ready for review November 17, 2026 23:34

@lorengordon lorengordon left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

/build

@mergify

mergify Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@lorengordon
lorengordon requested a review from a team November 18, 2026 14:41
@lorengordon
lorengordon merged commit 7218e3c into plus3it:master Nov 18, 2026
30 checks passed
@lorengordon
lorengordon deleted the fix/aws-associate-public-ip-var branch November 18, 2026 15:38
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