Is there a way to modify `inputs.__defaults` in th...
# aws
g
Is there a way to modify
inputs.__defaults
in the state via code? cc @red-match-15116 probably requires deep pulumi knowledge. For the context, I am trying to find the simplest (read without stack surgery) way to migrate lots of projects out of
awsx
So far I have a nice flow on how to refactor the code without losing resources.
e
The __defaults is a pulumi-terraform-bridge artifact that tries to record the origin of an actual property value to inform further treatment - did the value originate from applying a default or not. I recall it was slightly convoluted .. possibly would reach for explicit surgery in this case ... `pulumi stack export | transform | pulumi stack import``
g
Yeah, I was hoping I wouldn't have to, but if this is the only option it will be a very simple transformation.
It would be great if I could have types while working with the exported state but I could not find anything relevant. Programming language does not matter that much.
__defaults
are really the only thing preventing me from using
initialize
method to do rather heavy state transformation. Here's what I am working on: original code in the
constructor
(awsx creates component resource and urn)
Copy code
const sg = awsx.ec2.SecurityGroup(...)
new code migrated away from
awsx
without aliases.
protected initialize(args: pulumi.Inputs)
Copy code
const sg = awsx.ec2.SecurityGroup(...) // transformation with retain on delete=true

const sgIdPromise = new Promise((resolve) => sg.id.apply(resolve))

const classicSg = new aws.ec2.SecurityGroup(
"resourceName"
{
  name: sg.securityGroup.name
},
{
import: await sgIdPromise
}
e
Yeah, interesting idea but not supported yet AFAIK (generated types for state). There is type information in Pulumi Package Schema but the generated helper types are focused on direct use scenarios not transforming state.
g
Pulumi Package Schema
- is this accessible from the code somewhere?
e
I think the most fleshed out SDK for working with it is in Go
g
thank you, time to brush up my Golang "skills"
r
Just wanna say I am flattered to be tagged as someone with deep pulumi knowledge 💜
And also that I am very glad @enough-garden-22763 jumped in because I sure had no idea how to answer this one
g
Sorry for tagging you directly, I usually try to avoid this but my questions can take me to the dark places.