hashicorp / packer-plugin-amazon

Packer plugin for Amazon AMI Builder
https://www.packer.io/docs/builders/amazon
Mozilla Public License 2.0
75 stars 112 forks source link

Support Deregistration Protection #516

Closed phuhung273 closed 1 week ago

phuhung273 commented 1 week ago

Closes #486

Description

Integration Test

amazon-ebs.basic-example: output will be in this color.

==> amazon-ebs.basic-example: Prevalidating any provided VPC information
==> amazon-ebs.basic-example: Prevalidating AMI Name: packer-example-20241116152947
    amazon-ebs.basic-example: Found Image ID: ami-0664c8f94c2a2261b
==> amazon-ebs.basic-example: Creating temporary keypair: packer_6738ba6b-1d80-2214-bad8-40de2eadda8d
==> amazon-ebs.basic-example: Creating temporary security group for this instance: packer_6738ba71-0533-49e9-e004-e55fa2b8a344
==> amazon-ebs.basic-example: Authorizing access to port 22 from [0.0.0.0/0] in the temporary security groups...
==> amazon-ebs.basic-example: Launching a source AWS instance...
    amazon-ebs.basic-example: Instance ID: i-031b269632a49e63e
==> amazon-ebs.basic-example: Waiting for instance (i-031b269632a49e63e) to become ready...
==> amazon-ebs.basic-example: Using SSH communicator to connect: 3.85.87.245
==> amazon-ebs.basic-example: Waiting for SSH to become available...
==> amazon-ebs.basic-example: Connected to SSH!
==> amazon-ebs.basic-example: Stopping the source instance...
    amazon-ebs.basic-example: Stopping instance
==> amazon-ebs.basic-example: Waiting for the instance to stop...
==> amazon-ebs.basic-example: Creating AMI packer-example-20241116152947 from instance i-031b269632a49e63e
    amazon-ebs.basic-example: AMI: ami-017c9909fd9e4ba2c
==> amazon-ebs.basic-example: Waiting for AMI to become ready...
==> amazon-ebs.basic-example: Skipping Enable AMI deprecation...
==> amazon-ebs.basic-example: Enabling deregistration protection on AMI (ami-017c9909fd9e4ba2c) in region "us-east-1" ...
==> amazon-ebs.basic-example: Terminating the source AWS instance...
==> amazon-ebs.basic-example: Cleaning up any extra volumes...
==> amazon-ebs.basic-example: No volumes to clean up, skipping
==> amazon-ebs.basic-example: Deleting temporary security group...
==> amazon-ebs.basic-example: Deleting temporary keypair...
Build 'amazon-ebs.basic-example' finished after 3 minutes 55 seconds.

==> Wait completed after 3 minutes 55 seconds

==> Builds finished. The artifacts of successful builds are:
--> amazon-ebs.basic-example: AMIs were created:
us-east-1: ami-017c9909fd9e4ba2c
Screenshot 2024-11-16 223820
phuhung273 commented 1 week ago

Hey @phuhung273,

Thanks for the PR! I very much appreciate you adding an acceptance test at the same time, thanks a lot for this; I'll try it in our environment to be sure, but this looks good to me at first glance.

I've left a few comments on the code and the docs, the options for the deregistration_protection are not visible in the READMEs for the builders, so we should probably address that before we merge and release this feature.

Besides that, LGTM! Thanks for the PR again, much appreciated

As new contributor, im really grateful for your kind instruction @lbajolet-hashicorp

lbajolet-hashicorp commented 1 week ago

Hi again @phuhung273,

I've just tried to run the acceptance test, which failed because the Region was not specified in the AMI specification for the test. I've also noticed that the created AMI would linger after testing, so I took the liberty to push a couple commits to address those shortcomings on top of yours, hope this is not a problem.

With those changes, the test does succeed and cleans-up afterwards, so provided the tests go green now, I'll be able to trigger a merge!

phuhung273 commented 1 week ago

Hi again @phuhung273,

I've just tried to run the acceptance test, which failed because the Region was not specified in the AMI specification for the test. I've also noticed that the created AMI would linger after testing, so I took the liberty to push a couple commits to address those shortcomings on top of yours, hope this is not a problem.

With those changes, the test does succeed and cleans-up afterwards, so provided the tests go green now, I'll be able to trigger a merge!

Thank you so much @lbajolet-hashicorp. Not sure why the test succeeded on my side, maybe because I already set AWS_REGION

Again, thank you so much for being incredibly helpful and giving instruction. Hope it wont cause any problem for the plugin.