jfrog / terraform-provider-xray

Terraform provider to manage JFrog Xray
https://jfrog.com/xray/
Apache License 2.0
149 stars 12 forks source link

resource "xray_watch" "repository" for creating xray_watch policy does not accepts list of repositories #79

Closed SudhirmkGit closed 2 years ago

SudhirmkGit commented 2 years ago

Hi , I am using jfrog x-ray provider and using the resource "xray_watch" "repository" for creating xray_watch policy. In the description of the block it clearly mentioned that we can either watch a single repo or list of repositories, however when i pass the list of repositories it errors out with the below message. it is accepting only one string value(one repository to watch) and not the list of repositories

Error: Incorrect attribute value type on modules/jfrog/policies.tf line 40, in resource "xray_watch" "repository": name = var.repositories var.repositories is a list of dynamic, known only after apply Inappropriate value for attribute "name": string required.

This is the block used

resource "xray_watch" "repository" { name = "repository-watch" description = "Watch a single repo or a list of repositories". --> it says list of repositories active = true project_key = "testproj"

watch_resource { type = "repository" bin_mgr_id = "default" name = "your-repository-name". --> am passing list of repositories here (var.repositories) repo_type = "local"

https://registry.terraform.io/providers/jfrog/xray/latest/docs/resources/watch

can you please advise how can i pass the list of repositories for this watch_resource block?

alexhung commented 2 years ago

@SudhirmkGit Per HCL, you define multiple instances of watch_resource attribute for multiple repos/builds/etc.

resource "xray_watch" "repository" {
    name        = "repository-watch"
    description = "Watch a single repo or a list of repositories"
    active      = true
    project_key = "testproj"

    watch_resource {
        type.      = "repository"
        bin_mgr_id = "default"
        name       = "your-repository-name-1"
        repo_type  = "local"
    }

    watch_resource {
        type       = "repository"
        bin_mgr_id = "default"
        name       = "your-repository-name-2"
        repo_type  = "local"
    }
}

The example HCL in the documentation also shows this: https://registry.terraform.io/providers/jfrog/xray/latest/docs/resources/watch#example-usage

SudhirmkGit commented 2 years ago

Thanks, this can be closed..