Hi I am trying to update ONLY one parameter of th...
# general
l
Hi I am trying to update ONLY one parameter of the resource, my workflow is like this: 1. get the resource id from current resource which is not managed by the pulumi 2. get the resource by using the pulumi lookup 3. make a new resource using import and then update the value. the reason of doing this is because I do not know the current resource value and I only want to change one parameter, however if I want to use new resource with import parameter, I have to set the required parameters which is not know by me https://gist.github.com/atazangene/f600c7c7f9d7039ea4db951f5f6d28db
and I get this error:
l
Pulumi is only declarative. You cannot change things: you can only declare what they must look like. If you want to update a resource, you must define that entire resource. Since you want to continue to manage that resource outside of Pulumi, you cannot use Pulumi to update it. You can update it in a Pulumi program though, using the normal SDK of whatever provider (AWS, Azure, ...) the resource is in.
s
so a dynamic provider would be the only interoperable choice in this case? https://www.pulumi.com/docs/concepts/resources/dynamic-providers/ never understood the
pulumi import
workflow, how would that differ?
l
No. You could manage the resource in Pulumi. Or you could update the resource via its normal SDK. You should almost certainly not try to get Pulumi to update an unmanaged resource.
s
gotcha, I missed the "normal" in your previous comment, and took it to mean "use the sdk in pulumi" if, for whatever reason, the normal sdk was used to update state outside pulumi, would a
pulumi refresh
be helpful here to resolve drift?
l
No. Since you're using the SDK directly, that bit of code is imperative, not declarative. You can use the Pulumi get functions where needed, and they also aren't affected by
pulumi refresh
.
You probably want to put the bit of code that calls the SDK into an apply() so that it happens at the right time, and you probably want to put in some sort of guard so that it doesn't happen if not needed.
And if you happen to be using automation-api, you may want to consider putting the code outside of your Pulumi projects entirely, and putting it directly into your automation-api code instead.