This message was deleted.
# general
s
This message was deleted.
g
The code you shared should work. Are you getting an error or is the file not being created?
f
if I split my stack into two; first to create the file,then second to read the file and use it, it works - I want to remove the file steps and just use the data in memory
Copy code
let private_key_encoded = "";
    service_account_key.privateKey.apply(k => private_key_encoded = k);
private_key_encoded is not set to k
g
Yea, this is a nuance to the async model within Pulumi. Can you share how you're wanting to use
private_key_encoded
? I can help you get it working and explain what's happening if I can see more of your code.
f
Copy code
const user_data_template = readFileSync('./cloud-config').toString();
    const vars_map = {
        private_key_json: private_key_encoded
    }
    const compiled_user_data = _.template(user_data_template);
    const rendered_user_data = compiled_user_data(vars_map);
so I'm using a template to render user-data for cloud-init
this key needs to be written to a specific location - I have similar (working) terraform code so essentially I'm translating from terraform
l
The
readFileSync
code also has to be inside the same
apply()
block. As written, that code is (potentially) being run before the
apply()
block.
private_key_encoded
is not updated by the time it is being used.