Issue
From ubuntu shell I ran below command, to talk to aws platform, to customise amazon ami(ami-9abea4fb
):
$ packer build -debug template.packer
Debug mode enabled. Builds will not be parallelized.
amazon-ebs output will be in this color.
==> amazon-ebs: Prevalidating AMI Name...
==> amazon-ebs: Pausing after run of step 'StepPreValidate'. Press enter to continue.
==> amazon-ebs: Inspecting the source AMI...
==> amazon-ebs: Pausing after run of step 'StepSourceAMIInfo'. Press enter to continue.
==> amazon-ebs: Creating temporary keypair: packer 5dfe9f3b-9cc2-cbfa-7349-5c8ef50c64d5
amazon-ebs: Saving key for debug purposes: ec2_amazon-ebs.pem
==> amazon-ebs: Pausing after run of step 'StepKeyPair'. Press enter to continue.
where template.packer
is:
{
"builders": [
{
"type": "amazon-ebs",
"region": "us-west-2",
"source_ami": "ami-9abea4fb",
"instance_type": "t2.micro",
"ssh_username": "ubuntu",
"ami_name": "MiddleTier-{{isotime | clean_ami_name}}",
"ami_description": "Amazon AMI customised",
"tags": {
"role": "MiddleTier"
},
"run_tags":{
"role": "buildSystem"
}
}
],
"provisioners": [
],
"post-processors":[
]
}
and my understanding is, AWS has created a private key(ec2_amazon-ebs.pem
) for packer to talk to EC2 instance in passwordless way, as mentioned in above steps.
But I do not see packer copying the private key(ec2_amazon-ebs.pem
) in my laptop(as ~/.ssh/ec2_amazon-ebs.pem
)
How does packer talk to EC2? without copying as ~/.ssh/ec2_amazon-ebs.pem
in my laptop
Solution
Unless Packer is given a private SSH with the ssh_private_key_file
Packer creates an ephemeral that is only kept in memory while Packer is running.
When you run with the -debug
flag this ephemeral key is saved into the current working directory. This is to enable you to troubleshoot the build by manually SSH'ing into the instance.
Answered By - Rickard von Essen