Giter Club home page Giter Club logo

Comments (11)

vishalbasra avatar vishalbasra commented on September 23, 2024

I also started a discussion here https://discuss.hashicorp.com/t/plugin-nomenclature-change/21887

from packer-plugin-ami-copy.

vishalbasra avatar vishalbasra commented on September 23, 2024

nevermnid, this is related to packer changing how they name plugins, I circumvented around this by using packer 1.6.6 and moving the binary in my working directory and referring the plugin directly

from packer-plugin-ami-copy.

martinbaillie avatar martinbaillie commented on September 23, 2024

from packer-plugin-ami-copy.

martinbaillie avatar martinbaillie commented on September 23, 2024

Please give https://github.com/martinbaillie/packer-plugin-ami-copy/releases/tag/v1.7.0 a shot. I've refactored the project to align to Hashicorp's latest plugin architecture but I don't use this anymore so can't easily test myself.

from packer-plugin-ami-copy.

vishalbasra avatar vishalbasra commented on September 23, 2024

hey, much thanks for trying tio fix this!
unfortunately I haven't been able to test this out myself bc of a different issue w packer 1.7 related to environment variables ( https://discuss.hashicorp.com/t/hcl2-environment-variables-followup/21886 )
as soon as I'm able to get past, I'm gonna test this out and let you know!
Again much much thanks!

from packer-plugin-ami-copy.

vishalbasra avatar vishalbasra commented on September 23, 2024

Hey @martinbaillie , so I attempted and ran into this

==> amazon-ebs.windows-base-image: Running post-processor:  (type ami-copy)
2021/03/25 15:50:20 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: 2021/03/25 15:50:20 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2021/03/25 15:50:20 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: 2021/03/25 15:50:20 Found region us-east-1
2021/03/25 15:50:20 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: 2021/03/25 15:50:20 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
Build 'amazon-ebs.windows-base-image' errored after 10 minutes 45 seconds: 1 error(s) occurred:

* Post-processor failed: unexpected EOF

==> Wait completed after 10 minutes 45 seconds

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

* Post-processor failed: unexpected EOF

==> Builds finished but no artifacts were created.
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: panic: runtime error: invalid memory address or nil pointer dereference
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1beedfc]
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: 
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: goroutine 98 [running]:
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: main.(*PostProcessor).PostProcess(0xc0005f8400, 0x21c48a8, 0xc0003e2940, 0x21c8d88, 0xc0005e3470, 0x21c8dd0, 0xc000555320, 0xc0000be214, 0x203000, 0xc00030c070, ...)
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: 	github.com/martinbaillie/packer-plugin-ami-copy/post-processor.go:182 +0x9dc
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: github.com/hashicorp/packer-plugin-sdk/rpc.(*PostProcessorServer).PostProcess(0xc00030e040, 0x1, 0xc00047d2b0, 0x0, 0x0)
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: 	github.com/hashicorp/[email protected]/rpc/post_processor.go:108 +0x19a
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: reflect.Value.call(0xc00007c2a0, 0xc00000e088, 0x13, 0x1f97fc7, 0x4, 0xc0000a3f08, 0x3, 0x3, 0xc00004c000, 0xc0000106f8, ...)
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: 	reflect/value.go:476 +0x8e7
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: reflect.Value.Call(0xc00007c2a0, 0xc00000e088, 0x13, 0xc000010708, 0x3, 0x3, 0xc000001638, 0xc0000c51f0, 0x1061ae0)
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: 	reflect/value.go:337 +0xb9
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: net/rpc.(*service).call(0xc00030e0c0, 0xc00009c0f0, 0xc0002900a8, 0xc0002900b0, 0xc000134200, 0xc00029e0a0, 0x1ccd1a0, 0xc00030d7c8, 0x18a, 0x1c8c8a0, ...)
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: 	net/rpc/server.go:377 +0x189
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: created by net/rpc.(*Server).ServeCodec
2021/03/25 15:50:21 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: 	net/rpc/server.go:474 +0x44d
2021/03/25 15:50:21 [INFO] (telemetry) ending ami-copy

* Post-processor failed: unexpected EOF
==> Wait completed after 10 minutes 45 seconds
2021/03/25 15:50:21 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2021/03/25 15:50:21 machine readable: amazon-ebs.windows-base-image,error []string{"1 error(s) occurred:\n\n* Post-processor failed: unexpected EOF"}

