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

Importing resources fails #939

Open
adrpp opened this issue Jan 18, 2025 · 2 comments
Open

Importing resources fails #939

adrpp opened this issue Jan 18, 2025 · 2 comments
Labels
kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team

Comments

@adrpp
Copy link

adrpp commented Jan 18, 2025

Describe what happened

Hello,

I'm struggling a bit with Pulumi using DO provider trying to import our existing infrastructure to Pulumi.

used (v)env with py3.12 base interpreter:

poetry show | egrep "pulumi|digitalocean"
pulumi 3.145.0 Pulumi's Python SDK
pulumi-digitalocean 4.38.0 A Pulumi package for creating and managing D...

First of all, created API token seems to work just fine, double checked that via your client pydo:

from pydo import Client

client = Client(token="$TOKEN")
projects = client.projects.list()
domains = client.domains.list()
droplets = client.droplets.list()
print(projects)
print(domains)
print(droplets)

The above prints all 3 resources, projects, domains and droplets.
It starts to get confusing as soon executing pulumi import, however, the error varies by the resource I try to import, e.g.:

Importing "Project":

pulumi import digitalocean:index/project:Project $ProjectName $ProjectUuid

digitalocean:index:Project ($Project):
error: sdk-v2/provider2.go:515: sdk.helper_schema: Error reading Project: GET https://api.digitalocean.com/v2/projects/$ProjectUuid: 401 (request "33678c9e-844d-4ed8-b7f7-b77562268e4e") Unable to authenticate you: provider=digitalocean@4.38.0
error: Preview failed: refreshing urn:pulumi:prod::$ProjectName::digitalocean:index/project:Project::$ProjectName: 1 error occurred:
* Error reading Project: GET https://api.digitalocean.com/v2/projects/$ProjectUuid: 401 (request "33678c9e-844d-4ed8-b7f7-b77562268e4e") Unable to authenticate you

Importing Droplet:

pulumi import digitalocean:index/droplet:Droplet [$DropletName](https://$DropletFqdn) $DropletId

digitalocean:index:Droplet ($DropletFqdn):
error: Preview failed: resource $DropletId does not exist

Importing Domain:

pulumi import digitalocean:index/domain:Domain $Name [$DomainName](https://$DomainName/)

digitalocean:index:Domain ($Name):
error: sdk-v2/provider2.go:515: sdk.helper_schema: Error retrieving domain: GET https://api.digitalocean.com/v2/domains/$DomainName: 401 (request "b385f666-369f-4cbd-ae2d-08426f38ee60") Unable to authenticate you: provider=digitalocean@4.38.0
error: Preview failed: refreshing urn:pulumi:prod::$Project::digitalocean:index/domain:Domain::$Name: 1 error occurred:
* Error retrieving domain: GET https://api.digitalocean.com/v2/domains/$DomainName: 401 (request "b385f666-369f-4cbd-ae2d-08426f38ee60") Unable to authenticate you

Summary:

  • importing "Project" leads to 401
  • importing "Droplet" leads to "resourse does not exist" aka 404
  • importing "Domain" leads to 401
  • for all imports I've used the same token used by pydo client which finds & resolves the resources I try to import to pulumi.

Thanks for any hint in advance,
Adrian

Sample program

Importing "Project":

pulumi import digitalocean:index/project:Project $ProjectName $ProjectUuid

digitalocean:index:Project ($Project):
error: sdk-v2/provider2.go:515: sdk.helper_schema: Error reading Project: GET https://api.digitalocean.com/v2/projects/$ProjectUuid: 401 (request "33678c9e-844d-4ed8-b7f7-b77562268e4e") Unable to authenticate you: provider=digitalocean@4.38.0
error: Preview failed: refreshing urn:pulumi:prod::$ProjectName::digitalocean:index/project:Project::$ProjectName: 1 error occurred:
* Error reading Project: GET https://api.digitalocean.com/v2/projects/$ProjectUuid: 401 (request "33678c9e-844d-4ed8-b7f7-b77562268e4e") Unable to authenticate you

Importing Droplet:

pulumi import digitalocean:index/droplet:Droplet [$DropletName](https://$DropletFqdn) $DropletId

digitalocean:index:Droplet ($DropletFqdn):
error: Preview failed: resource $DropletId does not exist

Importing Domain:

pulumi import digitalocean:index/domain:Domain $Name [$DomainName](https://$DomainName/)

digitalocean:index:Domain ($Name):
error: sdk-v2/provider2.go:515: sdk.helper_schema: Error retrieving domain: GET https://api.digitalocean.com/v2/domains/$DomainName: 401 (request "b385f666-369f-4cbd-ae2d-08426f38ee60") Unable to authenticate you: provider=digitalocean@4.38.0
error: Preview failed: refreshing urn:pulumi:prod::$Project::digitalocean:index/domain:Domain::$Name: 1 error occurred:
* Error retrieving domain: GET https://api.digitalocean.com/v2/domains/$DomainName: 401 (request "b385f666-369f-4cbd-ae2d-08426f38ee60") Unable to authenticate you

Log output

No response

Affected Resource(s)

No response

Output of pulumi about

CLI
Version 3.130.0
Go Version go1.22.6
Go Compiler gc

Plugins
KIND NAME VERSION
resource digitalocean 4.38.0
language python unknown

Host
OS ubuntu
Version 24.04
Arch x86_64

This project is written in python: executable='.venv/bin/python' version='3.12.3'

Backend
Name g14-2
URL file:local-state
User adrian
Organizations
Token type personal

Dependencies:
NAME VERSION
pulumi_digitalocean 4.38.0
pydo 0.7.0

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@adrpp adrpp added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Jan 18, 2025
@guineveresaenger
Copy link
Contributor

Hi @adrpp, thank you for filing this issue. Sorry you're running into trouble!

It seems like there's something in your provider config that's not set up to properly authenticate you.
How are you setting the DIGITALOCEAN_TOKEN? You should be able to either set it in your environment, or on your provider config: https://www.pulumi.com/registry/packages/digitalocean/#configuration-reference.

Possibly related: #836 (that issue seems to say that what you're seeing on Droplet may also be an auth issue in disguise. We should certainly send more helpful error messages here.)

@guineveresaenger guineveresaenger added awaiting-feedback Blocked on input from the author and removed needs-triage Needs attention from the triage team labels Jan 22, 2025
@adrpp
Copy link
Author

adrpp commented Jan 26, 2025

Hi,

I'm providing DO token via cli stack creation, as input.
Setting as env var for "pulumi import" cli cmd does not make a difference, retrieving same error.

e.g.

DIGITALOCEAN_TOKEN=XXXX; pulumi import digitalocean:index/droplet:Droplet "DROPLET_NAME" DROPLET_ID

Rgds,
Adrian

@pulumi-bot pulumi-bot added needs-triage Needs attention from the triage team and removed awaiting-feedback Blocked on input from the author labels Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team
Projects
None yet
Development

No branches or pull requests

3 participants