我是Packer的新手,正在尝试使用VPC的私有网络创建镜像,但一直出现错误*amazon-ebs: Timeout waiting for SSH.*
使用的Packer版本是1.3.4
,私有子网通过公共子网和路由表可以访问NAT网关。但问题可能是无法到达实例,所以我也尝试了其他参数,比如:ssh_interface值为private_dns
和associate_public_ip_address
。但即使更改后仍然出现相同的错误。
我使用的模板内容如下:
"builders": [
{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "{{user `region`}}",
"source_ami": "{{user `source_ami`}}",
"instance_type": "{{user `instance_type`}}",
"iam_instance_profile": "{{user `role`}}",
"ssh_username": "{{user `ssh_username`}}",
"ssh_timeout": "15m",
"vpc_id": "{{user `vpc_id`}}",
"subnet_id": "{{user `subnet_id`}}",
"associate_public_ip_address": true,
"ami_name": "{{user `name`}}.{{isotime \"2006-01-02T150405Z\"}}",
"ami_description": "based on {{user `source_ami`}}",
"tags": {
"Name": "{{user `name`}}"
}]
在这个模板中,我没有定义安全组,但是在Packer的日志中,我看到它能够创建一个临时的安全组,因此对端口22的访问也应该是可用的。
==> amazon-ebs: Pausing after run of step 'StepKeyPair'. Press enter to continue.
==> amazon-ebs: Creating temporary security group for this instance: packer_5
c6b3667-c41f-92bc-aa89-efc5f3a2d8a8
==> amazon-ebs: Authorizing access to port 22 from 0.0.0.0/0 in the temporary security group...
==> amazon-ebs: Pausing after run of step 'StepSecurityGroup'. Press enter to continue.
==> amazon-ebs: Pausing after run of step 'StepCleanupVolumes'. Press enter to continue.
==> amazon-ebs: Launching a source AWS instance...
但问题仍然存在。在模板中是否有我遗漏的内容?或者我应该采取不同的方法生成AMI呢?