创建实例模板时,Terraform GCP,获取源图像的相对路径时出错

菲洛

我在设置GCP实例模板时遇到了一个新问题。我假设terraform gcp提供程序上有更新。

resource "google_compute_instance_template" "backend-template" {
  name                    = "${var.platform_name}-backend-instance-template"
  description             = "Template used for backend instances"
  instance_description    = "backend Instance"
  machine_type            = "n1-standard-1"
  metadata_startup_script = "${lookup(var.startup_scripts,"backend-server")}"

disk {
  boot         = "true"
  source_image = "backend-packer-image"
}

metadata {
  APP_SETTINGS        = "${var.app_settings}"
  URL_STAGING         = "${var.url_staging}"
  API_URL_STAGING     = "${var.api_url_staging}"
  URL_PRODUCTION      = "${var.url_production}"
  API_URL_PRODUCTION  = "${var.api_url_production}"
  LOGIN_URL           = "${var.login_url}"
  API_URL             = "${var.api_url}"
  vault_server_IP     = "${lookup(var.static_ips, "vault-server")}"
  environment         = "${var.environment}"
}

network_interface {
  subnetwork = "${google_compute_subnetwork.private-fe-be.self_link}"
}

lifecycle {
  create_before_destroy = true
}

tags = ["no-ip", "backend-server"]

service_account {
  scopes = ["cloud-platform"]
}
}

这是运行脚本后的当前错误。但是,该图像backend-packer-image已经创建并存在于GCP上

* google_compute_instance_template.backend-template: 1 error(s) occurred:

* google_compute_instance_template.backend-template: error flattening disks: Error getting relative path for source image: String was not a self link: global/images/backend-packer-image
夜金

今天我遇到了完全相同的问题,我不得不直接研究pull请求,以找到正确使用此请求的方法。

所以,我要附带的是:输入此命令之前,必须首先确保已进入项目中,否则,如果是自定义图像,则找不到所需的图像:

gcloud compute images list --uri | grep "your image name"

这样,您将拥有图像的uri,然后可以将其完全放入图像中,然后它将起作用。

将图片名称替换为URI source_image

resource "google_compute_instance_template" "backend-template" {
  name                    = "${var.platform_name}-backend-instance- 
  template"
  description             = "Template used for backend instances"
  instance_description    = "backend Instance"
  machine_type            = "n1-standard-1"
  metadata_startup_script = "${lookup(var.startup_scripts,"backend-server")}"

  disk {
  boot         = "true"
  source_image = "https://www.googleapis.com/compute/v1/projects/<project-name>/global/images/backend-packer-image"
}

metadata {
  APP_SETTINGS        = "${var.app_settings}"
  URL_STAGING         = "${var.url_staging}"
  API_URL_STAGING     = "${var.api_url_staging}"
  URL_PRODUCTION      = "${var.url_production}"
  API_URL_PRODUCTION  = "${var.api_url_production}"
  LOGIN_URL           = "${var.login_url}"
  API_URL             = "${var.api_url}"
  vault_server_IP     = "${lookup(var.static_ips, "vault-server")}"
  environment         = "${var.environment}"
}

network_interface {
  subnetwork = "${google_compute_subnetwork.private-fe-be.self_link}"
}

lifecycle {
  create_before_destroy = true
}

tags = ["no-ip", "backend-server"]

service_account {
  scopes = ["cloud-platform"]
}
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

创建位图时的相对路径

在构建项目时,由于相对路径,webpack会给出错误

通过 Powershell 运行时在 Alteryx 中使用相对路径时出错

Terraform 相对路径

在 React 中使用相对路径时图像未加载

使用 require() 从相对路径加载图像时找不到模块

尝试从相对路径读取文件时,获取“ java.io.IOException:流已关闭”

从scala库内部获取相对路径(在开发该库时)

使用pH schematron时解析相对路径

使用相对路径时Docker的卷无效字符

需要Angular组件时找不到相对路径

使用相对路径时 currentTime 出现问题

在生产中尝试通过 .net core 3.X 中的相对路径读取文件时出错

在生产中尝试通过 .net core 3.X 中的相对路径读取文件时出错

Terraform中的相对路径

如何使用源的相对路径创建顶级命名卷?

创建exe时如何在PyInstaller中提供图标的相对路径

ng serve无法解析从src路径导入,但在使用相对路径时可以工作

使用直接路径而不是相对路径时,包含的dbconfig.php文件失败

如何在 React 中创建相对路径以显示图像

Docker运行命令,使用相对路径时卷错误

使用相对路径时电子中require()的意外行为

使用ansible构建时在Dockerfile中设置相对路径

从两个不同位置进行编织时,在Rmarkdown中使用相对路径

自定义Angular-CLI以在构建时修改相对路径

为什么我使用 Cmake 构建和 VS 2019 构建时相对路径不同?

使用相对路径时不显示CSS背景图片

使用代码存储库时如何引用资源的相对路径

在插件的相对路径中定位资源时出现问题