jfrog/terraform-provider-artifactory

Artifactory remote default value for list_remote_folder_items argument

Closed this issue · 3 comments

Describe the bug
Hello, we are upgrading the Artifactory provider to version 10.1.2 and during the plan we observed that for the artifactory_remote_docker_repository resource, the argument list_remote_folder_items which was not previously used was reported to be changed from false to true:

# artifactory_remote_docker_repository.docker-remote["public-dockerhub-mirror"] will be updated in-place
~ resource "artifactory_remote_docker_repository" "docker-remote-clj" {
~ external_dependencies_patterns        = [
- "**",
 ]
 id                                    = "public-dockerhub-mirror"
 **~ list_remote_folder_items              = false -> true**

However, in the documentation, the default value for the list_remote_folder_items argument is false: list_remote_folder_items - (Optional, Default: false)

In the source code (https://github.com/jfrog/terraform-provider-artifactory/blob/master/pkg/artifactory/resource/repository/remote/remote.go), the default for this argument is:

			"list_remote_folder_items": {
				Type:     schema.TypeBool,
				Optional: true,
				Default:  true,
				Description: "Lists the items of remote folders in simple and list browsing. The remote content is cached " +
					"according to the value of the 'Retrieval Cache Period'. Default value is 'true'.",
			},

Artifactory version: 7.46 -> to be upgraded to 7.77.3 after provider upgrade
Terraform provider: 10.1.2

Expected behavior
No modification to be done for list_remote_folder_items

@mindruandrei3 I traced this back to a change in January 2023 and we didn't update the documentation to match.

What is your previous provider version that you are upgrading from?

I've added this to our plan.

@mindruandrei3 tl;dr - Unfortunately, this can't be fixed. You can use lifecycle.ignore_changes meta argument for these attributes, or set the attribute in your configuration.


We switched the default value for a number of remote repository attributes back in 6.23.0 in Jan 2023. We made the mistake of not including a Terraform state upgrading function to switch the state to the new value. This means any new remote repository resource created from 6.23.0 onwards will have a different default values (for a small set of attributes) from resources created before 6.23.0.

Once the values are stored in the Terraform state, the provider does not have any ability to determine if that state value is explicitly set from the configuration or as a default value. This means the providers can't selectively 'fix' the erroneous value automagically for resources created using provider prior to 6.23.0. 😞

Switching the default value back will create the same problem but for all the resources created using 6.23.0 and after.


To avoid Terraform reporting the state drift, use lifecycle.ignore_changes meta argument:

resource "artifactory_remote_docker_repository" "my-docker-remote" {
  ...

  lifecycle {
    ignore_changes = [
     list_remote_folder_items,
    ]
  }

Or, set the attribute with value:

resource "artifactory_remote_docker_repository" "my-docker-remote" {
  ...
  list_remote_folder_items = false
}

Hello,

We fixed the plan drift by explicitly setting the parameter to false.
Thank you for your answer.

Regards,
Andrei