hashicorp / packer-plugin-amazon

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

common: validate capacity reservation options #483

Closed lbajolet-hashicorp closed 1 month ago

lbajolet-hashicorp commented 1 month ago

The capacity reservation options (ID, ARN, or Preference) are all mutually exclusive, only one of the three should be set in a given configuration.

The code wasn't enforcing this, leading to cases in which conflicts could be specified in the configuration, and the call to start the instance would then fail during build instead of before it starts.

This commit adds some logic to ensure that only valid options are accepted, and some tests are added to make sure these options cannot conflict.

Closes #473