Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harness TF Provider Issue with PolicySets #1134

Open
rogersbTrace3 opened this issue Dec 10, 2024 · 0 comments
Open

Harness TF Provider Issue with PolicySets #1134

rogersbTrace3 opened this issue Dec 10, 2024 · 0 comments

Comments

@rogersbTrace3
Copy link

rogersbTrace3 commented Dec 10, 2024

###Terraform Version
1.10.1

Affected Resource(s)

  • harness_platform_policyset

Terraform Configuration Files

resource "harness_platform_policy" "instance_size" {
  name       = "EC2 Instance Size"
  identifier = "ec2_instance_size"
  org_id            = var.org_id
  project_id        = var.project_id
  git_connector_ref = var.gitlab_connector_id
  git_path          = ".harness/Terraform_Plan_EC2_Instance_Size.rego"
  git_repo          = var.harness_config_path
  git_branch        = "main"
  git_is_new_branch = false
  git_import        = false
  git_commit_msg    = "Adding policy from Terraform"
  rego              = file("${path.module}/templates/ec2_demo/policy-instance-size.rego")
}

resource "harness_platform_policyset" "instance_size_policyset" {
  name       = "Instance Size"
  identifier = "instance_size"
  action     = "afterTerraformPlan"
  type       = "terraformPlan"
  enabled    = true
  org_id     = var.org_id
  project_id = var.project_id
  
  policies {
    identifier = harness_platform_policy.instance_size.id
    severity   = "error"
  }
}

Debug Output

https://gist.github.com/rogersbTrace3/2d60e95656e64620c0f06b8b1be6d6b7

Expected Behavior

Policy and PolicySet should have been created, and Policy should have been attached to the PolicySet.

Actual Behavior

  • Policy is created
  • PolicySet is also created
  • Policy is NOT attached
  • Terraform does not see that the PolicySet was created, instead it returns a 400 error.

Pasted image 20241210154856
Pasted image 20241210161139

  Error: 400 Bad Request
  
    with harness_platform_policyset.total_cost_policyset,
    on policies.tf line 23, in resource "harness_platform_policyset" "total_cost_policyset":
    23: resource "harness_platform_policyset" "total_cost_policyset" {

If the PolicySet is deleted in the Harness UI, then the Terraform is able to create the PolicySet successfully on the next run.

Steps to Reproduce

  1. terraform apply
  2. See 400 error as above.
  3. Delete PolicySet in Harness
  4. terraform apply
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant