0
votes

I'm using terraform enterprise,

I created main.tf file and placed the below code for creating sentinel policy

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"
}

Then, when I run the terraform apply, the plan is success but apply fails with the below error message.

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" {
1
Could someone assist? - youhoome

1 Answers

0
votes

check that the token used for the tfe provider is a team token, and not an org token. I just ran in to a similar situation when trying to add tfe_notification_configuration to a workspace.