hashicorp / packer-plugin-amazon

Packer plugin for Amazon AMI Builder
https://www.packer.io/docs/builders/amazon
Mozilla Public License 2.0
76 stars 112 forks source link

Select subnet based on az machine type availability #373

Closed lbajolet-hashicorp closed 1 year ago

lbajolet-hashicorp commented 1 year ago

This PR is an attempt to fix the problem where we pick a subnet that cannot spawn an instance of the type requested as the AZ linked to the subnet does not support it.

We also add some basic unit-tests for the step, which will be improved upon in upcoming PRs.

Related to #368 Related to #371

lbajolet-hashicorp commented 1 year ago

Does the call to describeInstnaceOfferings require a different set of permissions?

I'm not completely sure, but it may require the ec2:DescribeInstanceTypeOfferings action to be allowed for the account indeed. We could amend the code so that if the call fails because of a missing permission, we still attempt to pick a subnet, without checking for the capability to host the type of instance requested, along with a warning that we may pick a subnet that can't support it without having this capability.

lbajolet-hashicorp commented 1 year ago

Had verbal confirmation that Wilken was OK with the current state of the PR, so I'm merging this as-is.