microsoft / terraform-provider-azuredevops

Terraform Azure DevOps provider
https://www.terraform.io/docs/providers/azuredevops/
MIT License
385 stars 275 forks source link

Artifactory Service Connection null token after user changes description, URL. #422

Closed billbirchatcoles closed 5 days ago

billbirchatcoles commented 3 years ago

Community Note

Terraform (and Azure DevOps Provider) Version

v0.14.11

Affected Resource(s)

Terraform Configuration Files

resource "azuredevops_serviceendpoint_artifactory" "serviceendpoint" {
  for_each = var.artifactory_service_connections

  project_id            = azuredevops_project.this.id
  service_endpoint_name = each.value.name
  description           = format("Artifactory Service Connection (%s)", split("/", each.value.url)[2])
  url                   = each.value.url
  authentication_token {
    token = each.value.token
  }
}

Debug Output

At this point Terraform has set the internal token to β€œnull” instead of the token. Here's the proof, taken from the arguments passed into the jfrog executable in the pipeline which uses the Service Connection :

  "args": [
    "/apps/agent/_work/_tool/jfrog/1.47.1/x64/jfrog",
    "rt",
    "u",
    "--url=https://colesgroup.jfrog.io/colesgroup",
    "--access-token=null",
    "--spec=/apps/agent/_work/27/s/uploadSpec1626257680947.json",
    "--build-name=CEFS-DevOpsOnboarding",
    "--build-number=20210714.50",
    "--fail-no-op=true",
    "--dry-run=false",
    "--insecure-tls=false",
    "--threads=3",
    "--retries=3",
    "--symlinks=false"
  ],

Expected Behavior

The access token in the Service Connection should not be set to "null"

Actual Behavior

The access token in the Service Connection was set to "null" when Terraform apply ran.

Steps to Reproduce

This defect only appears after the following sequence of events:

  1. User modifies Artifactory Service Connection via the web UI, changes the URL or description, but not the token. (Use Save without verify).

  2. User runs the terraform plan and apply. This applies a plan:

image

[Notice the plan makes no mention of intent to update the secret access token.]

Note

I will be working on a fix for this myself in the next couple of days...

xuzhang3 commented 3 years ago

Hi @billbirchatcoles Normally, we do not recommend users change the resource configurations outside of Terraform, unpredictable. This issue might caused by the d.Set("authentication_token", xxx) at https://github.com/microsoft/terraform-provider-azuredevops/blob/master/azuredevops/internal/service/serviceendpoint/resource_serviceendpoint_artifactory.go#L151

venkatesh-thatham commented 2 years ago

@xuzhang3, last commented was Jul 19, 2021. It's been more than an year the issue remain open. any update on the fixes. looking forward to be hearing from you

xuzhang3 commented 2 years ago

@thatham #656 will fix this bug. Service will return the sensitive data password/token etc. as empty string or null, this cause the second update change the token to null even user not update the HCL.

venkatesh-thatham commented 2 years ago

@xuzhang3 I'm still getting below error Error: Error creating service endpoint in Azure DevOps: Unable to find service connection type 'artifactoryService' using authentication scheme 'Token'.

xuzhang3 commented 2 years ago

@thatham you need install the JFrom Artificatory extension( https://marketplace.visualstudio.com/items?itemName=JFrog.jfrog-artifactory-vsts-extension) for your ORG, this extension was not enabled by default.

venkatesh-thatham commented 2 years ago

@xuzhang3 we had installed JFrom Artificatory extension in our Azure DevOps, this is error

Error: Error creating service endpoint in Azure DevOps: Unable to find service connection type 'artifactoryService' using authentication scheme 'Token'. β”‚ β”‚ with module.jfrog_service_connections["0"].azuredevops_serviceendpoint_artifactory.distribution, β”‚ on modules/jfrog/distribution.tf line 1, in resource "azuredevops_serviceendpoint_artifactory" "distribution": β”‚ 1: resource "azuredevops_serviceendpoint_artifactory" "distribution" { β”‚ β•΅ β•· β”‚ Error: Error creating service endpoint in Azure DevOps: Unable to find service connection type 'artifactoryService' using authentication scheme 'Token'. β”‚ β”‚ with module.jfrog_service_connections["0"].azuredevops_serviceendpoint_artifactory.artifactory, β”‚ on modules/jfrog/main.tf line 1, in resource "azuredevops_serviceendpoint_artifactory" "artifactory": β”‚ 1: resource "azuredevops_serviceendpoint_artifactory" "artifactory" { β”‚ β•΅ β•· β”‚ Error: Error creating service endpoint in Azure DevOps: Unable to find service connection type 'artifactoryService' using authentication scheme 'Token'. β”‚ β”‚ with module.jfrog_service_connections["0"].azuredevops_serviceendpoint_artifactory.platform, β”‚ on modules/jfrog/platform.tf line 1, in resource "azuredevops_serviceendpoint_artifactory" "platform": β”‚ 1: resource "azuredevops_serviceendpoint_artifactory" "platform" { β”‚ β•΅ β•· β”‚ Error: Error creating service endpoint in Azure DevOps: Unable to find service connection type 'artifactoryService' using authentication scheme 'Token'. β”‚ β”‚ with module.jfrog_service_connections["0"].azuredevops_serviceendpoint_artifactory.xray, β”‚ on modules/jfrog/xray.tf line 1, in resource "azuredevops_serviceendpoint_artifactory" "xray": β”‚ 1: resource "azuredevops_serviceendpoint_artifactory" "xray" {

xuzhang3 commented 2 years ago

@thatham can you check that the extension correctly installed? image

venkatesh-thatham commented 2 years ago

@xuzhang3, we have installed this extension which has all service connection modules image

image

xuzhang3 commented 2 years ago

@thatham a bit different from my extension, image

you need install this extension: image

I will update the doc to include the requirement.

venkatesh-thatham commented 2 years ago

@xuzhang3 Jfrog Artifactory extension is using old version. if you refer my previous screenshots there's distinct difference between these two extension. https://www.jfrog.com/confluence/display/JFROG/Artifactory+Azure+DevOps+Extension https://www.jfrog.com/confluence/display/JFROG/JFrog+Azure+DevOps+Extension (using V2)

xuzhang3 commented 2 years ago

@thatham current resource only support the old version. A new resource need to added to support Artifactory v2

venkatesh-thatham commented 1 year ago

@thatham current resource only support the old version. A new resource need to added to support Artifactory v2

@xuzhang3, any plan to upgrade or create a set of resources and datasources with new versions ?. Looking forward to be hearing from you.

venkatesh-thatham commented 1 year ago

@xuzhang3, there's a PR #705 update to Jfrog V2, could you please review and merge. Appreciate your response timely