我正在创建一个AWS实例,并试图在创建时运行一个Vault服务器。我的问题是创建过程永远不会结束,因为服务器没有在后台运行。这是我的配置:
resource "aws_instance" "web" {
ami = "ami-466768ac"
instance_type = "t2.micro"
key_name = "my_key"
tags {
Name = "Vault"
}
provisioner "remote-exec" {
connection {
type = "ssh"
agent = false
user = "ec2-user"
private_key = "${file("/path/to/my_key")}"
}
inline = [
"curl -O https://releases.hashicorp.com/vault/0.10.4/vault_0.10.4_linux_amd64.zip",
"unzip vault_0.10.4_linux_amd64.zip",
"./vault server -dev -dev-listen-address=0.0.0.0:8200"
]
}
}
基本上,我是通过
curl
运行开发服务器。服务器实际上正在运行(我在终端日志中看到),但实例创建(由Terraform)从未完成:
aws_instance.web: Still creating... (40s elapsed)
aws_instance.web: Still creating... (50s elapsed)
aws_instance.web: Still creating... (1m0s elapsed)
aws_instance.web: Still creating... (1m10s elapsed)
aws_instance.web: Still creating... (1m20s elapsed)
aws_instance.web: Still creating... (1m30s elapsed)
...
我试着加上
&
在starting Vault server命令的末尾,为了不阻止shell,但在我执行此操作时,将创建实例,但实际上并没有启动Vault server。
如何在创建实例时以后台模式启动服务器?
编辑
我也试过
nohup
:
nohup ./vault server -dev -dev-listen-address=0.0.0.0:8200
但当terraform完成时服务器不会启动。。。