https://pulumi.com logo
#kubernetes
Title
# kubernetes
b

bored-table-20691

05/28/2021, 6:48 PM
What’s the typical way of renaming a resource? Specifically, let’s say I have:
Copy code
appsv1.NewDeployment(ctx, "myDeployment", &appsv1.DeploymentArgs{
and I want to change it to
Copy code
appsv1.NewDeployment(ctx, "my-deployment", &appsv1.DeploymentArgs{
If I do that, it fails because it says the Deployment already exists with that name (note that I have given it an explicit name, so it is not using autonaming)
g

gorgeous-egg-16927

05/28/2021, 8:18 PM
You should be able to set the
DeleteBeforeReplace
resource option to do this: https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/pulumi#DeleteBeforeReplace
b

bored-table-20691

05/28/2021, 8:22 PM
Would you recommend to set it once to do this replacement and then remove it? Because generally I wouldn’t want this behavior, it’s just this one time as I do the renaming.
Conceptually I just want something like a
pulumi stack rename resource <old name> <new name>
g

gorgeous-egg-16927

05/28/2021, 8:40 PM
Would you recommend to set it once to do this replacement and then remove it?
Yes.
Conceptually I just want something like a pulumi stack rename resource <old name> <new name>
As far as I know, there’s no current support for this.
4 Views