Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Auth-type 'oauth2' is not supported, use 'personal_token' instead after importing scalr_vcs_provider #375

Open
huguesalary opened this issue Dec 2, 2024 · 3 comments

Comments

@huguesalary
Copy link

The error:

│ Error: Error updating vcs provider vcs-xxxxxxxxxxxxxxxxxx: Invalid Attribute
│ 
│ Auth-type 'oauth2' is not supported, use 'personal_token' instead.
│ 
│   with scalr_vcs_provider.gitlab,
│   on workspace-scalr.tf line 49, in resource "scalr_vcs_provider" "gitlab":
│   49: resource "scalr_vcs_provider" "gitlab" {
│ 

(vcs-xxxxxxxxxxxxxxxxxx is a redacted ID)


How it happened:

  • Created a brand new Scalr account
  • Added a Gitlab VCS connection via the Scalr UI, named gitlab - Hugues (note the name, it's important)
  • Created a main.tf file
import {
  to = scalr_vcs_provider.gitlab
  id = "vcs-xxxxxxxxxxxxxxxxxx"
}

resource "scalr_vcs_provider" "gitlab" {
  name     = "gitlab"    # note the name here is `gitlab` and not `gitlab - Hugues`
  vcs_type = "gitlab"
  token    = "gloas-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
  • Run tofu apply
  # scalr_vcs_provider.gitlab will be updated in-place
  # (imported from "vcs-xxxxxxxxxxxxxxxxxx")
  ~ resource "scalr_vcs_provider" "gitlab" {
        account_id = "acc-xxxxxxxxxxxxxxxxxx"
        id         = "vcs-xxxxxxxxxxxxxxxxxx"
      ~ name       = "gitlab - Hugues" -> "gitlab"
      + token      = (sensitive value)
        url        = "https://gitlab.com"
        vcs_type   = "gitlab"
    }

This last step errors with

│ Error: Error updating vcs provider vcs-xxxxxxxxxxxxxxxxxx: Invalid Attribute
│ 
│ Auth-type 'oauth2' is not supported, use 'personal_token' instead.
│ 
│   with scalr_vcs_provider.gitlab,
│   on workspace-scalr.tf line 49, in resource "scalr_vcs_provider" "gitlab":
│   49: resource "scalr_vcs_provider" "gitlab" {
│ 
@emocharnik
Copy link
Contributor

Hi, @huguesalary. Unfortunately, the Scalr provider cannot support oauth2 VCS providers as they require manual interventions from users to complete installation, which is not possible in the Terraform mode. So that's why personal access tokens are supported only.

@huguesalary
Copy link
Author

Thank you @emocharnik, that makes sense.

That being said, the way current scalr_vcs_provider resource works is confusing/maybe buggy?

Below are 2 confusing scenarios.


1st scenario

This scenario is the one I originally created this issue for.

  • Manually create a VCS connection using the Scalr UI, called "gitlab"
  • Import the VCS connection in opentofu using a scalr_vcs_provider (see import block below)
import {
  to = scalr_vcs_provider.gitlab
  id = "vcs-xxxxxxxxxxxxxxxxxx"
}

resource "scalr_vcs_provider" "gitlab" {
  name     = "gitlab"
  vcs_type = "gitlab"
  token    = "gloas-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
  • Run tofu apply
  • Modify the name (or any attribute really) of the VCS connection
import {
  to = scalr_vcs_provider.gitlab
  id = "vcs-xxxxxxxxxxxxxxxxxx"
}

resource "scalr_vcs_provider" "gitlab" {
  name     = "gitlab-renamed" # <--- changed the name here
  vcs_type = "gitlab"
  token    = "gloas-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
  • Run tofu apply
  # scalr_vcs_provider.gitlab will be updated in-place
  # (imported from "vcs-xxxxxxxxxxxxxxxxxx")
  ~ resource "scalr_vcs_provider" "gitlab" {
        account_id = "acc-xxxxxxxxxxxxxxxxxx"
        id         = "vcs-xxxxxxxxxxxxxxxxxx"
      ~ name       = "gitlab" -> "gitlab-renamed"
        token      = (sensitive value)
        url        = "https://gitlab.com"
        vcs_type   = "gitlab"
    }

This errors out with

│ Error: Error updating vcs provider vcs-xxxxxxxxxxxxxxxxxx: Invalid Attribute
│ 
│ Auth-type 'oauth2' is not supported, use 'personal_token' instead.
│ 
│   with scalr_vcs_provider.gitlab,
│   on workspace-scalr.tf line 49, in resource "scalr_vcs_provider" "gitlab":
│   49: resource "scalr_vcs_provider" "gitlab" {
│ 

Why it is confusing

I was able to import the resource using an import{} block and opentofu didn't complain.

Only when I changed an attribute of the resource (the name here), did I get an error from opentofu, but the error seems entirely unrelated: what does oauth2 have to do with the name change?

2nd scenario

This scenario might just be a bug?

Trying to create a scalr_vcs_provider resource for the first time:

resource "scalr_vcs_provider" "gitlab" {
  name     = "gitlab"
  vcs_type = "gitlab"
  token    = var.gitlab_access_token
}

Returns this error:

OpenTofu v1.8.6
Configuring remote state backend...
Initializing plugins and modules...
scalr_vcs_provider.gitlab: Creating...
╷
│ Error: Error creating vcs provider gitlab: Not found.
│ 
│ Entity does not exist (OauthApplication).
│ 
│   with scalr_vcs_provider.gitlab,
│   on workspace-scalr.tf line 26, in resource "scalr_vcs_provider" "gitlab":
│   26: resource "scalr_vcs_provider" "gitlab" {
│ 
╵

Why it is confusing

I'm trying to create a new VCS provider: why does it complain about not finding it?

@rtfee
Copy link
Contributor

rtfee commented Jan 24, 2025

@huguesalary sorry for the delay on this, we are reviewing the two scenarios

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants