Home > database >  Hashicorp Packer source_ami_filter name Path
Hashicorp Packer source_ami_filter name Path

Time:09-01

I have been searching all over Google and other forums to find an answer for this. Can Hashicorp Packer support operating systems other than Ubuntu and Windows? I have been trying to get an .pkr.hcl working for an Amazon Linux 2 instance but, I can not find the path name in the source_ami_filter block.

The current source_ami_block:

source_ami_filter {
    filters = {
      # need a name path correction
      name                = "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*"
      root-device-type    = "ebs"
      virtualization-type = "hvm"
    }

What I am trying to find as information:

source_ami_filter {
    filters = {
      # need a name path correction
      name                = "<amazon-linux-2 image path here>"
      root-device-type    = "ebs"
      virtualization-type = "hvm"
    }

CodePudding user response:

You can check in the AWS AMI Marketplace, the operating system vendor's documentation, or various queries with the API or CLI to retrieve a list of AMI names. For Amazon Linux 2, the name generally follows the path /aws/service/ami-amazon-linux-latest/amzn*.

For your filter above, you can adjust like:

source_ami_filter {
  filters = {
    name                = "amzn2-ami-*"
    root-device-type    = "ebs"
    virtualization-type = "hvm"
  }
}

I would recommend using the Amazon Packer plugin's AMI data source instead of a source_filter though. It would be more robust and organized in your code.

  • Related