我正在尝试部署hashcorp/terraform/vault module。特别是我不知道如何将图像传递到所需的模块变量consul_server_source_image
和vault_server_source_image
。我只想将docker hub镜像用于Vault和consul。
真正的问题是:执行此操作需要创建哪些资源,以及如何将它们粘合在一起? (或者被告知为什么我要做的事情是错误的/不明智的)
我会描述一下我已经尝试过的方法,但是我对terraform还是陌生的,所以我希望到目前为止,我的大多数失败都是出于显而易见的愚蠢原因。
这大致是main.tf
provider "google" "default" {
credentials = "${file(var.google_creds_dev)}"
project = "${var.project}"
region = "${var.region}"
zone = "${var.zone}"
}
data "docker_registry_image" "vault" {
name = "vault:latest"
}
data "docker_registry_image" "consul" {
name = "consul:latest"
}
resource "docker_image" "vault" {
name = "${data.docker_registry_image.vault.name}"
pull_triggers = ["${data.docker_registry_image.vault.sha256_digest}"]
}
resource "docker_image" "consul" {
name = "${data.docker_registry_image.consul.name}"
pull_triggers = ["${data.docker_registry_image.consul.sha256_digest}"]
}
//resource "google_compute_image" "vault" {
// name = "vault-image"
// source_disk = "${docker_image.vault.name}"
//}
module "vault" {
source = "hashicorp/vault/google"
version = "0.1.3"
consul_server_cluster_name = "consul-cluster"
consul_server_source_image = "???"
gcp_project_id = "${var.project}"
gcp_region = "${var.region}"
vault_cluster_name = "vault-cluster"
vault_source_image = "???"
}