https://pulumi.com logo
#typescript
Title
# typescript
g

green-bird-4706

09/28/2022, 12:35 AM
Hi everyone, I have a small existing project managed by Terragrunt/Terraform I am trying to migrate to Pulumi. I have tried to migrate us
tf2pulumi
but it doesn't support Terraform modules which we rely on heavily, so I abandoned that. I found a video on youtube of a livestream (

here

) that uses
tfstate
to import resources. I have tried to emulate that, I have this
resources.json
file:
Copy code
{
  "resources": [
    {
      "name": "lambda",
      "type": "AWS::Lambda::Function",
      "id": "ingestDataLambda"
    }
  ]
}
Which I just scraped out with JS. It was longer but I cut it down to importing one resource for simplicity. When I run
pulumi import -f resources.json --out index.ts
I get an error
Copy code
error: preview failed: failed to validate provider config: Could not automatically download and install resource plugin 'pulumi-resource-AWS'at version v5.16.0, install the plugin using `pulumi plugin install resource AWS v5.16.0`.
    Underlying error: error downloading plugin AWS to file: failed to download plugin: AWS-5.16.0: 403 HTTP error fetching plugin from <https://get.pulumi.com/releases/plugins/pulumi-resource-AWS-v5.16.0-linux-amd64.tar.gz>
I also get a
403
error when I run the
pulumi plugin install
. I have tried removing the
node_modules
folder and using
yarn
, using
Pulumi 3.38.0
and
Pulumi 3.40.2
. I am running:
Copy code
Description:    Debian GNU/Linux 9.13 (stretch)
Release:        9.13
Codename:       stretch
Inside Windows 11 WSL2. I have managed to deploy a simple S3 bucket to the AWS account so the Pulumi setup works, it just doesn't want to import for me. I have also tried reinstalling Pulumi on
Copy code
Description:    Ubuntu 20.04.5 LTS
Release:        20.04
Codename:       focal
But it has the exact same issue. I am currently running
v14.19.1
Thanks in advance for any help. I have searched this Slack channel and stack overflow but haven't found anything that will help.
l

little-cartoon-10569

09/28/2022, 12:52 AM
Looks like there's a case-sensitivity problem. The AWS plugin is called pulumi-resource-aws, not pulumi-resource-AWS. Maybe try changing the type to begin with "aws"?
g

green-bird-4706

09/28/2022, 1:00 AM
Thanks, that's fixed that error. I get a different error, I think the
type
field might still be wrong. Does
"type": "aws::Lambda::Function"
look correct - is there documentation on what the type fields should be. Terraform gave me
_
instead of
::
and I deduced the type from the AWS console. The error I get is:
Copy code
error: Preview failed: unrecognized resource type (Read): aws:Lambda:Function
So the type field would still seem incorrect.
l

little-cartoon-10569

09/28/2022, 1:05 AM
If it's a Pulumi type, then yes, it's wrong. Maybe those are Terraform types? To find a Pulumi type, you can look in the approppriate module: they're always at the bottom of the .js file, called
<module>.__pulumiType
. For example, aws/lambda/function.js says that the type is
aws:lambda/function:Function
.
g

green-bird-4706

09/28/2022, 1:14 AM
I've found that now inside the node modules. And that has imported successfully. 🎉 I can go and work out the other 20 resources now and import them now. Thanks so much for your help, I never found anything close to what the issue was.
👍 1
76 Views