diff --git a/cyral/data_source_cyral_repository.go b/cyral/data_source_cyral_repository.go index 02e22f8d..07b8abb7 100644 --- a/cyral/data_source_cyral_repository.go +++ b/cyral/data_source_cyral_repository.go @@ -71,7 +71,7 @@ func dataSourceRepositoryReadConfig() ResourceOperationConfig { func dataSourceRepository() *schema.Resource { return &schema.Resource{ - Description: "Retrieve and filter repositories.", + Description: "Retrieves a list of repositories. See [`repository_list`](#nestedatt--repository_list).", ReadContext: ReadResource(dataSourceRepositoryReadConfig()), Schema: map[string]*schema.Schema{ RepoNameKey: { diff --git a/cyral/resource_cyral_repository_access_rules.go b/cyral/resource_cyral_repository_access_rules.go index 886f4fc4..40ed420c 100644 --- a/cyral/resource_cyral_repository_access_rules.go +++ b/cyral/resource_cyral_repository_access_rules.go @@ -288,10 +288,12 @@ func resourceRepositoryAccessRules() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "policy_ids": { - Description: "Extra authorization policies, such as PagerDuty or DUO.", - Required: true, - Type: schema.TypeList, - MinItems: 1, + Description: "Extra authorization policies, such as PagerDuty or DUO." + + " Use the attribute `id` from resources `cyral_integration_pager_duty`" + + " and `cyral_integration_mfa_duo`.", + Required: true, + Type: schema.TypeList, + MinItems: 1, Elem: &schema.Schema{ Type: schema.TypeString, }, diff --git a/docs/data-sources/repository.md b/docs/data-sources/repository.md index 3af35db8..071b3a91 100644 --- a/docs/data-sources/repository.md +++ b/docs/data-sources/repository.md @@ -1,6 +1,6 @@ # cyral_repository (Data Source) -Retrieve and filter repositories. +Retrieves a list of repositories. See [`repository_list`](#nestedatt--repository_list). ## Example Usage @@ -18,9 +18,9 @@ resource "cyral_repository" "mongo-repository" { } } -resource "cyral_repository" "mysql-repository" { +resource "cyral_repository" "mysql-repository1" { type = "mysql" - name = "tf-provider-mysql-repository" + name = "tf-provider-mysql-repository1" repo_node { host = "mysql.com" @@ -28,17 +28,45 @@ resource "cyral_repository" "mysql-repository" { } } -data "cyral_repository" "search-for-mysql-repo" { +resource "cyral_repository" "mysql-repository2" { + type = "mysql" + name = "tf-provider-mysql-repository2" + + repo_node { + host = "mysql2.com" + port = 3306 + } +} + +data "cyral_repository" "specific-mysql-repo" { depends_on = [ cyral_repository.mongo-repository, - cyral_repository.mysql-repository + cyral_repository.mysql-repository1, + cyral_repository.mysql-repository2, ] - name = "tf-provider-mysql-repository" + # As we have more than one MySQL repos, we need to provide + # the name and type or just the name (repo names are unique) + name = "tf-provider-mysql-repository1" type = "mysql" } -output "mysql_repo_id" { - value = data.cyral_repository.search-for-mysql-repo.id +data "cyral_repository" "all-mysql-repos" { + depends_on = [ + cyral_repository.mongo-repository, + cyral_repository.mysql-repository1, + cyral_repository.mysql-repository2, + ] + type = "mysql" +} + +output "mysql1_repo_id" { + # Because our search is targeting a specific name that we + # know it exists referencing index 0 is safe. + value = data.cyral_repository.specific-mysql-repo.repository_list[0].id +} + +output "all_mysql_repo_ids" { + value = data.cyral_repository.all-mysql-repos.repository_list } ``` diff --git a/docs/resources/repository_access_rules.md b/docs/resources/repository_access_rules.md index 4116f55a..433dae6a 100644 --- a/docs/resources/repository_access_rules.md +++ b/docs/resources/repository_access_rules.md @@ -91,4 +91,4 @@ Required: Required: -- `policy_ids` (List of String) Extra authorization policies, such as PagerDuty or DUO. +- `policy_ids` (List of String) Extra authorization policies, such as PagerDuty or DUO. Use the attribute `id` from resources `cyral_integration_pager_duty` and `cyral_integration_mfa_duo`. diff --git a/examples/data-sources/cyral_repository/data-source.tf b/examples/data-sources/cyral_repository/data-source.tf index d8ed0a4b..c8542f5b 100644 --- a/examples/data-sources/cyral_repository/data-source.tf +++ b/examples/data-sources/cyral_repository/data-source.tf @@ -11,9 +11,9 @@ resource "cyral_repository" "mongo-repository" { } } -resource "cyral_repository" "mysql-repository" { +resource "cyral_repository" "mysql-repository1" { type = "mysql" - name = "tf-provider-mysql-repository" + name = "tf-provider-mysql-repository1" repo_node { host = "mysql.com" @@ -21,15 +21,43 @@ resource "cyral_repository" "mysql-repository" { } } -data "cyral_repository" "search-for-mysql-repo" { +resource "cyral_repository" "mysql-repository2" { + type = "mysql" + name = "tf-provider-mysql-repository2" + + repo_node { + host = "mysql2.com" + port = 3306 + } +} + +data "cyral_repository" "specific-mysql-repo" { depends_on = [ cyral_repository.mongo-repository, - cyral_repository.mysql-repository + cyral_repository.mysql-repository1, + cyral_repository.mysql-repository2, ] - name = "tf-provider-mysql-repository" + # As we have more than one MySQL repos, we need to provide + # the name and type or just the name (repo names are unique) + name = "tf-provider-mysql-repository1" type = "mysql" } -output "mysql_repo_id" { - value = data.cyral_repository.search-for-mysql-repo.id +data "cyral_repository" "all-mysql-repos" { + depends_on = [ + cyral_repository.mongo-repository, + cyral_repository.mysql-repository1, + cyral_repository.mysql-repository2, + ] + type = "mysql" +} + +output "mysql1_repo_id" { + # Because our search is targeting a specific name that we + # know it exists referencing index 0 is safe. + value = data.cyral_repository.specific-mysql-repo.repository_list[0].id +} + +output "all_mysql_repo_ids" { + value = data.cyral_repository.all-mysql-repos.repository_list }