average-horse-29207
08/31/2023, 12:14 PMpulumi up
, it complains that it can't create the resource (as it already exists). Based on https://www.pulumi.com/blog/repairing-state-with-pulumi-refresh/ I was expecting to be able to use pulumi refresh
to import the existing resource into the state, however pulumi refresh
command doesn't even seem to see the resource group or storage account, and doesn't seem to do anything. Any ideas why the refresh command isn't seeing any resources to refresh?
pulumi up:
Enter your passphrase to unlock config/secrets
(set PULUMI_CONFIG_PASSPHRASE or PULUMI_CONFIG_PASSPHRASE_FILE to remember):
Previewing update (dev):
Type Name Plan
pulumi:pulumi:Stack pulumi-test-dev
+ ├─ azure-native:resources:ResourceGroup resourceGroup create
+ └─ azure-native:storage:StorageAccount storage create
Resources:
+ 2 to create
1 unchanged
Do you want to perform this update? yes
Updating (dev):
Type Name Status Info
pulumi:pulumi:Stack pulumi-test-dev **failed** 1 error
+ └─ azure-native:resources:ResourceGroup resourceGroup **creating failed** 1 error
Diagnostics:
azure-native:resources:ResourceGroup (resourceGroup):
error: cannot create already existing subresource '/subscriptions/REDACTED/resourcegroups/AC-PulumiTest-dev'
pulumi:pulumi:Stack (pulumi-test-dev):
error: update failed
Resources:
1 unchanged
Duration: 5s
pulumi refresh
Previewing refresh (dev):
Type Name Plan
pulumi:pulumi:Stack pulumi-test-dev
Resources:
1 unchanged
Do you want to perform this refresh?
No resources will be modified as part of this refresh; just your stack's state will be.
yes
Refreshing (dev):
Type Name Status
pulumi:pulumi:Stack pulumi-test-dev
Resources:
1 unchanged
resource in Program.cs
var config = new Pulumi.Config();
var shortName = config.Require("shortName");
ResourceGroup resourceGroup = new("resourceGroup", new()
{
ResourceGroupName = $"AC-PulumiTest-{shortName}"
});
brave-planet-10645
08/31/2023, 12:32 PMpulumi import
command or the add the id to the resource. There’s some guidance on what to do (I would use the pulumi import
command personally) on this page: https://www.pulumi.com/docs/using-pulumi/adopting-pulumi/import/average-horse-29207
08/31/2023, 12:36 PMpulumi refresh
to interactively walk me through the imports I needed
Are these two different kinds of imports?brave-planet-10645
08/31/2023, 12:37 PMaverage-horse-29207
08/31/2023, 12:56 PMpulumi refresh
couldn't detect these changes, or is simply something that hasn't been written. I'm coming with a lot of familiarity deploying with ARM / bicep templates which don't include a state file, so I'm still trying to wrap my head around what the state file is doing)brave-planet-10645
08/31/2023, 12:57 PMaverage-horse-29207
08/31/2023, 12:57 PMbrave-planet-10645
08/31/2023, 12:58 PMaverage-horse-29207
08/31/2023, 1:08 PMpulumi refresh
is purely looking at the state. And because pulumi's initial creation never got far enough to insert into the statefile, pulumi refresh
never knows about the other resources.
My thinking was that since plumui up
knew enough about what resource to create (and that conflicted), that it could therefore be able to work out the specific resource to import. However I never see a call to dotnet build
when running pulumi refresh
, so it never has any of that information available to it.brave-planet-10645
08/31/2023, 1:08 PM