# general


02/21/2024, 1:28 PM
With dynamic providers written in nodejs, I understand the provider code is serialized and stored against the state of the custom resource. However I am seeing some strange behaviour with the serialization, wrt process.env variables being inlined. I'll paste the snippet in a thread, if someone wants to take a look.... 🐿️
Copy code
import * as pulumi from '@pulumi/pulumi'

const ev1 = process.env['EV1']

const randomprovider: pulumi.dynamic.ResourceProvider = {
  create(inputs) {
    const ev2 = process.env['EV2']
    const id = `${ev1}-${ev2}-${Math.random()}`
    return Promise.resolve({ id, outs: {} })

  delete(id, props) {
    const ev2 = process.env['EV2']
    console.log('deleting random with id:', id)
    console.log('ev1=', ev1, 'ev2=', ev2)
    return Promise.resolve()

export class Random extends pulumi.dynamic.Resource {
  constructor(name: string, opts?: pulumi.CustomResourceOptions) {
    super(randomprovider, name, {}, opts)
the value of ev1 is serializated into __provider, but for ev2 the same line is not replaced the behaviour of ev2 not being serialized is what I'd like to use (so I can adjust the endpoint URL of the remote provider if required), but I'd like to understand the difference in behaviour here
this is the most interesting line:
console.log('ev1=', ev1, 'ev2=', ev2)
when the delete function is run, ev1 will show the old value from the previous run, and ev2 will show the value from the current run