I'm trying to perform a transformation that delete...
# general
h
I'm trying to perform a transformation that deletes some inputs conditionally. This works well but I can't figure out a way to detect whether the resource exists yet. Does anyone know if this is at all possible?
Copy code
transformations: [
        (args) => {
          if (args.type === 'kubernetes:apps/v1:Deployment') {
            // FIXME: We only want to set the image on create, not on updates
            const props = args.props as any
            props.spec.template.spec.containers.forEach((container: any) => {
              delete container.image
              delete container.imagePullPolicy
            })

            return { props, opts: args.opts }
          }
          return undefined
        }
      ],
PS I know transformations is going to be deprecated with transforms, but for the life of me I couldn't get it do delete those inputs.
e
I don't think this is possible. Transforms run on the declared goal state, which is agnostic to what operation is going to be performed. I think this ends up being some thing like https://github.com/pulumi/pulumi/issues/16189, which we keep thinking about but is a hard problem to do in a declarative way.
h
Ah well for now I managed to workaround that by exporting the stack using pulumi.automation and checking if the urn was in there already.