Hi,
We are in the process of migrating our provider from SDKv2 to framework. One of our existing resource contains optional blocks at the root level, with one required attribute inside these blocks.
The repo
block is optional with repositories
attribute being required inside the block. There are 2 more root attributes (build
and release_bundle
) with identical block schema (not shown in this example below).
resource "artifactory_permission_target" "test-perm" {
name = "test-perm"
repo {
includes_pattern = ["foo/**"]
excludes_pattern = ["bar/**"]
repositories = ["example-repo-local"]
actions {
users {
name = "anonymous"
permissions = ["read", "write"]
}
groups {
name = "readers"
permissions = ["read"]
}
}
}
}
See Terraform Registry for details.
Our acceptance tests (that pass for SDKv2 version of the resource) fail with the following error message:
resource_artifactory_permission_target_test.go:335: Step 1/5 error: Error running pre-apply refresh: exit status 1
Error: Missing Configuration for Required Attribute
with artifactory_permission_target.test-perm6951051,
on terraform_plugin_test.tf line 6, in resource "artifactory_permission_target" "test-perm6951051":
6: resource "artifactory_permission_target" "test-perm6951051" {
Must set a configuration value for the build.repositories attribute as the
provider has marked it as required.
Refer to the provider documentation or contact the provider developers for
additional information about configurable attributes that are required.
Error: Missing Configuration for Required Attribute
with artifactory_permission_target.test-perm6951051,
on terraform_plugin_test.tf line 6, in resource "artifactory_permission_target" "test-perm6951051":
6: resource "artifactory_permission_target" "test-perm6951051" {
Must set a configuration value for the release_bundle.repositories attribute
as the provider has marked it as required.
Refer to the provider documentation or contact the provider developers for
additional information about configurable attributes that are required.
(The acceptance test only have configuration for repo
attribute)
This suggests that the provider bypass(?) the optional nature of the block and determines that the block’s required attribute “repositories” means the blocks are now required as well?
The root attribute repo
is a SingleNestedBlock
with attribute repositories
’s required
set to true
. From the documentation, my understanding is that SingleNestedBlock
is optional out of the box.
Or have I setup the block incorrectly? Or may be I should be using SingleNestedAttribute
instead?