martinbaillie / packer-plugin-ami-copy

Packer post-processor plugin for copying, encrypting, tagging a built AMI into other accounts.
Mozilla Public License 2.0
32 stars 21 forks source link

Unexpected EOF #17

Closed bantl23 closed 3 months ago

bantl23 commented 3 years ago

I'm sure I'm just not configured correctly but I'm trying to copy over tags. I'm getting the below error message when ami-copy is executed, it's a little cryptic so I'm not sure what is wrong. Any thoughts? Below is a redacted snip of the code.

Error Message:

==> amazon-ebs.proxy: Running post-processor:  (type ami-copy)
Build 'amazon-ebs.proxy' errored after 18 minutes 11 seconds: 1 error(s) occurred:

* Post-processor failed: unexpected EOF

==> Wait completed after 18 minutes 11 seconds

==> Some builds didn't complete successfully and had errors:
--> amazon-ebs.proxy: 1 error(s) occurred:

* Post-processor failed: unexpected EOF

==> Builds finished but no artifacts were created.

proxy.pkr.hcl:

packer {
  required_plugins {
    ami-copy = {
      version = ">=v1.7.0"
      source  = "github.com/martinbaillie/ami-copy"
    }
  }
}

variable "aws_access_key_id" {
  type    = string
  default = "${env("AWS_ACCESS_KEY_ID")}"
}

variable "aws_secret_access_key" {
  type    = string
  default = "${env("AWS_SECRET_ACCESS_KEY")}"
}

variable "aws_session_token" {
  type    = string
  default = "${env("AWS_SESSION_TOKEN")}"
}

variable "aws_ami_users" {
  default = <redacted>
}

variable "aws_ami_regions" {
  default = <redacted>
}

data "amazon-ami" "source" {
  access_key  = "${var.aws_access_key_id}"
  secret_key  = "${var.aws_secret_access_key}"
  token       = "${var.aws_session_token}"
  region      = <redacted>
  owners      = <redacted>
  filters = {
    architecture        = <redacted>
    name                = <redacted>
    root-device-type    = <redacted>
    virtualization-type = <redacted>
  }
  most_recent = true
}

source "amazon-ebs" "proxy" {
  access_key                  = "${var.aws_access_key_id}"
  secret_key                  = "${var.aws_secret_access_key}"
  token                       = "${var.aws_session_token}"
  region                      = <redacted>
  vpc_id                      = <redacted>
  subnet_id                   = <redacted>
  security_group_id           = <redacted>
  ami_name                    = "daphne-${var.type}-proxy ubuntu ${legacy_isotime("20060102T150405.999999999")}"
  ami_regions                 = "${var.aws_ami_regions}"
  ami_users                   = "${var.aws_ami_users}"
  source_ami                  = "${data.amazon-ami.source.id}"
  ssh_username                = <redacted>
  instance_type               = <redacted>
  associate_public_ip_address = true

  tags = {
    OS_Version      = <redacted>
    OperatingSystem = <redacted>
    Project         = <redacted>
    Usage           = <redacted>
    SourceAMI       = "{{ .SourceAMI }}"
  }

  run_tags = {
    OS_Version      = <redacted>
    OperatingSystem = <redacted>
    Project         = <redacted>
    Usage           = <redacted>
    SourceAMI       = "{{ .SourceAMI }}"
  }
}

build {
  sources = ["source.amazon-ebs.proxy"]

  post-processor "ami-copy" {
    ami_users    = "${var.aws_ami_users}"
  }
}
bantl23 commented 3 years ago

Also here is the packer version Packer v1.7.3