jfrog / terraform-provider-artifactory

Terraform provider to manage JFrog Artifactory
https://jfrog.com/artifactory
Apache License 2.0
271 stars 104 forks source link

artifactory_remote_maven_repository always updating password in plan/apply #347

Closed erlarson85 closed 2 years ago

erlarson85 commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

Requirements for and issue

Expected behavior A clear and concise description of what you expected to happen.

Additional context Add any other context about the problem here.

Terraform v1.1.7 on linux_amd64

resource "artifactory_remote_maven_repository" "mulesoft-ee" {
  key                            = "mulesoft-ee"
  repo_layout_ref                = "maven-2-default"
  url                            = data.vault_generic_secret.mulesoft.data["url"]
  handle_releases                = true
  handle_snapshots               = true
  includes_pattern               = "**/*"
  username                       = data.vault_generic_secret.mulesoft.data["username"]
  password                       = data.vault_generic_secret.mulesoft.data["password"]
  socket_timeout_millis          = "5000"
  store_artifacts_locally        = true
  block_mismatching_mime_types   = true
  retrieval_cache_period_seconds = "6000"
  missed_cache_period_seconds    = "1800"
  project_environments           = []
  property_sets                  = []
}

Terraform Plan:

Artifactory 107.33.12

Terraform will perform the following actions:

  # artifactory_remote_maven_repository.mulesoft-ee will be updated in-place
  ~ resource "artifactory_remote_maven_repository" "mulesoft-ee" {
        id                                    = "mulesoft-ee"
      ~ password                              = (sensitive value)
        # (43 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

After applying it will continue to state it will update in place. This happens whether password is hard coded or a data lookup.

Terraform state shows:

# artifactory_remote_maven_repository.mulesoft-ee:
resource "artifactory_remote_maven_repository" "mulesoft-ee" {
    allow_any_host_auth                   = false
...
    password                              = (sensitive value)

...
   unused_artifacts_cleanup_period_hours = 0
    url                                   = (sensitive)
    username                              = (sensitive)
    xray_index                            = false
chb0github commented 2 years ago

There is a long, tortured story about passwords. We are working on a solution and welcome your commentary:

chb0github commented 2 years ago

@alexhung - This may not be at all related to general password issues

alexhung commented 2 years ago

@chb0github After worked on #383 I think this issue may be similar with state or unpacking or omitempty. Will take a quick look today.

alexhung commented 2 years ago

Confirmed that this issue is caused by the hashing of the password for TF state, as well the unpacking not ignoring password field on read().

Solution in #383 will fix this issue.