我正在使用Terraform Enterprise,
我创建了main.tf文件,并放置了以下代码以创建哨兵策略
data "tfe_workspace_ids" "all" {
names = ["*"]
organization = myorg
}
locals {
workspaces = "${data.tfe_workspace_ids.all.external_ids}" # map of names to IDs
}
resource "tfe_sentinel_policy" "test" {
name = "my-policy-name"
description = "This policy always passes"
organization = "myorg"
policy = "main = rule { true }"
enforce_mode = "hard-mandatory"
}
然后,当我运行Terraform Apply时,该计划是成功的,但是Apply失败并显示以下错误消息。
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# tfe_sentinel_policy.test will be created
+ resource "tfe_sentinel_policy" "test" {
+ description = "This policy always passes"
+ enforce_mode = "hard-mandatory"
+ id = (known after apply)
+ name = "my-policy-name"
+ organization = "myorg"
+ policy = "main = rule { true }"
}
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions in workspace "tf-sentinel-governance"?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
tfe_sentinel_policy.test: Creating...
Error: Error creating sentinel policy my-policy-name for organization myorg: resource not found
on main.tf line 10, in resource "tfe_sentinel_policy" "test":
10: resource "tfe_sentinel_policy" "test" {
答案 0 :(得分:0)
检查用于token
提供者的tfe
是团队令牌,而不是组织令牌。尝试将tfe_notification_configuration
添加到工作区时,我遇到了类似情况。