https://pulumi.com logo
Title
c

cold-yacht-45876

04/13/2021, 7:43 PM
Hi, I've previously used an explicit provider for resources in a stack:
const role = new aws.iam.Role(`role-name`, {
      assumeRolePolicy: '...'
    },
    {
      provider
    });
Now I'd like to remove the provider option to use the default provider, but now pulumi wants to replace the resource:
const role = new aws.iam.Role(`role-name`, {
      assumeRolePolicy: '...'
    });
Is there a way around this, or am I stuck with keeping the explicit provider or accepting the replace operation? Not that big of a deal for this particular resource, but it's worse for stuff like databases, queues, etc.
l

little-cartoon-10569

04/13/2021, 8:24 PM
Unfortunately there is no simple support for this. There are two options that I have used that work well.
The easier depends on there not being any references to the resource (e.g. from child resources). You can delete the resource from state and import it again. Importing resources uses the default provider (unless you edit the created code).
The harder option is to export the stack, find the "wrong" and default providers, edit the resource's provider from the "wrong" one to the default, and import the stack. Not harder, I suppose, but more scary, with more potential for mistakes.
c

cold-yacht-45876

04/13/2021, 8:59 PM
ok, got it. Thanks!