Terminating the source AWS instance

404 views
Skip to first unread message

Nico Brys

unread,
Oct 10, 2014, 5:26:09 AM10/10/14
to packe...@googlegroups.com
Hi,

I've got a question about creating AMIs. The latest step of creating an ami using packer is terminating the source image. This step takes around 10 minutes. Is it really necessary to wait until the source image is terminated before continuing the packer build process? Once the call to the amazon api is made to terminate this instance, can't packer just continue instead of waiting?

09:50:03   [0;32m    amazon-ebs: AMI: ami-cad37ebd [0m
09:50:03   [1;32m==> amazon-ebs: Waiting for AMI to become ready... [0m
10:01:48   [1;32m==> amazon-ebs: Terminating the source AWS instance... [0m
10:11:57   [1;32m==> amazon-ebs: Deleting temporary keypair... [0m
10:11:57   [1;32mBuild 'amazon-ebs' finished. [0m

-> 11 minutes to create the ami
-> 10 minutes to stop the source instance?? This can be done in just a second

Thanks in advance!
Nico

Todd Thomas

unread,
Oct 10, 2014, 3:15:27 PM10/10/14
to packe...@googlegroups.com
Nico, I've been experimenting with AWS myself. It seems the answer to your question is "no".

At the point of interaction, packer is waiting on AWS to process this request. For the free account (which I have), AWS appears to treat the t1.micro AMIs as a low priority and thus the waiting. I haven't paid for anything past the free account so I'm not sure if this process gets a higher priority on a paid level or not; googling this same subject supports these observations.

It's just time-consuming - for now.

TT

Shane Meyers

unread,
Oct 10, 2014, 3:24:15 PM10/10/14
to packe...@googlegroups.com
It really depends on the instance type.  g2.2xlarge instances take a really long time to terminate as well.  I'm not sure why, especially considering they're pretty high performance boxes.

My understanding is that packer waits for the source instance to be terminated to ensure the volume is in a guaranteed consistent state.  Otherwise if the instance is slow to shutdown for whatever reason, packer could take a snapshot of an inconsistent file system.

-shane
--
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nico Brys

unread,
Oct 11, 2014, 7:09:46 AM10/11/14
to packe...@googlegroups.com
I'm just wondering it we just can't change the source









// Terminate the source instance if it exists


        if s.instance != nil {




                ui.Say("Terminating the source AWS instance...")


                if _, err := ec2conn.TerminateInstances([]string{s.instance.InstanceId}); err != nil {


                        ui.Error(fmt.Sprintf("Error terminating instance, may still be around: %s", err))


                        return


                }


                stateChange := StateChangeConf{


                        Pending: []string{"pending", "running", "shutting-down", "stopped", "stopping"},


                        Refresh: InstanceStateRefreshFunc(ec2conn, s.instance),


                        Target:  "terminated",


                }




                WaitForState(&stateChange)


to









// Terminate the source instance if it exists


        if s.instance != nil {




                ui.Say("Terminating the source AWS instance...")


                if _, err := ec2conn.TerminateInstances([]string{s.instance.InstanceId}); err != nil {


                        ui.Error(fmt.Sprintf("Error terminating instance, may still be around: %s", err))


                        return


                }


                stateChange := StateChangeConf{


                        Pending: []string{"pending", "running", "shutting-down", "stopped", "stopping"},


                        Refresh: InstanceStateRefreshFunc(ec2conn, s.instance),


                        Target:  "shutting-down",


                }




                WaitForState(&stateChange)

Reply all
Reply to author
Forward
0 new messages