Windows AMI Fast Launch fails

Using the latest amazon-packer plugin with the following snippet

packer {
  required_plugins {
    packer-plugin-amazon = {
      version = "= 1.2.2"
      source = "github.com/hashicorp/amazon"
    }
  }
}
...
fast_launch {
    target_resource_count = 1
  }
...

I get the following error

Error enabling fast boot for AMI: retry count exhausted. Last err: InvalidRequest: Cannot enable faster launching. Run instances dry run failed for enabling faster launching.No default VPC for this user. GroupName is only supported for EC2-Classic and default VPC. To enable faster launching, a subnet ID or network interface ID is required in the launch template.

I do not know if it’s possible to set a launch_template inside a packer template.

Hi @lmayorga1980,

Looks like the docs are not generated correctly for the fast_launch block, but you can indeed reference a launch template to use with your instance.

There are 3 options here:

  • template_id
  • template_name
  • template_version

ID and name are mutually exclusive, so you should only specify one, and template_version is optional, and will default to the latest version of the launch template you’re referencing either by name or ID.

For example, the block should be something like this:

fast_launch {
    target_resource_count = 1
    template_id = "lt-1234567890abcde"
    template_version = 2 # optional, picks the latest version by default
}

Hope that helps!

Based on this info, does the launch_template need to have an AMI ID reference or just the AZs and non-default VPC.

Also it seems that LaunchTemplateData does not have any required fields based on the docs

I would presume you don’t need to specify the AMI ID, since the AMI will be created by Packer, so it won’t exist when creating the template in the first place.

As for the LaunchTemplateData you are referring to, from what I understand, this is for creating the launch template. Right now when enabling fast_launch for a Windows AMI, if you want to use a launch template, you will have to create it beforehand, and you can then reference it using the combination of options I shared earlier with you. We don’t support creating the launch template from a Packer build as of now.

Interesting, I use Packer with spot_instances for windows and it creates a temporal launch template for spot instances, I just capture that ID and did a run with it and is building. Not sure if the results would satisfy need need for fast_launch. I would just need to have a generic launch_template and just reference it but I wonder in this specific scenario there will be 2 launch_templates.