我正在使用 packer 创建一个安装了 docker 的自定义 AMI。然后我尝试添加 docker swarm。不幸的是,它失败了,因为 terraform 无法通过 ssh 连接到任何机器。
地形应用
在一切停止之前,这会在日志中打印 100 次:
aws_instance.swarm-manager (remote-exec): Connecting to remote host via SSH...
aws_instance.swarm-manager (remote-exec): Host: 35.176.154.111
aws_instance.swarm-manager (remote-exec): User: ubuntu
aws_instance.swarm-manager (remote-exec): Password: false
aws_instance.swarm-manager (remote-exec): Private key: true
aws_instance.swarm-manager (remote-exec): SSH Agent: false
我在浏览器中打开AWS EC2控制台,找到堡垒服务器的公网IP。尝试连接但失败:
我可以自己通过 ssh 连接到服务器。Terraform 不能访问 EC2 实例。
ssh -i ~/.ssh/terraform-eu-west-2.pem [email protected]
密钥对
对于 eu-west-2 区域,我创建了一个名为 terraform 的密钥。这被保存为 ~/.ssh/terraform-eu-west-2.pem
我在 Github 上的所有文件
我已经把所有的 shebang 都保存到了github repo 中。请看一看。
在输出的最后,terraform apply
我得到了这个。我认为这是因为我无法 ssh,但我不确定。
Error applying plan:
4 error(s) occurred:
* aws_instance.swarm-node[2]: 1 error(s) occurred:
* Script exited with non-zero exit status: 125
* aws_instance.swarm-node[0]: 1 error(s) occurred:
* Script exited with non-zero exit status: 125
* aws_subnet.c: 1 error(s) occurred:
* aws_subnet.c: Error creating subnet: InvalidParameterValue: Value (eu-west-2c) for parameter availabilityZone is invalid. Subnets can currently only be created in the following availability zones: eu-we
st-2a, eu-west-2b.
status code: 400, request id: 5459c120-f60b-4beb-9acb-323c4bc3c06d
* aws_instance.swarm-node[1]: 1 error(s) occurred:
* Script exited with non-zero exit status: 125
错误说:Subnets can currently only be created in the following availability zones: eu-west-2a, eu-west-2b
。但是,如果我将区域从eu-west-2更改为eu-west-2a,我会收到一条错误消息* provider.aws: Not a valid region: eu-west-2a
您正在混合区域/可用区。区域eu-west-2
只有 2 个有效区域:eu-west-2a, eu-west-2b
. 但是您的 Terraform 代码也在尝试使用 invalid zone eu-west-2c
。c
从您的 Terraform 代码或使用区域中删除该区域部分,其中c
区域也可用(例如eu-west-1
)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句