Hello again! I'm here with another question. I sta...
# getting-started
h
Hello again! I'm here with another question. I started creating my projects with typescript and though it's relatively nice and clean, I think I prefer python. How do I convert my projects from typescript to python? I'm not even looking to translate index.ts to main . My projects are relatively simple so I can do that manually.
Is there a way to 1) keep the name of the project but change it from ts to py? and then 2) not have to destroy the existing resources?
Or do I have to 1) destroy the resources and stacks 2) create a new python project 3) write it all up from scratch and 4) re-create the resources?
c
The easiest and simplest way is if you are ok with destroying the resources, deleting the stack and then recreating everything with the desired project runtime. The other way involves renaming the project to something else which frees up the project name for you to create a new one with the original name using the desired runtime. Then you'd have to force-remove (
stack rm
) the stack in the renamed project without actually destroying any of the resources. Finally, you'd have to
pulumi import
every single resource into the new project's stack.
h
Thanks @clever-sunset-76585. At this stage, I'm ok with destroying the resources. But what I'll do is test what you suggested just in case I have to go through the scenario in the future when I can't afford to destroy the resources. So to reiterate, the steps are: 1. pulumi stack rename with FQ project name, that way the project gets renamed, rather than a stack. 2. pulumi stack rm -f to delete the stack but keep resources 3. create a new project with the same name as the original project 4. pulumi import each resource
c
Project names are specified in the
Pulumi.yaml
file, so you should update the name in that file after the rename. Also I just realized something. Since you'd be reusing the original project and the stack name, you can simply import the state into the new project that has the right runtime. For that you should first export the state from your current stack (before you run the stack rename) as a backup.
h
Hi @clever-sunset-76585 So I tried what you suggested and exported the stacks before a rename. I created a new project with the same name. I can't, however, import the stacks:
Copy code
error: the stack 'dev' is too old to be used by this version of the Pulumi CLI
I have a feeling it's because the original project was in ts and the new one is in python? Providers are not the same?
c
error: the stack 'dev' is too old to be used by this version of the Pulumi CLI
I have never seen that error before. What was the CLI version when you created the original TS-based project?
h
Unfortunately, I must have closed that terminal window so I can't tell the version of the CLI.. But it was recent. I started playing with Pulumi only a couple of weeks ago.
I also just updated the CLI and received the same error..
Huh, so an interesting bit is that the import worked just fine for a different stack.
It also worked ok for another project. Strange.
But I'm good. I was able to "translate" my project from TS to python without making changes to my resources.
And my automation in github actions picked it up and happily decided that the resources remained unchanged.
Thank you for all your help @clever-sunset-76585
c
That's strange indeed. You are still talking about a
pulumi stack import
, correct? Anyway glad you've sorted it out.
h
yeah, it was the stack import from a previously exported file.