【发布时间】:2021-02-26 11:02:31
【问题描述】:
将 some-spring-boot.jar 复制到 GCE 实例中的最佳方法是什么?
我认为这是一项相当常见的任务,但在谷歌搜索后发现关于它的文档为零。
我已经在 GCP 中生成了服务帐户并将所有内容保存到 gcp-credentials.json 中:
{
"type": "service_account",
"project_id": "some project",
"private_key_id": "someid",
"private_key": "some key",
"client_email": "xxx@developer.gserviceaccount.com",
"client_id": "xxxx",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/xxxdeveloper.gserviceaccount.com"
}
这是我在谷歌上搜索了几个小时后正在做的事情:
terraform {
required_providers {
google = {
source = "hashicorp/google"
}
}
}
provider "google" {
version = "3.5.0"
credentials = file("gcp-credentials.json")
project = "some project"
zone = "us-central1-a"
}
resource "google_compute_instance" "vm_instance" {
name = "my-instance"
machine_type = "e2-medium"
#metadata_startup_script = file("startup.sh")
tags = [
"http-server",
"https-server"]
boot_disk {
initialize_params {
image = "some image with jdk"
}
}
network_interface {
network = "default"
access_config {}
}
provisioner "file" {
source = "../../../target/my-jar-1.0.0.jar"
destination = "/tmp/my-jar-1.0.0.jar"
connection {
type = "ssh"
user = "root"
private_key = file("gcp-credentials.json").private_key
agent = "false"
}
}
}
只要我运行它就会说
[ERROR] Error: Missing required argument
[ERROR]
[ERROR] on main.tf line 43, in resource "google_compute_instance" "vm_instance":
[ERROR] 43: connection {
[ERROR]
[ERROR] The argument "host" is required, but no definition was found.
任何帮助将不胜感激
【问题讨论】:
标签: terraform terraform-provider-gcp