Ebin Davis
Ebin Davis

Reputation: 6129

Creating image of the running instance using Packer

I launched an instance in AWS using Terraform with basic functionalities.Once the instance is launched, i need to capture that instance into image using Packer.

How can i accomplish the same?

Upvotes: 0

Views: 636

Answers (1)

Vorsprung
Vorsprung

Reputation: 34327

Packer is used to make customised AMIs. But if the image is already running and customised then an AMI can be made with standard AWS tools

Once the instance is running and configured with Terraform, take an ami image of it. See this documentation https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-ebs.html

OTOH if you want to automate the whole process of making the AMI automatically then add your steps that configure the base AMI in the first place to run Terraform within the packer script

Once you have a Packer script like this, the whole process is automatic

To make a new AMI running packer build on your packer config file should do everything automatically

Edit: your comments below hint that maybe what you want to do is use Packer on an already running instance to make an AMI, perhaps with further configuration to add to it. To do this, first make an AMI of the running image. There are instructions for doing this in the link above.

Next, write your Packer script in such a way that it takes the AMI id of the new image as a parameter. Then you can run the Packer script using the new AMI as input and so finish up with an AMI made by Packer but based on the running instance

Sorry it took a while to add this but I can't imagine a use case where this would be a useful thing to do

Upvotes: 1

Related Questions