【问题标题】:Terraform Error creating Topic: googleapi: Error 403: User not authorized to perform this actionTerraform 错误创建主题:googleapi:错误 403:用户无权执行此操作
【发布时间】:2021-12-01 01:17:02
【问题描述】:

Googleapi:错误 403:用户无权执行此操作

provider "google" {
  project     = "xxxxxx"
  region      = "us-central1"
}

resource "google_pubsub_topic" "gke_cluster_upgrade_notifications" {
  name    = "cluster-notifications"
  

  labels = {
    foo = "bar"
  }

  message_storage_policy {
    allowed_persistence_regions = [
      "region",
    ]
  }
}

# create the storage bucket for our scripts
resource "google_storage_bucket" "source_code" {
  name          = "xxxxxx-bucket-lh05111992"
  location      = "us-central1"
  force_destroy = true
}

# zip up function source code
data "archive_file" "function_script_zip" {
  type        = "zip"
  source_dir  = "./function/"
  output_path = "./function/main.py.zip"
}

# add function source code to storage
resource "google_storage_bucket_object" "function_script_zip" {
  name   = "main.py.zip"
  bucket = google_storage_bucket.source_code.name
  source = "./function/main.py.zip"
}


resource "google_cloudfunctions_function" "gke_cluster_upgrade_notifications" {---
-------
}

服务帐号附加了所有者角色

也尝试使用 1.导出 GOOGLE_APPLICATION_CREDENTIALS={{path}} 2.credentials = "${file("credentials.json")}" 通过将json文件放在terraform根文件夹中。

【问题讨论】:

  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: kubernetes google-cloud-platform google-cloud-functions terraform


【解决方案1】:

使用的帐户似乎缺少一些创建 Cloud Pub/Sub 主题的权限(例如 pubsub.topics.create)。 owner 角色应该足以创建主题,因为它包含必要的权限(您可以查看此here)。因此,Terraform 中可能设置了错误的服务帐户。

为了解决这些 IAM 问题,我建议:

  1. 使用Policy Troubleshooter

  2. Impersonate service account 并使用带有 --verbosity=debug 标志的 CLI 进行 API 调用,这将提供有关缺少权限的有用信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-17
    • 1970-01-01
    • 2020-07-04
    • 2011-02-10
    • 2019-01-28
    • 2020-06-21
    • 2016-11-23
    相关资源
    最近更新 更多