* Post-processor failed: unexpected EOF
==> Builds finished but no artifacts were created.
2021/03/25 15:50:21 [INFO] (telemetry) Finalizing.
2021/03/25 15:50:21 /Users/v.basra/.packer.d/plugins/github.com/martinbaillie/ami-copy/packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64: plugin process exited
2021/03/25 15:50:23 waiting for all plugin processes to complete...
2021/03/25 15:50:23 /usr/local/bin/packer: plugin process exited
2021/03/25 15:50:23 /usr/local/bin/packer: plugin process exited
2021/03/25 15:50:23 /usr/local/bin/packer: plugin process exited
2021/03/25 15:50:23 /usr/local/bin/packer: plugin process exited

I'm not versed w go enough to understand what this is, does this tell you if something obvious is wrong here?

from packer-plugin-ami-copy.

vishalbasra avatar vishalbasra commented on September 23, 2024

So I went over your code and nothing was obvious but the error was coming in from https://github.com/vishalbasra/packer-plugin-ami-copy/blob/master/post-processor.go#L182 and I added
encrypt_boot = false and it works now - I think this may be an accidental required parameter?
alas the ami was copied but without tags
a snippet from the running build :

==> amazon-ebs.windows-base-image: Adding tags to AMI (ami-BLA)...
==> amazon-ebs.windows-base-image: Tagging snapshot: snap-BLABLA
==> amazon-ebs.windows-base-image: Creating AMI tags
    amazon-ebs.windows-base-image: Adding tag: "created-by": "vishal"
    amazon-ebs.windows-base-image: Adding tag: "created-on": "20210325160606"
    amazon-ebs.windows-base-image: Adding tag: "type": "dummy-test"
==> amazon-ebs.windows-base-image: Creating snapshot tags
==> amazon-ebs.windows-base-image: Terminating the source AWS instance...
==> amazon-ebs.windows-base-image: Cleaning up any extra volumes...
==> amazon-ebs.windows-base-image: No volumes to clean up, skipping
==> amazon-ebs.windows-base-image: Deleting temporary keypair...
2021/03/25 21:41:29 [INFO] (telemetry) ending 
2021/03/25 21:41:29 [INFO] (telemetry) Starting post-processor manifest
==> amazon-ebs.windows-base-image: Running post-processor:  (type manifest)
2021/03/25 21:41:29 [INFO] (telemetry) ending manifest
2021/03/25 21:41:29 Flagging to keep original artifact from post-processor 'manifest'
2021/03/25 21:41:29 [INFO] (telemetry) Starting post-processor ami-copy
==> amazon-ebs.windows-base-image: Running post-processor:  (type ami-copy)
2021/03/25 21:41:30 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: 2021/03/25 21:41:30 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2021/03/25 21:41:30 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: 2021/03/25 21:41:30 Found region us-east-1
2021/03/25 21:41:30 packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64 plugin: 2021/03/25 21:41:30 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
==> amazon-ebs.windows-base-image (ami-copy): [us-east-1] Copying ami-BLA to account FOO (encrypted: false)
==> amazon-ebs.windows-base-image (ami-copy): [us-east-1] Copying ami-BLA to account BAR (encrypted: false)
==> amazon-ebs.windows-base-image (ami-copy): Going to wait for image to be in available state
==> amazon-ebs.windows-base-image (ami-copy): Going to wait for image to be in available state
==> amazon-ebs.windows-base-image (ami-copy): Waiting one minute (1/30) for AMI to become available, current state: pending for image ami-009f357260ae1d076 on account BAR
==> amazon-ebs.windows-base-image (ami-copy): Waiting one minute (1/30) for AMI to become available, current state: pending for image ami-BLA on account FOO
==> amazon-ebs.windows-base-image (ami-copy): Waiting one minute (2/30) for AMI to become available, current state: pending for image ami-009f357260ae1d076 on account BAR
==> amazon-ebs.windows-base-image (ami-copy): Waiting one minute (2/30) for AMI to become available, current state: pending for image ami-BLA on account FOO
==> amazon-ebs.windows-base-image (ami-copy): Waiting one minute (3/30) for AMI to become available, current state: pending for image ami-009f357260ae1d076 on account BAR
==> amazon-ebs.windows-base-image (ami-copy): Waiting one minute (3/30) for AMI to become available, current state: pending for image ami-BLA on account FOO
==> amazon-ebs.windows-base-image (ami-copy): Waiting one minute (4/30) for AMI to become available, current state: pending for image ami-BLA on account FOO
==> amazon-ebs.windows-base-image (ami-copy): Waiting one minute (4/30) for AMI to become available, current state: pending for image ami-009f357260ae1d076 on account BAR
==> amazon-ebs.windows-base-image (ami-copy): Waiting one minute (5/30) for AMI to become available, current state: pending for image ami-BLA on account FOO
==> amazon-ebs.windows-base-image (ami-copy): Waiting one minute (5/30) for AMI to become available, current state: pending for image ami-009f357260ae1d076 on account BAR
==> amazon-ebs.windows-base-image (ami-copy): [us-east-1] Finished copying ami-BLA to BAR (copied id: ami-009f357260ae1d076)
==> amazon-ebs.windows-base-image (ami-copy): [us-east-1] Finished copying ami-BLA to FOO (copied id: ami-BLA)
2021/03/25 21:46:48 [INFO] (telemetry) ending ami-copy
==> Wait completed after 10 minutes 41 seconds
Build 'amazon-ebs.windows-base-image' finished after 10 minutes 41 seconds.

