Terraform Google Uptime 检查模块 - 如何指定区域

发布于 2025-01-09 17:17:15 字数 1627 浏览 1 评论 0原文

我想指定一个区域来运行正常运行时间检查。我指定了参数 selected_regions 并指定了值“北美”,但出现以下错误


我的 terraform 代码

resource "google_monitoring_uptime_check_config" "http1" {
  project      = var.project_id
  display_name = "Website uptime check1"
  timeout = "10s"
  period = "60s"
  selected_regions = [var.region1]
  http_check {
    path = "/"
    port = "80"
  }
  monitored_resource {
    type = "uptime_url"
    labels = {
      project_id = var.project_id
      #region     = var.region
      host = "xx.xx.xx.xx"
    }
  }
}

错误

Step #1 - "terraform-apply": Error: Error updating UptimeCheckConfig "projects/xxxxxxxxxxxx/uptimeCheckConfigs/website-uptime-check-vh-T7eowa2Y": googleapi: Error 400: Invalid value at 'uptime_check_config.selected_regions[0]' (type.googleapis.com/google.monitoring.v3.UptimeCheckRegion), "North America"
Step #1 - "terraform-apply": Details:
Step #1 - "terraform-apply": [
Step #1 - "terraform-apply":   {
Step #1 - "terraform-apply":     "@type": "type.googleapis.com/google.rpc.BadRequest",
Step #1 - "terraform-apply":     "fieldViolations": [
Step #1 - "terraform-apply":       {
Step #1 - "terraform-apply":         "description": "Invalid value at 'uptime_check_config.selected_regions[0]' (type.googleapis.com/google.monitoring.v3.UptimeCheckRegion), \"North America\"",
Step #1 - "terraform-apply":         "field": "uptime_check_config.selected_regions[0]"
Step #1 - "terraform-apply":       }
Step #1 - "terraform-apply":     ]
Step #1 - "terraform-apply":   }``
Step #1 - "terraform-apply": ]
Step #1 - "terraform-apply": 

I want to specify a region for uptime check to run . I specified argument selected_regions and assigned value "North America" but getting the below error


My terraform code

resource "google_monitoring_uptime_check_config" "http1" {
  project      = var.project_id
  display_name = "Website uptime check1"
  timeout = "10s"
  period = "60s"
  selected_regions = [var.region1]
  http_check {
    path = "/"
    port = "80"
  }
  monitored_resource {
    type = "uptime_url"
    labels = {
      project_id = var.project_id
      #region     = var.region
      host = "xx.xx.xx.xx"
    }
  }
}

Error

Step #1 - "terraform-apply": Error: Error updating UptimeCheckConfig "projects/xxxxxxxxxxxx/uptimeCheckConfigs/website-uptime-check-vh-T7eowa2Y": googleapi: Error 400: Invalid value at 'uptime_check_config.selected_regions[0]' (type.googleapis.com/google.monitoring.v3.UptimeCheckRegion), "North America"
Step #1 - "terraform-apply": Details:
Step #1 - "terraform-apply": [
Step #1 - "terraform-apply":   {
Step #1 - "terraform-apply":     "@type": "type.googleapis.com/google.rpc.BadRequest",
Step #1 - "terraform-apply":     "fieldViolations": [
Step #1 - "terraform-apply":       {
Step #1 - "terraform-apply":         "description": "Invalid value at 'uptime_check_config.selected_regions[0]' (type.googleapis.com/google.monitoring.v3.UptimeCheckRegion), \"North America\"",
Step #1 - "terraform-apply":         "field": "uptime_check_config.selected_regions[0]"
Step #1 - "terraform-apply":       }
Step #1 - "terraform-apply":     ]
Step #1 - "terraform-apply":   }``
Step #1 - "terraform-apply": ]
Step #1 - "terraform-apply": 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

被你宠の有点坏 2025-01-16 17:17:15

尝试输入此文档中列出的区域:

美国、欧洲、南美洲或亚太地区

Try entering region like listed in this doc:

USA, EUROPE, SOUTH_AMERICA, or ASIA_PACIFIC

一笔一画续写前缘 2025-01-16 17:17:15

该列表很难找到。截至 2023 年 8 月 31 日,位置如下:

https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.uptimeCheckConfigs#UptimeCheckRegion

  • REGION_UNSPECIFIED
  • 美国 EUROPE
  • SOUTH_AMERICA
  • ASIA_PACIFIC
  • USA_OREGON
  • USA_IOWA
  • USA_VIRGINIA

使用示例:

variable "list_uptime_check_regions" {
  type = list
  description = "List of regions from which the check will be run."
  default = [ "EUROPE", "ASIA_PACIFIC", "SOUTH_AMERICA" ]
}

resource "google_monitoring_uptime_check_config" "https_incident" {
  display_name = "uptime-check_test"
  selected_regions = var.list_uptime_check_regions  
  timeout = "60s"
  ...
}

The list is quite difficult to find. As of 31/08/2023, it is here:

https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.uptimeCheckConfigs#UptimeCheckRegion

  • REGION_UNSPECIFIED
  • USA EUROPE
  • SOUTH_AMERICA
  • ASIA_PACIFIC
  • USA_OREGON
  • USA_IOWA
  • USA_VIRGINIA

Example of use:

variable "list_uptime_check_regions" {
  type = list
  description = "List of regions from which the check will be run."
  default = [ "EUROPE", "ASIA_PACIFIC", "SOUTH_AMERICA" ]
}

resource "google_monitoring_uptime_check_config" "https_incident" {
  display_name = "uptime-check_test"
  selected_regions = var.list_uptime_check_regions  
  timeout = "60s"
  ...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文