Еще одно предложение: вы можете позвонить в Packer из Terraform.
resource "null_resource" "packer_runner" {
triggers = {
install_script = "${sha1(file("${path.module}/scripts/app/install.sh"))}"
packer_file = "${sha1(file("${path.module}/packer/packer.json"))}"
}
provisioner "local-exec" {
working_dir = "${path.module}"
command = "packer build -var 'ami_name=${var.ami_name}' -var 'aws_region=${var.aws_region}' -var 'network_id=${var.network_id}' -var -parallel-builds=1 ./packer/packer.json"
interpreter = ["PowerShell", "-Command"]
}
}
Затем, на packer.json
:
<...stuff...>
"provisioners": [
{
"type": "shell",
"inline": "/usr/bin/cloud-init status --wait"
},
{
"type": "shell",
"environment_vars": [
"NETWOR_ID={{user `network_id`}}"
],
"script": "./scripts/app/install.sh"
},
<...more stuff...>