==> Builds finished. The artifacts of successful builds are:
2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact-count []string{"3"}
==> Wait completed after 10 minutes 41 seconds

==> Builds finished. The artifacts of successful builds are:
2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact []string{"0", "builder-id", "mitchellh.amazonebs"}
2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact []string{"0", "id", "us-east-1:ami-BLA"}
2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact []string{"0", "string", "AMIs were created:\nus-east-1: ami-BLA\n"}
2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact []string{"0", "files-count", "0"}
2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact []string{"0", "end"}
us-east-1: ami-BLA
--> amazon-ebs.windows-base-image: AMIs were created:
us-east-1: ami-BLA

2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact []string{"1", "builder-id", "mitchellh.amazonebs"}
2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact []string{"1", "id", "us-east-1:ami-BLA"}
2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact []string{"1", "string", "AMIs were created:\nus-east-1: ami-BLA\n"}
2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact []string{"1", "files-count", "0"}
2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact []string{"1", "end"}
us-east-1: ami-BLA
--> amazon-ebs.windows-base-image: AMIs were created:
us-east-1: ami-BLA

2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact []string{"2", "builder-id", "mitchellh.amazonebs"}
2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact []string{"2", "id", "us-east-1:ami-BLA"}
2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact []string{"2", "string", "AMIs were created:\nus-east-1: ami-BLA\n"}
2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact []string{"2", "files-count", "0"}
2021/03/25 21:46:48 machine readable: amazon-ebs.windows-base-image,artifact []string{"2", "end"}
us-east-1: ami-BLA
--> amazon-ebs.windows-base-image: AMIs were created:
us-east-1: ami-BLA

2021/03/25 21:46:48 [INFO] (telemetry) Finalizing.
2021/03/25 21:46:50 [WARN] (telemetry) Error finalizing report. This is safe to ignore. Post "https://checkpoint-api.hashicorp.com/v1/telemetry/packer": context deadline exceeded
2021/03/25 21:46:50 waiting for all plugin processes to complete...
2021/03/25 21:46:50 /usr/local/bin/packer: plugin process exited
2021/03/25 21:46:50 /usr/local/bin/packer: plugin process exited
2021/03/25 21:46:50 /Users/v.basra/.packer.d/plugins/github.com/martinbaillie/ami-copy/packer-plugin-ami-copy_v1.7.0_x5.0_darwin_amd64: plugin process exited
2021/03/25 21:46:50 /usr/local/bin/packer: plugin process exited
2021/03/25 21:46:50 /usr/local/bin/packer: plugin process exited

Post which tags are present on the image in the original account but not in the accounts listed to be copied in
I've defined tags as shown above like this :

  tags = {
    created-by = "vishal"
    created-on = "${local.timestamp}"
    type       = "dummy-test"
  }

I think https://github.com/vishalbasra/packer-plugin-ami-copy/blob/master/amicopy/amicopy.go#L99 isn't being called

from packer-plugin-ami-copy.

vishalbasra avatar vishalbasra commented on September 23, 2024

Again, I'm not versed w go, but I'm gonna attempt to get my hands dirty with this one, if I manage to get it working, I'll open a pull request :)

from packer-plugin-ami-copy.

martinbaillie avatar martinbaillie commented on September 23, 2024

from packer-plugin-ami-copy.

vishalbasra avatar vishalbasra commented on September 23, 2024

Hey never mind this, I figured it out, I wasn't supplying the role correctly.I did notice that the plugin makes one copy of the ami in addition to the image created in the destination account which packer now implicitly makes as well. https://www.packer.io/docs/builders/amazon/ebs#ami_users results in having one image made which is copied by packer and then with the plugin making one in having ( with the tags :) ) - I end up with two images but that work fines for me,I'm really happy with the way it's working.
Again much thanks for your work, you've made life a lot easier (and this has encouraged me to get my hands dirty with golang as well so yay! ) :)

from packer-plugin-ami-copy.

martinbaillie avatar martinbaillie commented on September 23, 2024

Great to hear. Thanks :)

Interesting that Packer now copies the AMI to target accounts πŸ€” I suppose the plugin will copy+tag+encrypt at least.

from packer-plugin-ami-copy.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.