Error: Unknown post-processor type "ami-copy"

Viewed 131

I am using the packer plugin from https://github.com/martinbaillie/packer-plugin-ami-copy and followed the examples in that repository

 post-processor "ami-copy" {
    ami_users    = "${var.ami_users}"
    encrypt_boot = false
    role_name    = "AMICopyRole"
    // ... other settings.
  }

during the build I see that the plugin is installed

Installed plugin github.com/hashicorp/amazon v1.0.6 in "/root/.config/packer/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.6_x5.0_linux_amd64"
Installed plugin github.com/martinbaillie/ami-copy v1.8.0 in "/root/.config/packer/plugins/github.com/martinbaillie/ami-copy/packer-plugin-ami-copy_v1.8.0_x5.0_linux_amd64"

but later on I get the following error

Error: Unknown post-processor type "ami-copy"

  on images/ubuntu20-java-17/build.pkr.hcl line 75:
  (source code not available)

known post-processors: [shell-local docker-import manifest alicloud-import
googlecompute-import ucloud-import vsphere-template googlecompute-export vagrant
vagrant-cloud digitalocean-import vsphere checksum yandex-export docker-tag
yandex-import artifice docker-save amazon-import compress docker-push]

I have tried to find a solution to the issue but have had no luck.

I am using packer in docker and am running packer:full-1.7.82.0

Any help would be appreciated a LOT

here is the build.pkr.hcl file :


variable "ami_users" {
    type    = list(string)
    default = ["xxxxxxxxxx","xxxxxxxxxx","xxxxxxxxxx","xxxxxxxxxx"]
    description = "AMI Users"
    sensitive   = false
    
}
variable "name" {
    type        = string
    default     = "bmj-ubuntu20-java-17"
    description = "AMI Name"
    sensitive   = false

}



source "amazon-ebs" "ubuntu" {
  instance_type = "t2.micro"
  region        = "eu-west-1"
  source_ami_filter {
    filters = {
      name                = "ubuntu/images/*ubuntu-focal-20.04-amd64-server-*"
      root-device-type    = "ebs"
      virtualization-type = "hvm"
    }
    most_recent = true
    owners      = ["099720109477"]
  }
  ssh_username = "ubuntu"
  subnet_id = "subnet-xxxxxxxxxx"
  ssh_interface = "private_ip"
  ami_name = "${var.name}-{{timestamp}}"
  ami_description = "Ubuntu 20.04 Base AMI Image"
  ena_support = true
  ami_users = var.ami_users
  snapshot_users = ["xxxxxxxxxx","xxxxxxxxxx","xxxxxxxxxx","xxxxxxxxxx"]
  shutdown_behavior = "terminate"
  tags = {
      os_name = "Ubuntu"
      os_release = "20.04"
      base_ami_name = var.name
      name = var.name
      build = "base"
  }
}

build {
  name    = "bmj-packer"
  sources = [
    "source.amazon-ebs.ubuntu"
  ]

 provisioner "shell" {
    inline = ["sudo apt-get update -y && sudo apt-get install --no-install-recommends -y "] 
 }
 
 # install basics
 provisioner "ansible" {
     user = "ubuntu"
     playbook_file = "./common/focal/basics.yaml"
    }
 
 # install java
 provisioner "ansible" {
     user = "ubuntu"
     playbook_file = "./common/focal/java_17.yaml"
    }
  # setup users
 provisioner "ansible" {
     user = "ubuntu"
     playbook_file = "./common/focal/users_and_groups.yaml"
    }   
    # setup users
 provisioner "ansible" {
     user = "ubuntu"
     playbook_file = "./common/ssh_keys.yaml"
    }

   post-processor "ami-copy" {
     ami_users    = "${var.ami_users}"
     encrypt_boot = false
     role_name    = "AMICopyRole"
  }
  
     
}

Hope that makes it clearer.

0 Answers
Related