broad-hairdresser-1495
04/30/2021, 3:57 PMpulumi.export()
is it possible to use that output to a variable and use this data later in the code?
my_volumeID = pulumi.export('volume_ID', volume.id)
or is it just for output?better-actor-92669
04/30/2021, 4:05 PMvolume.id
directly. Or, if you need to use apply()
, something like
member=service_account.email.apply(
lambda x: 'serviceAccount:' + x
)
broad-hairdresser-1495
04/30/2021, 4:11 PMvolume.id
in Pulumi :
ebs_att = aws.ec2.VolumeAttachment(volume_["tags"]["Name"],
device_name=volume_["device_name"],
volume_id=volume.id,
instance_id=server.id)
but that is for aws Pulumi functions.
i want to write that volume.id to file:
fw = open("myFile.txt", "w")
fw.write(volume.id)
fw.close()
better-actor-92669
04/30/2021, 4:30 PMdef pulumi_output_renderer_kps(args_to_render) -> None:
from service_scripts.template_files import template_config
jinja2_variables_dict_kps = {
# TODO: define varialbes for KPS values
'project_name': project_name,
'project_zones': gcp_region_zones,
}
template_config(
args_to_render[0],
args_to_render[1],
jinja2_variables_dict_kps,
render_in_place=False,
write_to_stdout=False,
)
Output.all(
kps_additional_scrape_configs_out_file_location,
kps_additional_scrape_configs_j2_location,
).apply(pulumi_output_renderer_kps)
broad-hairdresser-1495
04/30/2021, 4:37 PMred-match-15116
04/30/2021, 4:44 PMdef write_id_to_file(id):
with open("myFile.txt", "w") as fw:
fw.write(id)
volume.id.apply(write_id_to_file)
broad-hairdresser-1495
05/04/2021, 7:45 AMdef write_id_to_file(id, instanceName):
with open("myFile.txt", "w") as fw:
fw.write(id + instanceName)
volume.id.apply(write_id_to_file, instanceName)
I tested out with global variable, but that did not work when there is multiple instances.def pulumi_output_renderer(args_to_render):
with open("myFile.txt", "a") as fw:
fw.write(args_to_render[0] + " - " + str(args_to_render[1]["Name"]) + "\n")
pulumi.Output.all(volume.id, host.tags).apply(pulumi_output_renderer)
also more info can be found here: https://www.pulumi.com/docs/intro/concepts/inputs-outputs/